Version: 1.6.2
© 2007-2009 Daniel Collins
© 2008 Philip Kent
kexec-loader is a Linux based bootloader that uses kexec to start the kernel of your choice. It fits on a 1.44MB floppy, supports most block devices supported by Linux and is easy to use. kexec-loader supports reading GRUB configuration files, this allows kexec-loader to be used as a drop-in replacement for GRUB by merely setting the GRUB installation path.
The kexec-loader project site has prebuilt disk images available for download, unless you have a very good reason for compiling from source, this is the best option, as the process for building disk images is complicated and requires an understanding of the Linux boot process. The prebuilt images have support for PC floppy drives, USB mass storage devices and the FAT filesystem, other devices and filesystems may be used if the appropriate module is loaded.
The configuration for kexec-loader is stored on the boot floppy in a file named /kexec-loader.conf, it must exist, as kexec-loader locates the boot floppy by checking for its presence. The following devices are searched by default:
If the kexec-loader boot floppy is not in that list, you can override the default search list by using the kexec_root kernel option, for example: kexec_root=/dev/hda.
The file contains directives in the form "<directive> [args]", directives and argument should be seperated with whitespace, empty lines and lines beginning with a hash (#) are ignored.
The directives are as follows.
Where parameters are shown in <angled brackets>, they are required for that directive. Ones in [square brackets] are optional. For mount and rootfs, if you do specify a fstype, it should be specified as ext2:/dev/hda1 for example.
To navigate the kexec-loader menu, use your arrow keys to select an item and press enter to boot it. A number of functions are available; press L to list the detected devices and their filesystems. Press enter if you are on the device screen or an error and you want to escape.
Upon asking a kernel to boot, it may take a few seconds for it to load the kernel and switch to it. After switching, your new kernel will start and the boot process will happen as it would normally.
kexec-loader has a built in shell. To access it press "s" on the menu screen. This shell allows
There are two further directives used to control kexec-loader, rather than set up a kernel to boot. They are:
To scroll through the command history, use the up and down keys. A maximum of 32 commands are remembered (upon exceeding this, the oldest command will be removed from the history to make space). Commands that are longer than the screen can hold will scroll, similar to the 'nano' text editor. Please note that this shell will be improved in subsequent releases.
Once kexec-loader has started all debugging messages, as well as Linux kernel messages are sent to a separate debug console. By default the debug console is /dev/tty2, this can be changed at boot by using the Linux cmdline, for example kexec_debug=/dev/ttyS0 writes all debug messages and kernel messages to the first serial port.
Kernel modules can be loaded by kexec-loader to add support for extra devices or filesystems which target systems can be loaded from. To add extra modules, simply copy them to /modules/ on the kexec-loader disk, to specify module arguments, use the /modules/modules.conf file. Modules loaded this way only affect the kernel running kexec-loader, not those loaded by kexec-loader.
If you are using an official kexec-loader disk image, kernel modules are available on the downloads page of the project site, named somthing like modules-XXX.tar.gz, make sure you download the correct modules for your kernel.
This section explains how to build a kexec-loader disk image, you must build a kernel and toolchain which is not explained in this document. I recommend using uClibc as a toolchain as glibc is too big to fit on a floppy, you must also use Linux 2.6.13 or above, as earlier versions did not have the kexec syscalls.
You will need the following to compile kexec-loader:
To compile kexec-loader, use the following commands:
HOST=i386-linux-uclibc make
./mkinitramfs.sh initramfs.cpio
The first command assumes your toolchain was built to target i386-linux-uclibc, in which case the various tools such as gcc can be invoked as i386-linux-uclibc-gcc, ensure you set this to the correct target, or the compile may fail, or end up being compiled with the wrong toolchain. You must also make sure that the toolchain bin directories are included in $PATH.
The first command compiles kexec-loader, downloads, patches and compiles kexec-tools, then links them as the binaries src/kexec-loader and src/kexec-loader.static, which are dynamically and statically linked respectively. The second command creates a Linux initramfs archive as initramfs.cpio, the initramfs contains kexec-loader.static as /init, some device nodes and empty directories.
This is a fairly generic floppy building method:
Notes:
I embed the kexec-loader initramfs inside the kernel to make it take a little less space, you can also put the initramfs on the floppy image as a seperate file if your chosen bootloader is capable of loading an initrd/initramfs for the kernel, the UPX compression step is also optional.
For information on kexec-loader, including current development and latest releases, please see the project website.
The developer of kexec-loader, Daniel Collins (aka solemnwarning), can often be found on the Freenode IRC network. To contact solemnwarning, you can use the following e-mail address: solemnwarning@solemnwarning.net.