If compiling kexec-loader the following software is required:
You will also need cpio, lzma and fakeroot (or root access) to create an initramfs, mtools and syslinux if building a floppy image or mkisofs and isolinux if building an ISO image.
The following environment variables are used by the Makefile while building kexec-loader, they may or may not be required depending on what target is being invoked. For example the 'floppy' target requires KERNEL to be set.
Variable | Default | Description |
---|---|---|
HOST | None | Cross-compiler target (i.e. i386-linux-uclibc) |
FLOPPY | floppy.img | Name of floppy image file |
ISO | cdrom.iso | Name of ISO image file |
ISOLINUX | /usr/share/syslinux/isolinux.bin | Path to isolinux binary |
KERNEL | None | Path to Linux kernel binary |
KCONFIG | None | Path to Linux kernel config file |
Once you have the build environment setup you can run 'make' to build statically and dynamically linked kexec-loader binaries (kexec-loader.static and kexec-loader respectively). During the build process kexec-tools and e2fsprogs will be downloaded, patched (if necessary) and the required parts will be included in kexec-loader.
The rootfs filesystem containing kexec-loader and other files such as device nodes is extracted from an initramfs archive during bootup, it is usually named initrd.img to comply with 8.3 filename restrictions and common convention, however it is not an initrd which serves a similar purpose, but is differently implemented. There is an mkinitramfs.sh script in the kexec-loader source distribution which can be used to build one once the binaries have been compiled.
If you wish to use kexec-loader without a dedicated boot disk (i.e when using PXE), you should add any files normally loaded from the boot disk (kexec-loader.conf, keymap.txt, etc) to the root of the initramfs alongside an empty file called "noboot". The presence of the noboot file instructs kexec-loader that there is no boot disk and all files should be loaded from the initramfs instead.
Note: Emulated disks (BIOS INT13) cannot be used with kexec-loader as Linux does not use BIOS calls to access drives.
Floppy images containing kexec-loader can be built using the 'make floppy' command, you will need to provide a kernel in the KERNEL environment variable and optionally the .config file in the KCONFIG variable. Such kernels should include vfat and floppy support at the very least, if built as a module these must be included in the initramfs using the addmod.sh script.
Support exists for running kexec-loader from a CD, however it is recommended to use a floppy image if possible as you will need to rebuild the ISO image and burn a new CD if any changes are made to the configuration/modules/etc. If you still wish to build an ISO image you can use the 'make cdrom' command which uses KERNEL/KCONFIG in the same way as the floppy target. When you first run it, a directory named iso-files will be created, containing the file tree of the CD and an iso-modules directory, to which modules can be added in order to include them in the initramfs. If you make any changes to these directories you can run 'make cdrom' again to update the ISO.
The root directory (where kexec-loader.conf, modules, etc are placed) can be changed using the rootdir kernel argument. For example if rootdir=/boot/kexec is passed to the kexec-loader kernel, the configuration, modules and other files will be loaded from the /boot/kexec/ directory instead of / on the boot disk.