Kernel + initrd in 1MB of flash

Introduction

A Linux system should be possible in 1MB flash. Hopefully this will serve as a generic HOWTO to build minimal applications that have just one or two functions, but operate entirely from the 1MB storage. I will provide binaries for all except the kernel, which you probably want to change depending on your application.

Prerequisites

I compile all this stuff direct on my 32-bit Slackware 12.2 system. This should work on any 32-bit x86 Linux with a recent kernel.

You need to configure your Bootloader kernel command-line to: "console=uart,io,0x3f8".

Instructions

Download biffinitrd-XXX.tar.bz2 and decompress it (subsitite the latest version for XXX):

$ tar xf biffinitrd-XXX.tar.bz2

$ cd biffinitrd-XXX

Then run the mkbiffrd script:

$ python mkbiffrd.py

This should create initramfs.cpio

Get the 2.6.30.1 kernel from www.kernel.org:

$ wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.30.5.tar.bz2

$ tar xf linux-2.6.30.5.tar.bz2

$ cd linux-2.6.30.5

Copy or link the previously generated initramfs.cpio into this directory:

$ ln -s ../initramfs.cpio

Patch the kernel:

$ patch -p1 < ../bifferboard-2.6.30.5-X.patch

Then copy the config and compile:

$ cp ../bifferboard-2.6.30-X.config .config

$ make

After some time you should find the firmware in arch/x86/boot/bzImage, and you can copy it to your Bifferboard.

Notes

    • This quick guide is no substitute for Peter's excellent Linux on Flash HOWTO, especially if you like to compile everything from source, or wish to customise your busybox installation.

    • I've provided asmutils binaries, because you need an antiquated version of Nasm (0.98.39) to compile them.

    • By using a mixture of asmutils and busybox, I have hopefully got the best of both worlds, reducing the total size of the rootfs, while keeping a standard init/getty/shell.

    • The Busybox part of the system is still huge, so there is scope for reducing the rootfs even more.

    • When adding your own applications to this starting point, use dietlibc and/or static linking to ensure your app fits in the remaining space. Put your programs into the 'files' directory, and they will be picked up by the next run of mkbiffrd.py. DO NOT PUT THEM IN 'initramfs'. This is a temporary staging directory which gets recreated each time mkbiffrd.py is run.

An experimental asmutils-only distribution

An asmutils-only system can be found at: http://bifferboard.svn.sourceforge.net/viewvc/bifferboard/initrd/.

e.g.:

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

cd initrd/asmutils

make (there will be errors, ignore them)

cd ..

./mkbiffrd.py

Exits