Creating the Initial RAM Disk

Getting the base initrd image

First you have to get a working initrd image. Since you need a Debian installation this is pretty simple:

# mkdir initrd
# cd initrd
# gunzip </boot/initrd.img-2.6.18-4-686 | cpio --extract --preserve --verbose

Remember you choice for the initrd image when you create the boot device later because you have to pick a compatible kernel.

Modifications

I made some modifications to the stock initrd image:

Modules
I added modules for vfat and sshfs support. Also important (but not obvious) for bootable vfat USB sticks are the modules nls_cp437.ko and nls_iso8859-1.ko which must be present to enable mount to mount the stick. I know that both modules are standard for western-style charsets but I have no idea if these modules have to be changed if the stick is created under different NLS settings.

Furthermore I made some additional scripts

/bin/cpio
the busybox cpio cannot extract "--format=newc" archives (when trying it says "need to fix this"). Using "--format=crc" could be an option but for now I prefer to install a "real" cpio.

/init
Not new of course but I maintain a copy of it for editing. The modified init script does not boot locally but tries to get the linux image into RAM.

/lib/libnsl.so.1
required to make cpio run.

/scripts/load-image
Loads the linux.tgz from a TFTP server or from a CD-ROM or USB device (/dev/sd[ab]1). The load-image script does

  1. Try to mount the devices /dev/hda to /dev/hdd, /dev/sg0 and /dev/sr0 to find a CD-ROM.
  2. When successful, the directories /, /isolinux, /boot and /bootcode are checked for the file linux.tgz.
  3. If the file can be found it is installed into RAM.

If this is not successful this is repeated for detected USB disks and the disk partitions /dev/sda1 to /dev/sdd1. Possible file system type are ext2, ext3 and vfat; the scanned directories are /, /extlinux and /boot.

Notice that this is only the basic functionality. The script supports also PXE boots from TFTP of FTP servers.

/scripts/init-image
Makes some modifications to the RAM installed linux image. These are

  1. Create the directory /dev/shm.
  2. Create /var/cache/apt/archives/partial just in case it was cleaned with the .deb packages.
  3. Configure the interfaces lo as auto and eth0 as auto and dhcp.

Packing the image

The initrd image must be a cpio archive, so in contrast to the Linux image a tar will not work. Furthermore the cpio archive must have a certain format:

# cd initrd
# find . | cpio --create --'format=newc' | gzip >../initrd.img-2.6.18-4-686

creates the initrd image in the required format.