Adding more entries to our PXE boot menu

In my previous post, I covered the process of rebuilding our PXE boot server with AlmaLinux, and adding AlmaLinux as a bootable option within the PXE boot menu.
In this post, I’m going to cover the process of creating a sub-menu, and adding some bootable tools to our sub-menu.
This process will be much the same as I covered in this previous post, however this post will be a little more informative as to why we’re doing what we’re doing.

We’re going to download the following tools:
Rescuezilla
Clonezilla
Gparted
Ntpasswd (I used version 110511, more on this below)

Downloading and unzipping files

Before we get started, we need to install the unzip package if it’s not already installed:

[root@COLO-PXE ~]# yum install -y unzip

We’re now going to download the files for each bootable tool. Note that our current working directory is ~ or/root.

[root@COLO-PXE ~]# wget https://github.com/rescuezilla/rescuezilla/releases/download/2.3.1/rescuezilla-2.3.1-64bit.impish.iso
[root@COLO-PXE ~]# wget https://altushost-swe.dl.sourceforge.net/project/clonezilla/clonezilla_live_stable/2.8.1-12/clonezilla-live-2.8.1-12-amd64.zip
[root@COLO-PXE ~]# wget https://altushost-swe.dl.sourceforge.net/project/gparted/gparted-live-stable/1.3.1-1/gparted-live-1.3.1-1-amd64.zip
[root@COLO-PXE ~]# wget http://pogostick.net/~pnh/ntpasswd/usb110511.zip

Now that we’ve got our files downloaded we can extract them into their own folders, so we can start moving files to the correct locations:

[root@COLO-PXE ~]# unzip clonezilla-live-2.8.1-12-amd64.zip -d clonezilla
[root@COLO-PXE ~]# unzip gparted-live-1.3.1-1-amd64.zip -d gparted
[root@COLO-PXE ~]# unzip usb110511.zip -d ntpasswd

You’ll have noticed that Rescuezilla has downloaded as an .iso rather than a .zip. We’re going to need to mount this ISO image, and then copy the contents out and to a new folder – we’ll handle this shortly.

Moving downloaded files

We now want to begin the process of moving our files to the correct locations. In the last post, we used /srv/networkboot as our PXE directory, and /var/lib/tftpboot for our bootloaders directory. We’re going to create a folder for each tool, in each location above:

[root@COLO-PXE ~]# mkdir /srv/networkboot/{rescuezilla,clonezilla,gparted}
[root@COLO-PXE ~]# mkdir /var/lib/tftpboot/{rescuezilla,clonezilla,gparted,ntpasswd}

Next, we’re going to do the following:
For Clonezilla and Gparted, find their initrd.img and vmlinuz files within the live directory, and copy them to their respective directories within /var/lib/tftpboot
Find their filesystem.squashfs file, and copy it to their respective directories within /srv/networkboot:

[root@COLO-PXE ~]# cp clonezilla/live/{initrd.img,vmlinuz} /var/lib/tftpboot/clonezilla/
[root@COLO-PXE ~]# cp clonezilla/live/filesystem.squashfs /srv/networkboot/clonezilla/
[root@COLO-PXE ~]# cp gparted/live/{initrd.img,vmlinuz} /var/lib/tftpboot/gparted
[root@COLO-PXE ~]# cp gparted/live/filesystem.squashfs /srv/networkboot/gparted/

For Ntpasswd, we can do the following:
Find the initrd.cgz,scsi.cgz and vmlinuz files, and copy them to the respective directory within /var/lib/tftpboot:
You’ll note that at the beginning I said I used version 110511 rather than the most recent version, 140201. This was simply because every other time I booted this, it would kernel panic on me and I couldn’t work out why, even with my previously confirmed working menu entries from previous post – not entirely sure why this is happening.

[root@COLO-PXE ~]# cp ntpasswd/{initrd.cgz,scsi.cgz,vmlinuz} /var/lib/tftpboot/ntpasswd/

You’ll have noticed we haven’t done anything with Rescuezilla yet – as the file downloaded in an .iso format, we need to work with this differently.
To begin, we’re going to move the .iso file to the folder we created earlier – /srv/networkboot/rescuezilla:

