Introduction

If you don't have a mainboard supported by LinuxBIOS don't worry: QEMU can help you to emulate one. Using LinuxBIOS with QEMU may serve the purpose to familiarize you as a developer with LinuxBIOS and may be a reference system during development.

While there are many ways to use LinuxBIOS to load and run a Linux kernel, this tutorial covers two of the most common:

LinuxBIOS with FILO as payload, using FILO to load a Linux kernel (and optional initramfs) from a hard disk image. This approach involves a bit more mechanism (it relies on FILO's built-in disk and filesystem drivers) but it produces a tiny LinuxBIOS image.

LinuxBIOS with a Linux kernel (and optional initramfs) as payload. This cuts FILO out of the picture, but the main challenge with this approach is squeezing the resulting LinuxBIOS image into QEMU's BIOS ROM area (currently 2 MB, but easy to extend by patching QEMU).

Requirements

plus a Linux kernel and root filesystem and a working development environment (make, gcc, etc.). gcc 4.0.x and 4.1.x are known to work for all packages except QEMU, which requires gcc 3.x.

Building or finding a Linux kernel

If you are using FILO, you can simply grab a Linux kernel and initramfs from your favorite distribution.

Otherwise, you will probably need to build a kernel and initramfs from scratch, ensuring that the final LinuxBIOS image does not exceed QEMU's BIOS size limit. Building the kernel and initramfs is beyond the scope of this tutorial; how you configure them depends on your application.

If you plan to use kexec to chain-boot another Linux kernel, tools from these projects can help automate the process of generating a kernel and initramfs:

if you are using a Linux payload, increase the value of option ROM_SIZE to 2048*1024 (2 MB)

Return to targets directory and execute:

$ ./buildtarget emulation/qemu-i386

Go to targets/emulation/qemu-i386/qemu-i386 and execute:

$ make

This creates the LinuxBIOS image (qemu-bios.rom). Copy and rename this file to bios.bin in your home directory.

Building Qemu

If you plan to run Qemu version 0.9.0, you will have to build QEMU from source after applying a couple of patches. (Later versions of QEMU might incorporate these patches, allowing you to run them unmodified; hopefully someone will be kind enough to update this tutorial if this happens.)