PXE Magic: Flexible Network Booting with Menus

Set up a PXE server and then add menus to boot kickstart images, rescue disks and diagnostic tools all from the network.

Extra Features: PXE Rescue Disk

One of my favorite features of a PXE server is the addition of a Knoppix
rescue disk. Now, whenever I need to recover a machine, I don't need to hunt
around for a disk, I can just boot the server off the network.

First, get a Knoppix disk. I use a Knoppix 5.1.1 CD for this example,
but I've been successful with much older Knoppix CDs. Mount the CD-ROM, and
then go to the boot/isolinux directory on the CD. Copy the miniroot.gz and
vmlinuz files to your /var/lib/tftpboot directory, except rename them
something distinct, such as miniroot-knx5.1.1.gz and vmlinuz-knx5.1.1,
respectively. Now, edit your pxelinux.cfg/default file, and add lines like
the one I used above in my example:

Notice here that I labeled it 1, so if you already have a label with that
name, you need to decide which of the two to rename. Also notice that
this example references the renamed vmlinuz-knx5.1.1 and
miniroot-knx5.1.1.gz files. If you named your files something else, be
sure to change the names here as well. Because I am mostly dealing with
servers, I added 2 after init=/etc/init on the append line, so it would boot
into runlevel 2 (console-only mode). If you want to boot to a full
graphical environment, remove 2 from the append line.

The final step might be the largest for you if you don't have an NFS server
set up. For Knoppix to boot over the network, you have to have its CD
contents shared on an NFS server. NFS server configuration is beyond the
scope of this article, but in my example, I set up an NFS share on 10.0.0.1
at /mnt/knoppix/5.1.1. I then mounted my Knoppix CD and copied the full
contents to that directory. Alternatively, you could mount a Knoppix CD
or ISO directly to that directory. When the Knoppix kernel boots, it will
then mount that NFS share and access the rest of the files it needs
directly over the network.

Extra Features: Memtest86+

Another nice addition to a PXE environment is the memtest86+ program. This
program does a thorough scan of a system's RAM and reports any errors.
These days, some distributions even install it by default and make it
available during the boot process because it is so useful. Compared to
Knoppix, it is very simple to add memtest86+ to your PXE server, because it
runs from a single bootable file. First, install your distribution's
memtest86+ package (most make it available), or otherwise download it from
the memtest86+ site. Then, copy the program binary to
/var/lib/tftpboot/memtest. Finally, add a new label to your
pxelinux.cfg/default file:

label 3
kernel memtest

That's it. When you type 3 at the boot prompt, the memtest86+ program
loads over the network and starts the scan.

Conclusion

There are a number of extra features beyond the ones I give here. For instance,
a number of DOS boot floppy images, such as Peter Nordahl's NT Password and
Registry Editor Boot Disk, can be added to a PXE environment. My own use of
the pxelinux menu helps me streamline server kickstarts and makes it
simple to kickstart many servers all at the same time. At boot time, I can
not only indicate which OS to load, but also more specific options, such as
the type of server (Web, database and so forth) to install, what hostname to use, and
other very specific tweaks. Besides the benefit of no longer tracking down
MAC addresses, you also can create a nice colorful user-friendly boot menu
that can be documented, so it's simpler for new administrators to pick up.
Finally, I've been able to customize Knoppix disks so that they do very
specific things at boot, such as perform load tests or even set up a Webcam
server—all from the network.

Kyle Rankin is a Senior Systems Administrator in the San Francisco Bay Area
and the author of a number of books, including Knoppix
Hacks and Ubuntu
Hacks for O'Reilly Media. He is currently the president of the
North Bay
Linux Users' Group.

Kyle Rankin is Chief Security Officer at Purism, a company focused on computers that respect your privacy, security, and freedom. He is the author of
many books including Linux Hardening in Hostile Networks, DevOps Troubleshooting and The Official Ubuntu

Thanks for this article! I decided to try it out just for the fun of it, but along the way I realized I had needed this for a long time. My job involves training UMTS operators' personnel on the use of their GPRS equipment, and I usually go in with a bunch of Knoppix CDs so the trainees can use the IP tools available or installable there -- from Wireshark, to VLANs and IP tunnels, to mobile phone simulators. While network-booting Knoppix isn't always the most practical solution in this situation, it does help in some cases.

However, I'd like to point out a mistake in the article which could frustrate some other readers' efforts:

The miniroot.gz file located on the /boot/isolinux directory of the Knoppix CD cannot be used for this, because it doesn't support NFS mounting (at least on the Knoppix 5.1.1 and 5.3.1 versions I tested).

You have to use the miniroot.gz file off the /tftpboot directory of a Knoppix Terminal Server. To get that, just boot a Knoppix LiveCD normally (no network boot yet) and start the Terminal Server on the Knoppix Services menu. Wait a few seconds after it is started and the miniroot.gz file will appear under that directory (it is only created when you start the Terminal Server). Now you can copy it to a pendrive or over ssh to your "real" terminal server.

Also, you have to do that with the same Knoppix version you plan to PXE-boot later; files from the recently released 5.3.1 version can't boot a 5.1.1 Knoppix, and vice-versa.

I'll still take in the Knoppix CDs, though. I give them to the trainees after the course, and I have tallied lots of "conversions" this way -- people just didn't know such powerful tools were available for the taking, and this is a real eye-opener for them.