How to setup a PXE boot Server?

Setting up a ‘PXE Network Boot Server’

PXE itself stands for “Pre-boot execution Environment“.

In order to use PXE you need to setup a boot-server which will allow client systems to:

  • Request an IP address (via DHCP)
  • Download a kernel (via TFTP)

With both of these services in place any system which supports PXE/network-booting (you might need to enable it in the BIOS) should be able to gain an IP address, fetch a kernel, and boot without an installed operating system. And it allows installing an operating system directly form a network interface, eliminating the need to burn a CD/DVD or use a physical medium.

Step 1:- Next you’ll need to install the following packages


#yum install tftp-server dhcp httpd syslinux –y

Step 2:- Now you need to setup the DHCP server. all you need to do is create /etc/dhcpd.conf with the following contents:

 subnet netmask {
 default-lease-time 3600;
 max-lease-time 4800;
 option routers;
 option domain-name-servers;
 option subnet-mask;
 option domain-name "";
 option time-offset -8;
 host host0 {
 hardware ethernet 04:4B:82:82:82:02;
 option host-name "host0";
 filename "pxelinux.0";

Then restart dhcp service.


Step 3:- Next you need to activate tftp within xinetd. All that is necessary is to change disable=yes to disable=no in /etc/xinetd.d/tftp . Then restart xinetd. The tftp RPM stores its servable content under /tftpboot.

For some distributor’s tftboot may be in different location like “/var/lib/tftpboot

Next, you need the actual pxe boot linux kernel (what is actually run immediately after your PXE boot client box gets a DHCP lease). In this case, that file is pxelinux.0, and is part of the syslinux RPM. You can find it at /usr/lib/syslinux/pxelinux.0. Copy that file into /tftpboot and make sure that it is world readable.


Step 4:- PXE Configuration: Now that we’ve configured the TFTP and DHCP servers we need to go back and complete the configuration. By default when a client boots up it will use its own MAC address to specify which configuration file to read – however after trying several options it will fall back to requesting a default file.

We need to create that that file, which will contain the list of kernels which are available to boot, we’ll firstly need to create a directory to hold it:

#mkdir –p /tftpboot/pxelinux.cfg

Now create the default pxelinux configuration inside the new file /tftpboot/pxelinux.cfg/default:

 DISPLAY boot.txt 
 prompt 1
 default cent65
 timeout 100
 label cent65
 kernel cent-vmlinuz
 append initrd=cent-initrd.img ramdisk_size=9216 noapic acpi=off inst.ks=

 label ubuntu_i386
 kernel ubuntu-linux
 append vga=normal initrd=ubuntu-initrd.gz

This file instructs the client to display the contents of the file boot.txt so create that too:

- Boot Menu -

Sample ks.cfg :

Step 5:- The only remaining job is to download the official kernel and associated initrd files and save them in the directories specified in the default file we created:

From the CD/DVD or from iso file we need to copy the vmlinuz and initrd files for each distribution as above in default file to the location “/tftpboot”

When these commands have been completed we’ll have the following structure:

root@itchy:~# tree /tftpboot/
|-- boot.txt
|-- cent-vmlinuz
|-- cent-initrd.img
|-- ubuntu-linux
|-- ubuntu-initrd.gz
|-- pxelinux.0
 `-- pxelinux.cfg    
    `-- default

Sample Run

A sample remote boot looks like this:

PXE entry point found (we hope) at 9AE6:00D5
My IP address seems to be C0A801BF
FTFTP prefix:
Trying to load: pxelinux.cfg/04:4B:82:82:82:02
Trying to load: pxelinux.cfg/C0A801BF
Trying to load: pxelinux.cfg/C0A801B
Trying to load: pxelinux.cfg/C0A801
Trying to load: pxelinux.cfg/C0A80
Trying to load: pxelinux.cfg/C0A8
Trying to load: pxelinux.cfg/C0A
Trying to load: pxelinux.cfg/C0
Trying to load: pxelinux.cfg/C
Trying to load: pxelinux.cfg/default
- Boot Menu -