Kexec

Introduction

There's been some discussion about this on the group, so I thought I should try to get something in the way of a kexec-based secondary bootloader. I've seen some examples of this on the internet, but they seem to involve uclibc, cross-compilers and all sorts of faffing about, so hopefully this is a bit simpler.

What we are trying to do is to have a generic firmware, with the kernel on a USB stick, thus getting round the bootloader's inability to boot directly from USB itself. Perhaps network or other 'boot devices' will be added later.

Instructions

First, get the statically linked kexec binary helpfully contributed by Razvan, or compile your own.

Next, check out all the stuff from subversion for a compact initrd-based system:

$ svn co https://bifferboard.svn.sourceforge.net/svnroot/bifferboard/initrd/

I've added an example rc files under files/etc/rc-kexec, you probably want to copy that over files/etc/rc although of course you can type these commands manually once the initrd system has loaded.

Next, copy the kexec config kernel/2.6.30.5.config-kexec over the default config kernel/2.6.30.5.config.

Follow the instructions in readme.txt on how to build. unfortunately you need an old version of Nasm.

This should give you a binary in linux-2.6.30.5/arch/x86/boot/bzImage that you can flash to the board.

Notes

My script (rc-kexec) expects the kexec program binary to be located on the first partition of the USB device at /boot/kexec, and the kernel image to be at /boot/bzImage.

You can use a line like:

kexec --append="`cat /proc/cmdline`" -l bzImage

To load the image with a specific command-line, however I've embedded the command-line into my kernel, which solved this, hence no mention of that in rc-kexec.

Caveats

There seems to be no easy way to wait for the USB device to become available before attempting to mount it, so I just chucked in a 10 second delay to wait for it to come on line. I guess a clever script or dietlibc app could solve this problem.