This guide will explain how to install a linux kernel and a basic set of unix utilities in a bootable CompactFlash Card, assuming that you have already installed RH9 on a PC and that you will be using a USB CF Card reader.

Initializing the CF Card

Let's start with erasing any existing partitions and creating a new one:
fdisk /dev/sda (or whatever the device is for your CF card)

In case you are not familiar with fdisk:
p (prints all existing partitions) d (deletes a partition)
n (creates a new partition) w writes and exists
q quits without saving

Delete all existing partitions and create a default primary Linux partition (type 83) using all available space. Save and exit (w)

Format the new partition with:
mkfs.ext2 /dev/sda1 (replace sda1 with your new partition)

Create a mount point and mount your CF card:
mkdir /mnt/flash
mount -t ext2 /dev/sda1 /mnt/flash
(sda1 would be the first partition on the device sda. Make sure you replace sda with the equivalent to your CF card)

And now, let's create a basic directory structure:
mkdir /mnt/flash/boot
mkdir /mnt/flash/bin
mkdir /mnt/flash/dev
mkdir /mnt/flash/dev/cciss
mkdir /mnt/flash/etc
mkdir /mnt/flash/lib
mkdir /mnt/flash/opt
mkdir /mnt/flash/proc
mkdir /mnt/flash/sbin
mkdir /mnt/flash/tmp
mkdir /mnt/flash/var
mkdir /mnt/flash/usr
mkdir /mnt/flash/usr/bin
mkdir /mnt/flash/usr/lib
mkdir /mnt/flash/etc/init.d
cd /mnt/flash/dev
/dev/MAKEDEV std
/dev/MAKEDEV ttyS0
/dev/MAKEDEV hda
/dev/MAKEDEV hde
/dev/MAKEDEV console
/dev/MAKEDEV audio
mknod psaux c 10 1
mknod console c 5 1
mknod /mnt/flash/dev/hda b 3 0
mknod /mnt/flash/dev/hdb b 3 64
mknod /mnt/flash/dev/hdc b 22 0
mknod /mnt/flash/dev/hdd b 22 64

Installing Busy Box

We need a basic set of unix utilities. Given the memory limitation, we will install BusyBox. Busybox provides a set of basic utilities in a single executable.

Download the latest version (0.60.5 when I wrote this guide)

Unpack and compile:
tar -zxf busybox-0.60.5.tar.gz
cd busybox-0.60.5
make install

Install Busybox on your CompactFlash:
cp -r _install/* /mnt/flash

Copying GRUB (Boot Loader)

Let's now copy a few files from the PC to the CF we will need them later on:
cp /sbin/grub /mnt/flash/sbin
cp /sbin/fdisk /mnt/flash/sbin
cp /sbin/mkfs.ext2 /mnt/flash/sbin
cp /lib/ /lib/ /lib/ /mnt/flash/lib/
cp /lib/ /mnt/flash/lib/
cp /lib/ /mnt/flash/lib/
cp /lib/ /mnt/flash/lib/
cp /lib/ /mnt/flash/lib/

RH9 comes with two boot loaders: LILO and GRUB. I have never been able to get LILO to work on a CF Card. It always stops at the LI prompt (usually writes LILO) and even though I tried all tricks I found on the web for this known problem, none of them worked. That's why we will use GRUB instead.

Copy all boot files from your PC to the CF Card:
cp -vax /boot/* /mnt/flash/boot

Getting a Kernel

By copying /boot to your CF Card, you have already copied your existing kernel. If that is good enough for you, then you can skip this section.

I am not going to spend time on the details here, just grab the latest version from, untar and do:

make menuconfig (It is important here to select the right processor according to the machine you will be using. See the Processor Type and Features section)

make menuconfig
make dep
make bzImage

Once it is done, copy the fresh kernel to your CF Card:
cp arch/i386/boot/bzImage /mnt/flash/boot/vmlinuz
cp /mnt/flash/boot/

Making the CompactFlash card bootable

Now we have to write the MBR on the Compact Flash. Execute GRUB:

You will get to the grub> command line. If you do not have curses installed on your PC, you will get: Error opening terminal Linux. If that is the case, try grub --no-curses

Grub names the drives in a different way. The first drive would be hd0, the second drive would be hd1, and so on. The partition number is specified with a second digit after a comma. For example hd0,0 is the first partition on the first hard drive. Set your root partition with:
root (hd1,0) you can hit tab twice after hd and you will get a list of option (bash-style) just to make sure you are talking about the right partition. It might not be (hd1,0)

Install the MBR with:
install /boot/grub/stage1 (hd1) /boot/grub/stage2 (again, replace hd1 with your CF drive)

More details on GRUB, such as creating a boot menu are beyond the scope of this document. Check this article for more information about GRUB on CompactFlash

Unmount your CF card with umount /mnt/flash. Your CF card is now ready and will get you to your # prompt. However, you will have to specify your kernel, root partition and init scripts at the GRUB> prompt:

GRUB> root (hd0,0) (or whatever it is)
GRUB> kernel /boot/vmlinuz root=/dev/hda1 rw init=/bin/sh
GRUB> boot

Replace hda1 with the device corresponding to your CF card. In my case is hda1 as I am using an ACS IDE to CompactFlash adapter in my BluePad Tablet PC

The next step would be to install Linux on the BluePad internal flash, but that would be covered in a future document.

For now, my mission has been accomplished

BluePad running linux

All knowledge and software published in this website is released under the GNU General Public License (GPL)