Linux PXE Server
In my home lab I found myself burning DVD's every time I wanted to test a new Linux OS or check out an ISO based tool. I knew there had to be a better, more efficient way to do my testing. My experience led me to The Preboot Execution Environment (PXE). PXE is an industry standard that allows a networked computer to load an operating system remotely. So I grabbed a Raspberry Pi, loaded it with the latest Rasbian image and built a PXE server…
Basic PXE Setup
First thing, update package lists. Then install a TFTP server, DHCP Server, NFS support, and the PXE booting files .(Since my router is providing DHCP I am using a proxy dhcp. dnsmasq comes with many tools, two of which are tftp and proxy dhcp.)
sudo apt-get update sudo apt-get install dnsmasq nfs-kernel-server syslinux-common
Lets make the root directory for our tftp server. I'll put mine at / for this example
The next step is to copy all the PXE boot files to the / of the tftp server(/tftpboot) and create the necessary files and directories .
cp -r /usr/lib/syslinux/* /tftpboot/ mkdir /tftpboot/pxelinux.cfg sudo nano /tftpboot/pxelinux.cfg/default
DEFAULT menu.c32 PROMPT 0 MENU TITLE PXE Boot LABEL Test MENU LABEL Test
Now, edit the dnsmasq settings. by adding the lines below to the end of the dnsmasq.conf file(this will enable the tftpserver and proxy DHCP required to assign PXE clients IP address). After editing the dnsmasq.cof file restart dnsmasq.
sudo nano /etc/dnsmasq.conf
Add/Edit the following info to the dnsmasq.conf
interface=eth0 dhcp-range=192.168.0.0,proxy dhcp-boot=pxelinux.0 pxe-service=x86PC,"Booting from Network...",pxelinux enable-tftp tftp-root=/tftpboot dhcp-boot=pxelinux.0,servername,192.168.0.50
sudo service dnsmasq restart
Now is a good time to test our configuration. From a remote computer, attempt to PXE boot. You should successfully receive an IP address and go to a boot menu.
Configure NFS Boot
Next we will set up th NFS support. Here we will create a few directories for organization and mounting purposes.
mkdir /tftpboot/iso ##Store distribution iso's here mkdir /tftpboot/nfs ##Directory where we will create distribution mount folders. mkdir /tftpboot/nfs/ubuntu ##Folder where we will mount the ubuntu iso
Edit the /etc/exports file
sudo nano /etc/exports
Add following line:
Mount the ISO
mount -o loop iso/ubuntu-13.04.iso nfs/ubuntu/
NOTE: In the future, if you add any additional entries to the /etc/exports file, nfs-kernel-server must be restarted.
Now enable rpcbind and restart nfs.
update-rc.d rpcbind enable && update-rc.d nfs-common enable service rpcbind start service nfs-kernel-server restart
Edit the default config file
sudo nano /tftpboot/pxelinux.cfg/default
Add the following:
DEFAULT menu.c32 PROMPT 0 MENU TITLE PXE Boot LABEL Test MENU LABEL Test LABEL Ubuntu MENU LABEL ^Ubuntu 13.04 KERNEL nfs/ubuntu/casper/vmlinuz APPEND initrd=nfs/ubuntu/casper/initrd.lz boot=casper netboot=nfs nfsroot=192.168.0.50:/tftpboot/nfs/ubuntu
Note: For some distributions I had to add the following to the end of the APPEND line:
ip=HostIP:ServerIP:RouterIP:Subnet:::none rw Example: ip=192.168.0.10:192.168.0.50:192.168.0.1:255.255.255.0:::none rw
Install Windows over PXE
In this tutorial I only covered how to PXE Ubuntu. If you are interested in installing Windows using this PXE Server, head over to my Install Windows over PXE Tutorial
Diskless Booting #2
If you have made it this far, congrats you are well on your way to diskless booting. This tutorial only convered booting to livecd's and installation media. If you are interested in diskless booting, then you may want to check out my iSCSI PXE boot tutorial.