How to create a network bootable installer

Bootstrapping

Set up a DHCP server. I used udhcpd, but it does not matter. Besides giving out an IP address, you need to specify the bootfile and the rootpath options, and the server IP address. I use this config file:

start 10.0.0.100
end 10.0.0.200
interface eth0

siaddr 10.0.0.5
boot_file /pxelinux.bin
option bootfile /pxelinux.bin
option rootpath /nfsroot

You need to set up a TFTP server next. All the operating systems have a way to boot into their PXE installer, but we want more: we want to have a boot menu allowing us to select which installer we start.

Grub has a PXE version that allows to boot into many operating systems, and having a grub lying around bootable via PXE is a very good idea, because grub has a console mode that allows you to reinstall itself on your hard disk, in case some stupid installer overwrites your boot record (Windows comes to mind).

However, grub does not allow chain-loading other PXE boot loaders. So we need to do the menu with some other software. As you can see above, I used PXELinux, which is part of Syslinux. Don't let the name and legacy fool you, though. It's not Linux specific.

So you need to have pxelinux around for this. Put it in your TFTP area, I am using /tftpboot for this. The file is called pxelinux.0 in the distribution, but if you say "make pxelinux.0", it also creates a pxelinux.bin, which is the same as pxelinux.0, and I found ".bin" clearer, so I just left that name there. It does not matter. In case you don't have one, you need to install a TFTP server now. I tried atftpd, but it had interoperability problems and tended to spontaneously segfault, so I switched to in.tftpd from tftp-hpa. After you said make install, you can simply run the daemon like this: in.tftpd -sl /tftpboot.

Next, we have to configure pxelinux. Go to your TFTP server directory, and create a directory "pxelinux.cfg". Create a file named "default" in this directory. Here is mine, to give you a general idea:

LABEL openbsd
  KERNEL openbsd.0

LABEL openbsd64
  KERNEL openbsd64.0

LABEL netbsd
  KERNEL netbsd.0

LABEL memtest
  KERNEL memtest.bin

LABEL grub
  KERNEL pxegrub

LABEL local
  LOCALBOOT 0

Having a memtest to run via network is also a nice things to have, trust me on this one. I use this one.

The last, optional step is to run a NFS server. It does not hurt to have a rescue system booting via nfsroot or RAM disk around.

OpenBSD

I used OpenBSD 3.8 for this. You need "bsd.rd" and "pxeboot" for your platform. Copy "bsd.rd" and to /tftpboot. Copy "pxeboot" to /tftpboot and name it "openbsd.0". It is important to have the file end with .0, because the extension determines what pxelinux does with the file. The .0 tells pxelinux that it is a PXE image; you could also boot a floppy image this way, for example, which needs a different memory layout.

Make sure your pxelinux.cfg/default has a KERNEL line linking to your new openbsd.0 file! We have a slight problem at this stage with the kernel names. You could also put a /boot/loader.rc file in your TFTP root. The problem is that the other BSDs behave the same and all fetch the same files, so you need to type in the kernel name manually if you want to offer more than one BSD in the boot menu.

That's it.

NetBSD

I used NetBSD 2.1 for this. Download netbsd-INSTALL.gz for your architecture, for example from ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-2.1/i386/binary/kernel/.

Copy this kernel image to your TFTP export directory. You also need pxeboot, which is not available standalone, but it is in base.tgz, for example from ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-2.1/i386/binary/sets/. You will find it in ./usr/mdec/pxeboot_ia32.bin. Copy this file to your TFTP root. I renamed mine to "netbsd.bin" for consistency. In contrast to OpenBSD, NetBSD expects to load the kernel via NFS, unless you interrupt the boot and say boot tftp:netbsd.gz at the prompt (assuming your kernel file is called netbsd.gz).

Make sure your pxelinux.cfg/default has a KERNEL line linking to your new netbsd.0 file!

That's it.

FreeBSD

I used FreeBSD 6.0 for this. You need to run an NFS server for FreeBSD. In particular, an NFS version 2 server. I normally use unfsd if I need NFS, but unfsd only supplies NFS version 3, that's why I mention this.

Copy boot/pxeboot from the FreeBSD mini install CD to /tftpboot/freebsd.0, then export the boot/kernel directory via NFS. That least that's what I did. Problem is: the kernel reboots for me. I get the rotating "/" display, then it hangs for a few seconds, then it reboots. Darn. I'll update this when I have more info.

Ubuntu

Do this:

cd /tftpboot
mkdir ubuntu
cd ubuntu
wget http://archive.ubuntu.com/ubuntu/dists/warty/main/installer-i386/current/images/netboot/pxeboot.tar.gz
wget http://archive.ubuntu.com/ubuntu/dists/warty/main/installer-i386/current/images/netboot/vmlinuz

Then add the following to your pxelinux.cfg/default:

LABEL ubuntu
  KERNEL ubuntu/vmlinuz
  APPEND vga=normal initrd=ubuntu/initrd.gz ramdisk_size=11057 root=/dev/rd/0 devfs=mount,dall rw --