When a PC boots, it typically locates a boot-loader or a bootable kernel on its hard disk, or on another medium such as a floppy disk, a CD-ROM, or a USB device. Some network cards, however, also have to capability of being used as a bootable medium : the contain a (ROM) chip that contains instructions to boot from a network server.
Using such a network card (PXE-capable network adaptors are a common example), it is possible to boot a PC by loading boot code of a network server. This can be used to setup diskless clients (terminals, thin clients, ... ), to bootstrap terminals, or to initiate an operating system setup (by loading an installer in stead of an operating system).
In this tutorial, we'll be exploring the basic concepts of network booting, network installation, and diskless clients. You can build on this to create your own implementation, although for complex, production-grade implementations, you might want to consider preconfigured packages to set this up (ltsp, edubuntu, ubuntu-ltsp, ...)
You need a server that will that provide a custom dhcp configuration, is capable of serving a bootable kernel over tftp, and provides a network file system or a ramdisk with a root filesystem to the clients. You can do all of this on the same machine, or use separate server for each role.
For the clients, you need a PC capable of PXE network boot. There are other network boot mechanisms but we won't go in to those.
You can use a full-blown dhcp server such as dhcpd, or a lightweight dhcp server that (at least) provides the options for dhcp boot. dnsmasq is a reasonable choice (it does both dhcp and dns).
Set up a dhcp server (howto). In addition to the usual dhcp configuration (address, netmask, ...), you need to add the following options :
the 2 server params are optional if the boot server is the same machine as the dhcp server; they refer to the tftp server where the client will get its boat loader or operating system from. The path to the file corresponds to the tftp location of the boot loader - we'll come to that in the next steps.
For dhcpd, you can look up the exact configuration syntax here.
For dnsmasq, the format is : dhcp-boot=file,servername,serveraddress
and don't forget /etc/init.d/dnsmasq restart
To test it, boot the client. You'll see it gets an IP address, but then it fails with "tftp timeout" because we've instructed it to download a file from tftp, but we haven't set that up yet. It does show that dhcp is working and the boot options are passed to the client. step 1 accomplished.
If things don't go as panned here, you'll need to get the dhcp server working correctly before you continue. Look in /var/log/syslog to see what's happening
tftp (trivial file transfer protocol) is a trivial file transfer protocol. It's used for straightforward file transfers without any bells or whistles. Not all tftp servers support the required parameters for PXE network boot. On Debian and Ubuntu, you can use tftpd-hpa or atftpd (Advanced tftp daemon). If you're already using dnsmasq for dhcp server, you can enable dnsmasq's build-in tftp server (!) simply by editing /etc/dnsmasq.conf (dnsmasq version 2.41 compiled with TFTP option, as is on Ubuntu 7.10 server) - this is explained here
You can go with the default tftp directory, or choose your own. I prefer the latter, it makes it easier to see how things fit together, which helps if you want to customize things. So we'll create a directory /srv/tftp where we will be serving files from.
tftp doesn't do any user authentication. Therefore, the files you want tftpd to serve need to be world-readable.
Lastly, we need to edit the configuration file. We'll run atftpd on its own (not controlled by inetd), and indicate we'll serve out of /srv/tftp
apt-get install atftpd mkdir /srv/tftp ### tftpd.conf USE_INETD=false OPTIONS="--daemon --port 69 --tftpd-timeout 300 --retry-timeout 5 --mcast-port 1758 --mcast-addr 18.104.22.168-255 --mcast-ttl 1 --maxthread 100 --verbose=5 /srv/tftp"
More info: Quick HOWTO, or howto setup atftp in ubuntu
That concludes Step 2.
Next, we need something to boot. To keep things simple, we take the Debian netinstaller. This is a set of installer files meant for network installs. We'll simply put these in /srv/tftp where the tftp daemon will serve them to the clients when the try to boot of the network
You can find these files at http://www.debian.org/; look for downloads. Simply unpack the netboot.tar.gz file at the desired location
cd /tmp wget http://http.us.debian.org/debian/dists/etch/main/installer-i386/current/images/netboot/netboot.tar.gz cd /srv/tftp/ gunzip /tmp/netboot.tar.gz tar -xf /tmp/netboot.tar # see what we've got netbootsrv:/srv/tftp# ls debian-installer pxelinux.0 pxelinux.cfg
Note the pxelinux.0 file. This is a boot loader. The file pxelinux.cfg/default contains boot parameters for the boot loader. It will inform the boot-loader about what kernel to load, with which parameters, and where to find it. pxelinux is a part of the syslinux framework, a universal linux boot loader.
While we're at it, check that these files are world-readable
When you power on the PC, you'll notice it detects the dhcp server, configures its network interface, proceeds to load the installer, and runs it. We can conclude that we have now network infrastructure that supports network booting, and that we are capable of booting and running an installer off the network server.
/var/log/syslog shows that after the dhcp, atftpd kicks in to server the boot-loader
Dec 30 15:58:23 netbootsrv dnsmasq: DHCPREQUEST(eth2) 192.168.126.150 00:0c:29:ab:30:4e Dec 30 15:58:23 netbootsrv dnsmasq: DHCPACK(eth2) 192.168.126.150 00:0c:29:ab:30:4e Dec 30 15:58:23 netbootsrv atftpd: Serving /srv/tftp/pxelinux.0 to 192.168.126.150:2070 Dec 30 15:58:23 netbootsrv atftpd: Serving /srv/tftp/pxelinux.0 to 192.168.126.150:2071This configuration can now be extended to create a network installation system (automatic installations with preseeding ). By replacing the installer by an operating system kernel we can also create workstations that boot their OS off a server.