PXE diagram

Easy Appliances – Part 1 – PXE Server

PXE Server can be a great thing for lots of purposes.

The main usages:

  1. Remote OS installation
  2. Boot diskless machine (ESXi can do it with autodeploy and stateless ESXi)


Before we begin, it might be better to be familiar with PXE buzzwords/terms and architecture.

Bootp – an old protocol to get an IP. it was used in the past to boot from the network. surpressed by DHCP. seems like it also implemented some PXE/TFTP features.

DHCP – service which

Tftp – simple ftp service without need of any authentication. this is the first service the PXE gets the first boot file. it works on port 69 udp.

xinetd – a deamon which implement tftp service.

pxelinux.0 – this is a basic boot file. the first file we are going to load from the TFTP service. it’s a bootstrap.

vsftpd – ftp service for linux. we use it to download installation files after pxelinux starts installation.

httpd – apache http service for linux. can be used instead of vsftp

How does it really works?


  1. Your NIC must support PXE boot (firmware with PXE client code). PXE boot option must be enabled in BIOS.
  2. PXE Does not support wireless!
  3. By PXE client code it asked from DHCP an IP address.
  4. then it gets an IP back with another property – “filename” which is what the client needs to ask from TFTP.
    1. another optional parameter from DHCP server is “next-server” which is needed if the PXE service is not installed in the same server as the DHCP.
  5. Boot loader (the filename) is pooled from the network into the RAM.
  6. From here the image itself take control, just like you mounting a disc or usb key  and boot from it. It can do anything.

pxelinux.0 publish boot menu. after you choose an option it will call other files from TFTP – vmlinuz & initrd or memtest.

pxelinux.0 also configured to take installation from specific URL (the “method” parameter) and to take kickstart file (the “ks” parameter).


PXE Service.

/var/lib/tftpboot/ – folder to keep all images.

Common utilities for PXE


 How to install PXE server?

