More PXE Magic

Multi-OS PXE Menu

If all you were interested in was PXE booting a single version of Ubuntu or Debian, you would be done. Of course, what if you wanted the choice of either the 32- or 64-bit versions of a particular release, or what if you wanted to choose between a few different releases? Although you could just overwrite your tftpboot directory every time you wanted to change it up, with only a few extra tweaks to the config, you easily can host multiple releases with the same menu.

Move Precise to a Submenu

To get started, let's clean out any existing files in the /var/lib/tftpboot directory. Let's use the i386 Precise netboot.tar.gz to begin, but let's tweak how the files are organized by isolating precise in its own directory:


$ cd /var/lib/tftpboot
$ sudo mkdir precise
$ cd precise
$ sudo wget http://us.archive.ubuntu.com/ubuntu/dists/precise/
↪main/installer-i386/current/images/netboot/netboot.tar.gz
$ sudo tar xzf netboot.tar.gz

All of the interesting PXE configuration can be found inside the ubuntu-installer/i386 directory, so make a copy of those files back in the root tftpboot directory so you can edit them:


$ cd /var/lib/tftpboot
$ sudo cp -a precise/ubuntu-installer/i386/boot-screens 
 ↪precise/ubuntu-installer/i386/pxelinux.0 
 ↪precise/ubuntu-installer/i386/pxelinux.cfg .

Unfortunately, all of the configuration files under the boot-screens directory you copied reference ubuntu-installer/i386/boot-screens, when you want them to reference just boot-screens, so the next step is to run a quick Perl one-liner to search and remove any instance of ubuntu-installer/i386/ found in the config file:


$ cd /var/lib/tftpboot/boot-screens
$ sudo perl -pi -e 's|ubuntu-installer/i386/||' *

The specific pxelinux configuration that points to the Ubuntu Precise kernel and initrd can be found under precise/ubuntu-installer/i386/boot-screens/txt.cfg. If you were to look at that file, it would look something like this:


default install
label install
        menu label ^Install
        menu default
        kernel ubuntu-installer/i386/linux
        append vga=788 initrd=ubuntu-installer/i386/
        ↪initrd.gz -- quiet 
label cli
        menu label ^Command-line install
        kernel ubuntu-installer/i386/linux
        append tasks=standard pkgsel/language-pack-patterns= 
         ↪pkgsel/install-language-support=false vga=788 
         ↪initrd=ubuntu-installer/i386/initrd.gz -- quiet

What you want to do is make a copy of this config file under your root-level boot-screens directory, but because you extracted the tarball into a directory named precise (instead of the root directory), you need to do another search and replace, and add precise in front of any reference to the ubuntu-installer directory. Otherwise, the paths to the kernel and initrd will be wrong:


$ cd /var/lib/tftpboot/boot-screens
$ sudo cp ../precise/ubuntu-installer/i386/boot-screens/txt.cfg 
 ↪precise-i386.cfg
$ sudo perl -pi -e 's|ubuntu-installer|precise/ubuntu-installer|g' 
 ↪precise-i386.cfg

When you are done, the /var/lib/tftpboot/boot-screens/precise-i386.cfg file should look something like this:


default install
label install
        menu label ^Install
        menu default
        kernel precise/ubuntu-installer/i386/linux
        append vga=788 initrd=precise/ubuntu-installer/i386/initrd.gz 
         ↪-- quiet 
label cli
        menu label ^Command-line install
        kernel precise/ubuntu-installer/i386/linux
        append tasks=standard pkgsel/language-pack-patterns= 
         ↪pkgsel/install-language-support=false vga=788 
         ↪initrd=precise/ubuntu-installer/i386/initrd.gz -- quiet

______________________

Kyle Rankin is a systems architect; and the author of DevOps Troubleshooting, The Official Ubuntu Server Book, Knoppix Hacks, Knoppix Pocket Reference, Linux Multimedia Hacks, and Ubuntu Hacks.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Don't you think it's (way

Anonymous's picture

Don't you think it's (way past) time to do something about all the SPAM in the comments?

Yes

David Lane's picture

Got any good suggestions? Don't forget to click on the "Report Spam" feature so that we can try and keep ahead of it.

David Lane, KG4GIY is a member of Linux Journal's Editorial Advisory Panel and the Control Op for Linux Journal's Virtual Ham Shack

Preseed Enhancement

Anonymous's picture

If you wanted to add a preseed file for installation to a headless server, what would you add?

Preseed

Boethius's picture

In the given append example you'd do the following:

append vga=788 initrd=ubuntu-installer/i386/initrd.gz auto url=http://serverhostingyourpreseedfile/preseedfile.cfg -- quiet

As for the actual preseed file itself, here's an excellent reference for Precise's preseed file:

https://help.ubuntu.com/lts/installation-guide/i386/preseed-contents.html

White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState