Yesterday I updated my boot system, which I use to boot my system from an USB flash drive. It’s consists basically of BusyBox, the swiss army knife of embedded Linux and uClibc, a small c library for embedded systems plus some more tools, which I need to setup Raid and to decrypt my devices before switching to my main system. Here are the steps needed to build the system based on a stage3 snapshot of gentoo sources:
First get the snapshot, unpack it and update it:
wget http://de-mirror.org/distro/gentoo/experimental/x86/embedded/stages/stage3-x86-uclibc-2008.0.tar.bz2
tar xvfz stage3-x86-uclibc-2008.0.tar.bz2 -C bootsystem/
mount -t proc proc /boot/bootsystem/proc
cp -L /etc/resolv.conf /boot/bootsystem/etc/
chroot /boot/bootsystem /bin/bash
env-update && source /etc/profile
emerge sync
emerge -auDv world
after that make a directory for your boot system and emerge all required packages:
mkdir /bootimage
ROOT=/bootimage USE=”static make-symlinks” emerge -av busybox mdadm
ROOT=/boot_image USE=”static” emerge -av =gnupg-1.4.9 cryptsetup
create the config for mdadm:
/sbin/mdadm —detail —scan >> /boot_image/etc/mdadm.conf
Having the system set up, we still need to build an initrd or initramfs, which can be both loaded at boot time. I choose the latter one and you have just to tell the kernel where your boot system resides. This is done by setting the CONFIGINITRAMFSSOURCE in the kernel config. Mine looks like this:
CONFIGINITRAMFSSOURCE=”/boot/bootimage /boot/cpiolist”
/boot/bootimage is the system create above and /boot/cpiolist contains some nodes required at bootup (early userspace), which are not created by busybox:
# supporting directories
dir /proc 0755 0 0
dir /sys 0755 0 0
dir /root 0755 0 0
dir /dev 0755 0 0
#initial device files required (mdev creates the rest)
nod /dev/console 0600 0 0 c 5 1
nod /dev/null 0666 0 0 c 1 3

Leave a comment