Network Boot

How to set up a PXE boot server

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, especially for diskless clients, 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 into those.

Step 1 : a dhcp server - dnsmasq

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 (and can also do tftp, which makes it a very good choice for a PXE boot server) .

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 parameters 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


or, if everything runs from the same server :


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 planned here, you'll need to get the dhcp server working correctly before you continue. Look in /var/log/syslog to see what's happening

Step 1b: set up a tftp server

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 and newer. The following was tested with dnsmasq on Ubuntu 8.04 with a mini install)

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. They also have to be owned by the account that the tftp server runst with -- usualy: nobody.

	mkdir /srv/tftp
        chown nobody /srv/tftp
sample dnsmasq.conf

Step 2 - something bootable

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; look for downloads. Simply unpack the netboot.tar.gz file at the desired location

	cd /tmp

	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

Lo and behold, a network installer !

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 should now show that after the dhcp, tftp kicks in to server the boot-loader

This configuration can now be extended for

Koen Noens
rewritten October 2010

alternative version of this page : pxe boot with atftp as tftp server