PXE Part 2- Network Linux Install
So booting memtest86+ from the network was very illuminating and helpful for testing out the setup, although pretty useless too.
The next goal is to build a centralized PXE based Debian netinst repository which allows to choose between the x86 and amd64 flavours.
The first good news is that there’s no need to mess with the daemons anymore.
The second is that Debian has done most of the work for me.
So to netboot we need:
- a kernel
- an initrd image with the installer
- a PXELINUX config file
I strongly suggest to pull all the files straight from the sid branch, for two reasons. The kernel is more recent than the one in the stable installer and, as such, it’s more likely that your NIC and disks will work out of the box (expecially if your installing onto brand new laptops). Nevertheless the sid installer allows you to chose among all the three flavours, while the stable installer is only good to install a stable release.
You can find all the goodies within the Debian Installer (amd64) or Debian Installer (i386) files: linux is the kernel, initrd.gz is (guess!!) the initrd image and finally the PXELINUX config file is under pxelinux.cfg/default. If you whish boot screen help files are available as well.
Just make the three files available via TFTP, fix up some of the paths inside the default config file, and give it a go. If you did your homework you should be able to get your Debian installer fired up on the PXE client.
Now this is all very cool. Except it only handles one arch. To handle both i386 and amd64 I’d need to merge the config files, fix name collisions, etc… Additionally, even after fixing all the names and paths, I’d end up with a list of option very hard to manage: install-i386, install-amd64, expert-i386, expert-amd64, rescue-i386, and so on.
One other very nice bit in PXELINUX is that it’s not only able to boot a kernel, but also to boot small binary modules which can handlecertain specific features. One of these is vesamenu.c32: a graphic menu module for PXELINUX which allows to display simple text menus and a background image. Submenues are also possible. So let’s see…
First let’s create a directory structure on the tftproot as things will be getting confusing soon:
- pxelinux.0
- memtest86+
- debian:
- amd64:
- linux
- initrd.gz
- i386:
- linux
- initrd.gz
- amd64:
- pxelinux.cfg:
- modules:
- vesamenu.c32
- menu.c32
- other c32 modules
- default
- root
- install
- debian32
- debian64
- tests
- bg.jpg
- modules:
On the top dir we have pxelinux.0, memtest86+: nothing new here.
The debian dir contains kernels and initrd images, for both amd64 and i386.
Under pxelinux.cfg I’ve created the modules dir for c32 binaries like vesamenu.c32 (take these modules from the syslinux dir and copy/symlink them here), then there is still my old default config and a bunch of new files: bg.jpg is the background image for my nifty graphical menus and the remaining files are the main and submenus config files.
First step: a new default config
ALLOWOPTIONS 0
NOESCAPE 1
PROMPT 0
DEFAULT pxelinux.cfg/modules/vesamenu.c32
APPEND pxelinux.cfg/root
The first 3 lines disable access to the command line interface to PXELINUX.
The important stuff comes next: the DEFAULT line is used to load a default kernel or com32 module; the APPEND directive tells PXELINUX to pass some options to a kernel or to a com module.
In this case we load the vesamenu.c32 module and we pass to it the path to the menu configuration file.
So root is my main menu and it looks like:
MENU TITLE MAIN MENU
MENU BACKGROUND pxelinux.cfg/bg.jpg
LABEL inst
MENU LABEL ^Install menu
KERNEL pxelinux.cfg/modules/vesamenu.c32
APPEND pxelinux.cfg/install
LABEL diskless
MENU LABEL ^Diskless and netboot menu
KERNEL pxelinux.cfg/modules/vesamenu.c32
APPEND pxelinux.cfg/diskless
LABEL tests
MENU LABEL ^Test menu
KERNEL pxelinux.cfg/modules/vesamenu.c32
APPEND pxelinux.cfg/tests
LABEL void
MENU LABEL
LABEL chain
MENU LABEL ^Normal boot
LOCALBOOT 0
The first 2 lines set the menu title and the menu background (the image must be a 640×480 png or jpeg).
Next I created 3 labels (or menu items) for the install, diskless and tests submenues.
Then an empty label (no MENU LABEL set) to insert a separator.
Last there’s another label called “Normal Boot”: this one is particular in that it doesn’t load a kernel, nor it does load a com module. The LOCALBOOT 0 directive causes PXELINUX to abort and to go back to the bios telling it the boot has failed. The bios will then pick the next candidate (the hard disk, the cdrom, etc) from its boot order list and attempt to boot again from there.
The install config file is again a menu descriptor:
MENU TITLE INSTALL MENU
MENU BACKGROUND pxelinux.cfg/bg.jpg
LABEL debian32
MENU LABEL Debian-i386
KERNEL pxelinux.cfg/modules/vesamenu.c32
APPEND pxelinux.cfg/debian32
LABEL debian64
MENU LABEL Debian-amd64
KERNEL pxelinux.cfg/modules/vesamenu.c32
APPEND pxelinux.cfg/debian64
LABEL void
MENU LABEL
LABEL back
MENU LABEL ^back
KERNEL pxelinux.cfg/modules/vesamenu.c32
APPEND pxelinux.cfg/root
Nothing fancy, just an intermediate menu which jumps to debian32, debian64 or back to root.
Finally let’s take a look at the debian64 menu (the debian32 is pretty much the same except for paths):
MENU TITLE INSTALL DEBIAN amd64
MENU BACKGROUND pxelinux.cfg/bg.jpg
DEFAULT install
LABEL install
kernel debian/amd64/linux
append vga=normal initrd=debian/amd64/initrd.gz --
LABEL linux
kernel debian/amd64/linux
append vga=normal initrd=debian/amd64/initrd.gz --
LABEL expert
kernel debian/amd64/linux
append priority=low vga=normal initrd=debian/amd64/initrd.gz --
LABEL rescue
kernel debian/amd64/linux
append vga=normal initrd=debian/amd64/initrd.gz rescue/enable=true --
LABEL auto
kernel debian/amd64/linux
append auto=true priority=critical vga=normal initrd=debian/amd64/initrd.gz --
LABEL void
MENU LABEL
LABEL back
MENU LABEL ^back
KERNEL pxelinux.cfg/modules/vesamenu.c32
APPEND pxelinux.cfg/install
This is pretty much the same config file available on debian with only the paths adjusted, a vesamenu layout and an option to get back to the install menu. Please note that the initrd directives are entirely on one line (as in lilo or grub), the wrapage is only due to the web rendering.
So I now have a fancy PXE boot server with nice menues and the ability to install pretty much any debian flavour of Debian.
If I was a wise nerd I would have stopped here…