Tag Archives: Tftpd-hpa

Ubuntu Server PXE Install

I was working on a set of Ubuntu servers for a cluster in my network lab and wanted to look into alternative boot methods to streamline the process.  I followed a lot of tutorials which recommended setting up a new DHCP server that could assign the machines leases and then direct the machines to the correct boot file.  After some failed attempts with running a temporary DHCP and TFTP server on a Windows machine I sifted through my DHCP server settings for pfSense and found that it actually had support for network boot built in.  This was great and allowed me to skip the whole DHCP server step and just change the following in the Services > DHCP Server tab in pfSense:

Of course for this to work I had to have pfSense’s DHCP server enabled.  Having this setup will now allow the bootable machines to be assigned a DHCP lease then look for the TFTP server at the address specified (192.168.2.200 in my situation) and to look for pxelinux.0 to boot from.  The next portion of this setup is a slightly modified version of the article found here https://help.ubuntu.com/community/PXEInstallServer , modified in the sense that I left out any DHCP server steps due to the fact that I’m handling the direction through pfSense.

Setting up your PXE server on Ubuntu:

sudo apt-get install inetutils-inetd tftpd-hpa

sudo nano /etc/default/tftpd-hpa

Make sure this file looks like this:

#Defaults for tftpd-hpa
RUN_DAEMON="yes"
OPTIONS="-l -s /var/lib/tftpboot"

Save the file if you need to make any changes and restart the daemon:

sudo /etc/init.d/tftpd-hpa restart

sudo nano /etc/inetd.conf

Edit the file so it looks similar to the following (note that you may need to change “udp” to “udp4” to override the default and use IPv4:

tftp    dgram   udp    wait    root    /usr/sbin/in.tftpd /usr/sbin/in.tftpd -s /var/lib/tftpboot

Once completed editing this file we need to copy the boot files from the Ubuntu ISO or CD.  In my case I inserted the Ubuntu Server CD into the machine’s drive and then completed the following:

sudo cp -r /media/cdrom/install/netboot/* /var/lib/tftpboot/

You can copy these files from wherever you’d like just as long as they end up in /var/lib/tftpboot/

At this point you should have everything in working order on the server side.  If your NIC has a boot menu for network boot (as some of my Intel NICs do) you can go ahead and try booting to the network.  If successful, it should retrieve the file from the server and then proceed to the Ubuntu Server installation screen.  If you want to customize your boot from this point (for example, retrieving the files from a local CD instead of over the Ubuntu mirrors via HTTP) see the Ubuntu guide listed earlier.

Client Machine Setup Using gpxe:

I found that I had better results using gpxe on the client machines.  I setup a boot floppy that included all of the NIC drivers by going to this website http://rom-o-matic.net/gpxe/gpxe-git/gpxe.git/contrib/rom-o-matic/ and choosing “all-drivers” and selecting a .dsk as the output format.  There are many different options you can chose as well if you would rather use USB or CD for example.  I created a floppy from this image using the following command:

dd if=IMAGE.dsk of=/dev/fd0

The example above assumes IMAGE.dsk is in the directory you issue this command from and also that your floppy drive is located at /dev/fd0.

This boot disk is quite useful if you are running into any issues.  It has a menu with a few setup and diagnostic commands.  You can manually set the server of which to direct once booted to this disk (if things don’t work for you automatically), change the target boot file, etc.

Troubleshooting:

Hopefully this gets those interested in PXE boot going successfully.  If you are having any problems, here are a few things to check:

  • Check your DHCP server settings.  Ensure that the IP address and filename is correct.
  • Check all of the configuration files edited earlier in this guide.  Any typos in the directory path will prevent things from working properly.
  • Check that your PXE server is listening by issuing the following command:
    netstat -a | grep tftp
  • Check that your NIC supports PXE boot
  • Check that you have properly enabled network boot in BIOS

If I’ve missed anything feel free to contact me and I’ll add any additional steps for setup or troubleshooting to the list.