All in one PXE server

During a cool project where I was using FOG (free open-source ghost) I realized that having a PXE boot server can pose numerous advantages. I wanted a PXE boot server that included FOG and it’s capabilities along with a multitude of operating systems and utilities that can be installed / ran over the network. This can replace the need of having a X number of CDs/DVDs/USB sticks around and the best of it all, multiple PCs can be booted with the same live OS or utility at the same time.

Similar projects that resemble what I’m trying to do are Ultimate Boot CD and PXEknife (apparently discontinued and dead).

Prerequisites

  • PXE booting base knowledge (check references for relevant links)
  • installed and working FOG server (or a PXE server if FOG isn’t that necessary)

As mentioned in the beginning of the post I wanted to be able to :

  • run FOG
  • install OSs (Linux distros and Windows) over the network
  • boot live OSs (mostly for Ubuntu, Ubuntu variants and Kali) over the network
  • run utilities over the network
  • add entries to the system in an easy way

It all comes down to the /tftpboot directory, where the boot menu is defined, along with all its graphic elements (background image, colors) and where the OS and utility files are being placed.

Directory structure

tftpboot-structure

Description:

  • install – the folder where OS and utility files are to be placed, each under the directory meant for it (e.g. linux distros in a version folder, located in a distro folder, located in the linux folder – install/linux/ubuntu/14.04)
  • tes – the folder containing menu configuration files (*.cfg) and background pictures for the menu
  • pxelinux.cfg – the folder containing “default” file to which TFTP is directed when PXE booting, which includes the “master.cfg” file, the main menu configuration file, where the menu structure and the background picture is being defined
  • root-files – these files can be found directly under /tfptboot, and are used in the booting sequence

The boot menu structure follows the directory structure from above – to be more specific, the “install” folder and its subfolders.

pxe-menu

pxe-menu-linux

Yup, its the CIA logo on the background – a quick google image search can give the most unexpected boot splash images.

An archive with the /tftpboot folder can be found on the Resources page.

Apart from the files and the directory structure mentioned above, it includes a Debian Wheezy netinstaller and memtest.

How add a new linux distro 

This example will cover the most simple scenario, that of downloading the net installer files from the distro source – in this case Ubuntu 14.04.

Download and extract the files in the desired location. The following assumes that you have created the path according to the directory structure.

cd /tfptboot/install/linux/ubuntu/14.04

wget archive.ubuntu.com/ubuntu/dists/trusty/main/installer-amd64/current/images/netboot/netboot.tar.gz

tar xvfz netboot.tar.gz

We ended up with the following

files-after-extraction

Adding PXE menu entries

Now having the files in place,  we have to add another menu element so that we can choose it when we PXE boot. When having the .cfg files already available (like in this case) I prefer to include them in the master menu, by adding a new menu entry that leads to the .cfg files available. To do this, I’m modifying the menu cfg file reserved for the linux sub menu

nano /tftpboot/tes/menus/linux.cfg

And adding an entry like the one below:

# Ubuntu 14.04 netinstall
MENU BEGIN Ubuntu 14.04
MENU TITLE Ubuntu 14.04
include install/linux/ubuntu/14.04/ubuntu-installer/amd64/boot-screens/menu.cfg
default install/linux/ubuntu/14.04/ubuntu-installer/amd64/boot-screens/vesamenu.c32
MENU END

The problem now is that the available .cfg files for the Ubuntu netinstaller that we’ve just downloaded does not include path information related to our structure.  The menu.cfg file which is referenced above looks like this :

menu title Installer boot menu
include ubuntu-installer/amd64/boot-screens/stdmenu.cfg
include ubuntu-installer/amd64/boot-screens/txt.cfg
include ubuntu-installer/amd64/boot-screens/gtk.cfg
menu begin advanced
menu title Advanced options
include ubuntu-installer/amd64/boot-screens/stdmenu.cfg
label mainmenu
menu label ^Back..
menu exit
include ubuntu-installer/amd64/boot-screens/adtxt.cfg
include ubuntu-installer/amd64/boot-screens/adgtk.cfg
menu end
label help
menu label ^Help
text help
Display help screens; type ‘menu’ at boot prompt to return to this menu
endtext
config ubuntu-installer/amd64/boot-screens/prompt.cfg

Notice the path ubuntu-installer/amd64/boot-screens/ . This must be prepended with the full path required for TFTP to understand where to get its files from. ubuntu-installer/amd64/boot-screens/ would turn into install/linux/ubuntu/14.04/ubuntu-installer/amd64/boot-screens/

It would go really slow to modify each of the paths manually for each files and that’s why I used the below sed line, which replaces the initial path with the full one.

sed -i ‘s|ubuntu-installer|install/linux/ubuntu/14.04/ubuntu-installer|g’ *.cfg

Now boot up your machine with the PXE server and check out the new entry under linux :

pxe-menu-ubuntu-app

pxe-menu-ubuntu-install

References

  • http://docs.oracle.com/cd/E24628_01/em.121/e27046/appdx_pxeboot.htm#EMLCM12198
  • http://www.pix.net/software/pxeboot/archive/pxespec.pdf
  • http://fogproject.org/wiki/index.php/Main_Page
  • http://www.howtogeek.com/57601/what-is-network-booting-pxe-and-how-can-you-use-it/