This post is the second in a series on building/setting up/improving a PXE boot server with CentOS.
By the end of this post, we’ll have added a handful of useful tools to our PXE menu, including Clonezilla and GParted.
To get things started
First of all, we’re going to need to make sure we have the unzip
package installed, if it’s not installed, simply run yum install -y unzip
and then we can proceed.
We’re going to need to find the correct download links for the tools we’re going to add:
– Ntpasswd – LINK
– GParted – LINK
– CloneZilla – LINK
Downloading and moving files
At the time of writing this post, the below links are the latest to each file. We can quickly download them by running the following commands. Note that our working directory is /root
or ~
.
wget http://pogostick.net/~pnh/ntpasswd/usb140201.zip
wget https://kumisystems.dl.sourceforge.net/project/gparted/gparted-live-stable/1.1.0-5/gparted-live-1.1.0-5-amd64.zip
wget https://osdn.net/dl/clonezilla/clonezilla-live-2.6.6-9-amd64.zip
Once you’ve downloaded the files, extract them into their own folders as shown below:
unzip usb140201.zip -d ntpasswd
unzip gparted-live-1.1.0-5-amd64.zip -d gparted
unzip clonezilla-live-2.6.6-9-amd64.zip -d clonezilla
Next, we’re going to create some directories for the files we just extracted. The best way I’ve found to deal with storing the files it to put them in separate folders as each bootable OS has files with the same names;
mkdir /var/lib/tftpboot/ntpasswd
mkdir /var/lib/tftpboot/gparted
mkdir /var/lib/tftpboot/clonezilla
mkdir /var/ftp/gparted
mkdir /var/ftp/clonezilla
For Clonezilla and Gparted we’ll want to do the following:
Inside the extracted ISO’s folder, find the live
folder. Inside you’ll need to copy the initrd.img
and vmlinuz
files out to their respective directories
For ntpasswd we need to copy the following files: initrd.cgz
,scsi.cgz
and vmlinuz
.
We’re basically copying the boot files into the tftp location so they can be referenced in the PXE boot menu, and copying the filesystem.squashfs
files to a location where they can be pulled via FTP once the OS has started booting.
cp clonezilla/live/{initrd.img,vmlinuz} /var/lib/tftpboot/clonezilla/
cp clonezilla/live/filesystem.squashfs /var/ftp/clonezilla/
cp gparted/live/{initrd.img,vmlinuz} /var/lib/tftpboot/gparted/
cp gparted/live/filesystem.squashfs /var/ftp/gparted/
cp ntpasswd/{initrd.cgz,scsi.cgz,vmlinuz} /var/lib/tftpboot/ntpasswd/
Edit/update PXE boot menu
To make our PXE menu a bit tidier, we’re going to create another menu file and reference that in our original file.
First, we’re going to edit the original menu located at /var/lib/tftpboot/pxelinux.cfg/default
and add the following to the bottom:
LABEL Tools
MENU LABEL Tools
KERNEL menu.c32
APPEND pxelinux.cfg/tools
This allows us to select the Tools sub-menu and enter it
Next, we need to create the tools file and enter the following:
MENU TITLE ########## PXE Tools Menu ##########
LABEL Back to Main Menu
MENU LABEL Main Menu
KERNEL menu.c32
APPEND pxelinux.cfg/default
LABEL ntpasswd
MENU LABEL ^1. NT Password and Registry Editor
kernel ntpasswd/vmlinuz
append rw vga=1 initrd=ntpasswd/initrd.cgz,ntpasswd/scsi.cgz
label GParted Live
MENU LABEL ^2. GParted Live
kernel gparted/vmlinuz
append initrd=gparted/initrd.img boot=live config components union=overlay username=user noswap noeject ip= vga=788 locales=en_US keyboard-layouts=en_US.UTF-8 fetch=ftp://10.176.40.10/gparted/filesystem.squashfs
label Clonezilla Live
MENU LABEL ^3. Clonezilla Live
KERNEL clonezilla/vmlinuz
APPEND initrd=clonezilla/initrd.img boot=live username=user union=overlay config components quiet noswap edd=on nomodeset nodmraid keyboard-layouts=en locales=en_US.UTF-8 ocs_live_run="ocs-live-general" ocs_live_extra_param="" ocs_live_batch=no net.ifnames=0 nosplash noprompt fetch=ftp://10.176.40.10/clonezilla/filesystem.squashfs
If you want to use this file, you’ll need to replace the IP address (10.176.40.10
) with the IP of your own PXE boot server.
Essentially what’s happening here, is that we’ve got 4 menu items. The top one takes us back to the original default
PXE menu, and the rest are for launching the items.
Each menu item points to the corresponding kernel that we copied earlier, and we’re appending each item with some extra options to help the live OS boot correctly and also set some options like the keyboard layout and OS language. Sources HERE and HERE.
If we now fire up a test machine and PXE boot, we should have the additional tools menu item, and when we select it, we’ll be presented with our new bootable tools.


If I was to now select GParted Live and boot to it, after a few moments we should be presented with the live OS

Similarly, if we boot Clonezilla, after a few moments we’ll land at the Clonezilla welcome screen

Wrapping up
In this post we’ve covered modifying our existing PXE boot menu config and creating a new menu file to include useful tools like GParted and Clonezilla, and we’re now able to boot and use these tools without needing to copy their ISO’s to our ESXi hosts datastore or making a bootable USB drive in the case of a physical machine.
In the next post, I’m going to cover modifying our kickstart file some more to allow random generation of our root password and to automate the setup of services like ssmtp
.