[root@COLO-PXE ~]# cp rescuezilla-2.3.1-64bit.impish.iso /srv/networkboot/rescuezilla/rescuezilla-2.3.1-64bit.impish.iso
[root@COLO-PXE ~]# ls -l /srv/networkboot/rescuezilla/
-rw-r--r-- 1 root root 1068525568 Jan 23 20:14 rescuezilla-2.3.1-64bit.impish.iso

Next, we’re going to mount the .iso and copy the vmlinuz and initrd.lz files to the /var/lib/tftpboot/rescuezilla folder:

[root@COLO-PXE ~]# mkdir /media/iso
[root@COLO-PXE ~]# mount -t iso9660 -o loop /srv/networkboot/rescuezilla/rescuezilla-2.3.1-64bit.impish.iso /media/iso
[root@COLO-PXE ~]# cp /media/iso/casper/{vmlinuz,initrd.lz} /var/lib/tftpboot/rescuezilla/

At this point, we have everything in place to start putting out sub-menu together, so let’s continue.

Build PXE menu

As mentioned above, we have everything in place to put our sub-menu in place. To get started, we need to create our new menu file within the /var/lib/tftpboot/pxelinux.cfg/ directory:

[root@COLO-PXE ~]# touch /var/lib/tftpboot/pxelinux.cfg/tools

We also need to edit our original default file, to include a section that points to our new menu. For ease, I’ve added this at the top of the file so it’s the first option. As it stands, this is our full default file so far:

default menu.c32
prompt 0
timeout 300
ONTIMEOUT localboot
MENU AUTOBOOT Booting from local drive in # seconds

menu title ########## PXE Boot Menu ##########

LABEL Tools
MENU LABEL Tools
KERNEL menu.c32
APPEND pxelinux.cfg/tools

LABEL Boot AlmaLinux 8.5 x64 with Network Repo
MENU LABEL Boot AlmaLinux 8.5 x64 with Network Repo
KERNEL almalinux/8.5/vmlinuz
APPEND initrd=almalinux/8.5/initrd.img method=ftp://10.179.1.10/almalinux/8.5 devfs=nomount

LABEL localboot
MENU LABEL Boot from local drive
LOCALBOOT 1
COM32 chain.c32
APPEND hd0 0

As mentioned at the start of this post, this post will be following much of the same steps as my previous post on this topic, and as such, I’m copying the same tools menu from that post to reuse here, however I’ve modified this to include the necessary lines to enable Rescuezilla to boot via PXE (source HERE), and also modified a could of options (fetch squashfs via HTTP rather than FTP, for example):

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 NT Password and Registry Editor
kernel ntpasswd/vmlinuz
append rw vga=1 initrd=ntpasswd/initrd.cgz,ntpasswd/scsi.cgz

label gparted
MENU LABEL GParted Live
kernel gparted/vmlinuz
append initrd=gparted/initrd.img boot=live config components union=overlay username=user noswap noeject locales=en_US keyboard-layouts=en_US.UTF-8 fetch=ftp://10.179.1.10/gparted/filesystem.squashfs

label clonezilla
MENU LABEL 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.179.1.10/clonezilla/filesystem.squashfs

LABEL rescuezilla
MENU LABEL Rescuezilla Live
KERNEL rescuezilla/vmlinuz boot=casper quiet splash fastboot toram
INITRD rescuezilla/initrd.lz
APPEND root=/dev/ram0 ramdisk_size=15000000 ip=dhcp url=http://10.179.1.10/networkboot/rescuezilla/rescuezilla-2.3.1-64bit.impish.iso

So what’s actually going on here?

At the top of the file, we have a menu option to go back to the previous menu.
Underneath, we have menu options for each bootable tool. The append line includes arguments to set options such as OS language, keyboard layout, and where to actually download the remainder of the files from. Each tools append options came from the following sources: ntpasswd, gparted, clonezilla, rescuezilla.
The biggest difference between all of these is Rescuezilla. We’re basically creating a ramdisk, dumping the ISO into it, and then booting it.

Testing our boot options

There’s been a lot of text in this post, so let’s test out booting to our different boot options!

Ntpasswd
Gparted
Clonezilla
Rescuezilla

his concludes this post.
In another post, I’m going to cover customizing the boot menu some more, and changing settings such as the background image and colours. Stay tuned!

Danny Written by: