Network booting with Linux – PXE


This article here is somewhat related to our previous one, in that it treats the subject of booting and installing Linux using the network, be it local or not. This time we will treat installing Linux without optical, floppy or other removable media, by just using the LAN. You are expected to have at least two computers in your network, and the client will need a NIC and a BIOS capable of using PXE. We will guide you from beginning to end, but some basic networking and Linux configuration knowledge, plus the use of an editor of your choice are required. You will learn what PXE is, how to configure a DHCP server, how to configure a TFTP server so the client can have access to the files, plus lots of interesting things, as usual.


PXE (pronounced “pixie”) stands for Preboot eXecution Environment and was introduced by Intel and Systemsoft in 1999. In short, it’s a capability most modern network cards and BIOSes have that enables the system to boot from LAN, just like it would boot from hard disk or CD-ROM. The PXE support must be present in the NIC’s firmware which, if set up accordingly in the BIOS, will get an IP address from the PXE server and download the necessary boot images. In order for an IP address to be available, the server must offer DHCP. After an IP address is leased, the TFTP server (which can be the same box as the DHCP server) hands out the necessary files to the client, so it can boot them after loading. That’s the whole idea, so enough talk, let’s get to work, shall we?

Installing the necessary tools and setting up

Before we start, it’s important to understand how the setup of the network we tested this on is laid out. The server is a Debian machine with two network cards, and the distribution we will install is also Debian, namely Squeeze, amd64. You can use any other distribution, but probably some config file locations will differ. This article does not deal with how you will set up the software sources for the actual installation. We will only take you to a working debian-installer and that’s about it. You’ll find lots of tutorials out there about how to set up a local Debian repository or how to configure a gateway on Linux.

So, the checklist : we will need a DHCP server, a TFTP server and the initrd and the kernel image to be transferred to the client. We chose a rather unusual approach in our setup, and you will see why.

Outside world ------> Router ------> Switch ------>(eth0) Server(eth1) ------> Client

So, the router gives out DHCP addresses (small, home router) in the form of 192.168.0.x . The server, which will also be handing out DHCP addresses, has its outside connection via eth0 and the inside connection for the client via eth1. The client has the only Ethernet connection directly to the PXE server, but that doesn’t mean you can’t configure the server as a gateway for netinstall or add another NIC to the client for outside access. There are a lot of possibilities, the important issue at hand is booting via PXE. Let’s start by installing the TFTP server.


TFTP stands for Trivial File Transfer Protocol and it’s the de facto “language” when it comes to transferring files to use with PXE. On Debian, we install it thusly:

 # aptitude install tftpd-hpa

Now we must configure it properly. Before anything, in our example we will run tftpd standalone, meaning we’re not going to use xinetd. The configuration will be different if you plan on using xinetd, and we don’t recommend it. Now all we have to do is edit /etc/default/tftpd-hpa :

#make sure these lines are present
TFTP_OPTIONS="-l -s /var/lib/tftpboot"

Let’s make sure the above directory exists and start the daemon:

 # mkdir -p /var/lib/tftpboot
 # /etc/init.d/tftpboot-hpa start


We have to offer the client an address before we commence installing via network, and this is done by using the Dynamic Host Configuration Protocol. The DHCP server has a pool of addresses from which it offers IPs when requested. One installs the server part with

 # aptitude install dhcp3-server

The configuration file is located at /etc/dhcp/dhcpd.conf (may be /etc/dhcp3 in older versions of Debian) and is a very well-commented file. Before we show you how our file looks like, a little recap may be in order: eth0 – outside world via switched network (192.168.0.x) and eth1 – direct link to the client (192.168.1.x).

ddns-update-style none;
# Remember the semicolons at the end of each line!
default-lease-time 86400;
max-lease-time 604800;

subnet netmask {
        filename "pxelinux.0";
        option subnet-mask;
# There is more to this file than we've shown, but what you have here is enough for PXE.

Now we must set eth1’s networking information, found in /etc/network/interfaces :

allow-hotplug eth1
iface eth1 inet static

Restart the network and we’re almost done:

 # ifdown eth1
 # ifup eth1

Configuring PXE

We must now configure the file that the client will be requesting, a file in which we will tell it how to find what it needs. So, let’s create the pxelinux.cfg directory :

 # mkdir /var/lib/tftpboot/pxelinux.cfg 

and create a file named ‘default’ that will have the following contents:

DISPLAY boot.txt

DEFAULT squeeze_amd64_install

LABEL squeeze_amd64_install
        kernel debian/squeeze/amd64/linux
        append vga=normal initrd=debian/squeeze/amd64/initrd.gz  --


You see a reference to the boot.txt file , so create it in /var/lib/tftpboot and add the line “squeeze_amd64_install” to it.

Now, to copy the necessary files somewhere to be found by the client:

 # cd /var/lib/tftpboot
 # wget\
 # mkdir -p debian/squeeze/amd64/
 # cd debian/squeeze/amd64/
 # wget\
 # wget\

Now, hoping that everything is alright, you can just boot your client and alter its’ BIOS settings for network boot. Before we finish, we owe you an explanation for this network setup we chose. We could have probably made it simpler, like using our ISP’s connection directly, and being able to access the network (Internet) as well. The idea is that the PXE server in our scenario can’t get its’ IP address (eth0) from DHCP as this setup won’t work: if you’re not gonna use the two-NIC scenario on the server, like we did, you need some kind of fixed IP address. So, the possibilities would be: ISP connected directly, set router to give only static IPs, make the PXE/DHCP/TFTP server also a gateway or create a local repository. We chose the latter because it suits our topology and purposes best, and it only involves setting up a webserver on the LAN, really. If we would have explained all your choices, including iptables for a gateway or apache for a HTTP server, this article would have been huge. Instead, we preferred to stick to the title and give you exactly that: Network booting with Linux.

Remember that this is just an example: like with NetbootCD, you can add as many distributions as you want, provided you have the necessary space on the server.

Final thoughts

First of all, we recommend patience. PXE is known to be kinda slow, regardless of your top Gigabit switch you bought last week. Second, read the comments and examples in dhcpd.conf as they will be useful now and later.

Comments and Discussions
Linux Forum