Building A PXE Server
These instructions are for setting up PXE on Linux (Ubuntu). If you are on a different distro, replace apt-get with whatever is appropriate. All tftp stuff here is in /var/lib/tftpboot/ but you my have it in a different place. If desired you can check out my original presentation, and then head on to the commands and code.
Contents |
Server Side Setup
Dhcp
The first step in PXE booting is having the client make a DHCP request, so you need a DHCP server. Any normal one will do, the extra part you need is the part of the DHCP configuration to send a tftp server and a filename.
Running Your Own
It is also assumed that you already have the ip address configured for your dhcp server, and that it is in the range of your address pool:
apt-get install dhcp3-server vi /etc/dhcp3/dhcpd.conf #Edit at will, you need to specify your tftp server ip and file to grab: subnet 192.168.0.0 netmask 255.255.255.0 { range 192.168.0.70 192.168.0.100; filename "pxelinux.0"; next-server 192.168.0.1; option subnet-mask 255.255.255.0; option broadcast-address 192.168.0.255; option routers 192.168.0.1; } /etc/init.d/dhcp3-server restart
Note: There are lots of dhcp servers out there, each with their own configuration oddities. I do know that dhcp3-server works.
Using DD-WRT for DHCP
So you don't want to run your own dhcp server? Let your DD-WRT Router do it for you!
Using Openwrt's DnsMasq
With vi:
vi /etc/config/dhcp # add " option dhcp_boot pxelinux.0,,10.0.2.120" under the dnsmasq heading
Alternativly:
uci set dhcp.@dnsmasq[0].dhcp_boot=pxelinux.0,,10.0.2.120 uci commit
Then restart it:
/etc/init.d/dnsmasq restart
Tftp
#apt-get -y install inetutils-inetd tftpd-hpa apt-get -y install tftpd-hpa service tftpd-hpa start
pxelinux Initial Setup
cd /var/lib/tftpboot/ wget http://mirrors.tummy.com/pub/ftp.ubuntulinux.org/ubuntu/dists/lucid/main/installer-i386/current/images/netboot/ubuntu-installer/i386/pxelinux.0 mkdir pxelinux.cfg touch pxelinux.cfg/default
Extras
Memtest86+
cd /var/lib/tftpboot/ wget http://www.memtest.org/download/4.20/memtest86+-4.20.bin.gz gunzip memtest86+-4.20.bin.gz mv memtest86+-4.20.bin memtest #For me, I couldnt have it end in .bin otherwise I got continuous "0104"s on my screen echo "LABEL memtest KERNEL memtest" >> pxelinux.cfg/default
Ubuntu
Take these instructions with a grain of salt, they just do Lucid (10.04) Server edition. Look at the different options in here to add different install options.
cd /var/lib/tftpboot/ mkdir ubuntu-lucid-32 wget http://mirrors.tummy.com/pub/ftp.ubuntulinux.org/ubuntu/dists/lucid/main/installer-i386/current/images/netboot/ubuntu-installer/i386/linux -O ubuntu-lucid-32/linux wget http://mirrors.tummy.com/pub/ftp.ubuntulinux.org/ubuntu/dists/lucid/main/installer-i386/current/images/netboot/ubuntu-installer/i386/initrd.gz -O ubuntu-lucid-32/initrd.gz echo " LABEL lucid32 KERNEL ubuntu-lucid-32/linux APPEND tasks=standard pkgsel/language-pack-patterns= pkgsel/install-language-support=false vga=normal initrd=ubuntu-lucid-32/initrd.gz -- quiet " >> pxelinux.cfg/default
Rip
RIPLinux is a nice, small, PXE bootable linux distro. I also have easy instructions for remastering it to fit your needs.
cd /tmp wget http://www.tux.org/pub/people/kent-robotti/looplinux/rip/RIPLinuX-13.7.PXE.zip unzip RIPLinuX-13.7.PXE.zip mkdir /var/lib/tftpboot/rip cp tftpboot/rootfs.cgz /var/lib/tftpboot/rip/ cp tftpboot/kernel32 /var/lib/tftpboot/rip/ echo " LABEL rip KERNEL rip/kernel32 APPEND nokeymap initrd=rip/rootfs.cgz root=/dev/ram0 rw" >> /var/lib/tftpboot/pxelinux.cfg/default #If you are satisfied you got everything you want rm RIPLinuX-13.7.PXE.zip rm -rf /tmp/tftpboot
Display File for Reference
Although setting up the LABEL directive in your default file enables a particular PXE booting option, who can remember what you have available? You can create a simple text file to help you remember what you have.
PROMPT 1 DISPLAY banner.txt
And put something in your banner.txt:
Welcome to PXE boot! Options: memtest Memtest86+ lucid32 Install Ubuntu 10.04 Server rip Recovery Is Possible Linux
Don't forget, this is just a map, it is not the territory. Just because you have something in this text file doesn't mean it is enabled in your pxelinux.cfg.
PXE Knife
PXE Knife is a kind of Ultimate Boot CD but in PXE form. I have not tried it.
Boot Dos Images
First get the memdisk kernel
cp /usr/lib/syslinux/memdisk /var/lib/tftboot/
Now take whatever dos image you have, put it in /var/lib/tftboot/, then add lines like these to your default:
LABEL dos KERNEL memdisk APPEND initrd=dos.dd
Remember that file locations are relative.