Creating a PXE LiveCD Environment
This quick tutorial will show you everything you need in order to make a PXE live environment. This livecd environment is useful for testing, diagnostics, data recovery, system imaging and more. For details, check out the SystemRescueCD project that this is built on.
The sysresccd is loaded with handy sysadmin tools that you can’t find in a regular installer’s ‘rescue’ mode. I’ve been using it since 2006, and I still consider it to be one of the most useful tools in my sysadmin toolbox. That’s why I like to make it part of my PXE menu.
Now, there are a million guides out there about creating a basic PXE boot server, so won’t be going over that part. I like to focus on the interesting bits that make this different. This guide assumes you’ve already got a TFTP and DHCP server set up to provide the basic PXE functionality.
1. Download SystemRescueCD.
2. Mount the iso to extract the files.
mkdir /mnt/tmp mount -o loop systemrescuecd-x86-3.1.2.iso /mnt/tmp
3. Copy the pxelinux bootloader to your tftpboot dir.
This dir will exist in one place or another if you’ve got a PXE server set up already. You may not actually need this file, since your existing pxe server should have it.
cp /mnt/tmp/isolinux/pxelinux.0 /var/lib/tftpboot/
4. Copy the special sysresccd pxelinux config file.
If you’ve already got a pxe menu that you like, can keep it and just append the parts of this that you want. Or, you can do what I did and create a separate menu for your handy new pxe livecd tools.
In this example, I’m creating a secret ‘admin’ menu. Append this to your existing pxelinux.cfg/default file, or skip this step and use the admin menu as your main menu.
# overwrite your default menu with the new one cp /mnt/tmp/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default # or create a second menu cp /mnt/tmp/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/admin_menu
Creating a second menu (optional). Using this menu, you can type ‘admin’ at your usual pxe prompt to enter the “secret” menu.
LABEL admin KERNEL menu.c32 APPEND pxelinux.cfg/admin_menu
5. Copy the necessary boot files to your tftpboot dir.
cd /mnt/tmp cp isolinux/ifcpu64.c32 isolinux/rescue* /var/lib/tftpboot/ cp bootdisk boot isolinux/initram.igz ntpasswd /var/lib/tftpboot/
6. Copy the livecd image to a web server.
It can be placed wherever you like, even on the local tftp server, as long as it’s available over HTTP.
scp /mnt/tmp/sysrcd* [email protected]:/var/www/html/pxeboot/
7. Edit the new menu to properly boot via PXE.
We’ll need to add ‘INITRD’ statements, as well as ‘boothttp’, to tell it where to fetch the livecd image from. I also trimmed out some other statements that were causing kernel panics in my environment. This is my working config. Edit every menu option as needed, removing those that you don’t find to be as useful.
MENU LABEL 1) SystemRescueCd: default boot options KERNEL ifcpu64.c32 INITRD initram.igz APPEND rescue64 boothttp=http://httpserver/pxeboot/sysrcd.dat TEXT HELP Livecd diagnostic/rescue environment. Default boot options. ENDTEXT
Create a serial option, if you have machines that rely on serial consoles (headless servers).
LABEL rescuecd_us MENU LABEL 2) SystemRescueCd: Serial Console KERNEL ifcpu64.c32 INITRD initram.igz APPEND rescue64 setkmap=us console=ttyS0,115200 boothttp=http://httpserver/pxeboot/sysrcd.dat TEXT HELP Livecd diagnostic/rescue environment. Serial console with US keymap. ENDTEXT
And that’s all there is to it! If all went well, you now have an ‘admin’ menu where you can perform sysadmin tasks like running ‘memtest’, ‘gparted’, and ‘partimage’ without having to insert a disk. Heck, you don’t even need a monitor, much less a cdrom drive. Now sit back and enjoy the fruits of sysadmin laziness. 🙂