Basic PXE server on CentOS

  1. Install scratch CentOS (latest CentOS 6 recommended – update with “yum update”).
  2. Configure 2xNICs – one public (with internet access) and one internal (to serve as a PXE with  DCHP).
    1. configure /etc/sysconfig/network-scripts/ifcfg-eth0 to get an IP from DHCP (your network DHCP).
    2. configure anew nic – eth1. install “yum install system-config-network-tui”.
      1. run system-config-network-tui
      2. select <New device> and press enter
      3. Device type: Ethernet
      4. Name: eth1
      5. Device:eth1
      6. Static IP:
      7. Netmask:
      8. Press OK
      9. Choose Save
      10. Choose Save&Quit
      11. now type “ifup eth1”
      12. validate with running “ifconfig”
    3. mount an CentOS installation to the machine  (by copying first an ISO to the machine or connect ISO to virtual machine. mountpoint: /media/cdrom (first create folder: “mkdir -p /media/cdrom”)
    4. create new folder for installation files “mkdir /instfiles”.
    5. create new folder for distributions: “mkdir -p /instfiles/distro”.
    6. create new folder for your linux installation distribution: “mkdir -p /instfiles/distro/centos”
    7. create new folder for your linux installation arch: “mkdir -p /instfiles/distro/centos/x86_64”
    8. create new folder for your linux installation version: “mkdir -p /instfiles/distro/centos/x86_64/6.5”
    9. copy or mount this installation to the final folder (“cp -R /media/cdrom /instfiles/distro/centos/x86_64/6.5” or “mount /dev/cdrom /instfiles/distro/centos/x86_64/6.5”
  3. Disable firewall and SELinux for simplicity:
    1. chkconfig iptables off
    2. service iptables stop
    3. sed -i “/^SELINUX=/c\dSELINUX=disabled” /etc/selinux/config
DHCP Service

#Install DCHP server for PXE ROM to get an IP
yum install dhcp -y

TFTP Service + boot loader example.

#For PXE ROM to pull the first image file.

yum install tftp-server  -y

#allowing tftp server (can be a little bit more formatted by sed – the first tab at the line is not working…)
sed -i “/disable = /c\disable\t\t = no” /etc/xinetd.d/tftp


#Now boot again the client and check if it gets the menu.

#Congratulations! you’ve managed to boot from PXE!
#Now it’s time to make your PXE boot installing the operating system to your client. for that we need ftp or http service to download installation files. we need service to  download from and kickstart file to tell  the installation from where to take the installation files.

Method 1: FTP Service for getting the installation

echo “local_root=/tftpboot/images/centos/x86_64/6.5” >> /etc/vsftpd/vsftpd.conf

#updating pxelinux to take the installation from this ftp service.

sed -i “/append/c\append initrd=initrd.img method= ks=” /var/lib/tftpboot/

service vsftpd start

ftp client

yum install ftp -y

Method 2: HTTP service to get installation files (Prefered)

yum install httpd -y

#configure apache httpd to point our images directory: (cobbler works with httpd and not with vsftpd).

touch /etc/httpd/conf.d/instfiles.conf

echo ‘AliasMatch ^/instfiles(.*)?$ “/instfiles$1” ‘ >> /etc/httpd/conf.d/instfiles.conf
echo “” >> /etc/httpd/conf.d/instfiles.conf
echo ‘<Directory “/instfiles”>’ >> /etc/httpd/conf.d/instfiles.conf
echo -e “\tOptions Indexes FollowSymLinks” >> /etc/httpd/conf.d/instfiles.conf
echo -e “\tOrder allow,deny” >> /etc/httpd/conf.d/instfiles.conf
echo -e “\tAllow from all” >> /etc/httpd/conf.d/instfiles.conf
echo -e “</Directory>” >> /etc/httpd/conf.d/instfiles.conf

chkconfig httpd –level 3 on

service httpd start

sed -i “/append/c\append initrd=initrd.img method= ks=” /var/lib/tftpboot/pxelinux.cfg/default

#Now check if you can surf to the server:
#Congratulations! now you can direct download files from your http service.

Last configuration to make it work
Making  anaconda kickstart configuration file

under  /instfiles create a new folder – kickstart.

mkdir -p /instfiles/kickstart

the file you need to put in it will be called anaconda-ks.cfg .

download example file:

cd /instfiles/kickstart

#install wget
yum install wget -y

wget http://www.cs.ndsu.nodak.edu/~hennebry/anaconda-ks.cfg

#Update boot menu to also take kickstart file to the installation

#add to append line at the end: ks=” check how to do it with sed.

Testing the whole process


You’ve managed to install PXE server to install operating system automatically. you need only choose your option from the menu (this one can be non-interactive but we’ll do it in the next part).

This is the basics, and also the basics for Cobbler, which make automation for configuring PXE.

How to install  and configure cobbler? in the next part!

Just to remember, the important files and folders are:

  1. /etc/sysconfig/dhcpd – main configuration for dhcp service, which ethernet interfaces to listen to.
  2. /etc/dhcp/dhcpd.conf – your dhcp service configuration and scopes.
  3. /etc/xinetd.d/tftp – your tftp service configuration, from where to pull files and to enable it.
  4. /var/lib/tftpboot – main tftp files, from which the client can pull  files. this is the root directory (“/”) seen for tftp clients.
  5. /var/lib/tftpboot/pxelinux.0 – first bootstrap loading by our client.
  6. /var/lib/tftpboot/pxelinux.cfg/default – pxelinux configuration file. what to do and menu configurations.
  7. /var/lib/tftpboot/images – distributions boot files, include vmlinuz and initrd.img which loads the installation program.
  8. /etc/httpd/conf.d – directory with http virtual directories configuration. it means that if you want to link http url to your local directory, you do it by configuring x.conf inside this directory, as x is your destination directory.



by the way, in order to take the installation files (the method parameter), you need to put a line in the kickstart file (right after “install” line:

url –url


Basic PXE server on Ubuntu


Packages we’re going to install

tftpd-hpa –

inetutils-inetd –


First, install Ubuntu server (LTS version recommended, I used 12.04.4 but I guess 14.04 can be also great).
The specs can be 1vCPU, 256MB memory and 8GB storage.
Just install the default installation.
Don’t forget to update all packages (sudo apt-get update && sudo apt-get upgrade).




  1. https://www.youtube.com/watch?v=zpzPuK6LNQ4 – Basic understanding.
  2. http://pxe.dev.aboveaverageurl.com/index.php/PXE_Booting – a bit more about the process.
  3. https://www.youtube.com/watch?v=B-QpCYKrVew – cobbler installation

How to install:


Leave a Reply

Your email address will not be published. Required fields are marked *