Building a LVM initrd

My system configuration

I'm running a "reasonably" stock RedHat/SGI configuration -- which means that:

I've set things up so that my root filesystem is on an LVM logical volume. While this leads to flexible storage management, it presents some interesting problems.

The problem with lvmcreate_initrd

It doesn't work. To boot my system, the initrd needs, minimally:

Unfortunately, the initrd built with lvmcreate_initrd only contains the LVM driver, and is thus dead in the water. Additionally, unlike RedHat's mkinitrd, the lvmcreate_initrd script doesn't provide any way of telling it to include additional modules.

My solution: a busybox-based initrd

To solve the booting problem, I've built an initrd image based on busybox, a suite of standard utilities designed for "small" installations (such as embedded systems, or initial ram disks). This gives me a flexibile pre-boot environment, including a real shell, and is especially useful when something is wrong with the boot process.

Kernel configuration

You'll need to make sure that your kernel has the following drivers built in:

I've also got tmpfs (CONFIG_TMPFS) compiled in, which I mount on /tmp in the initrd shell so that I have a place to drop command output or copy files from floppies without overrunning the end of the ramdisk.

Required files

To boot a system with root on an LVM volume, you need at least the following on your initrd image:

You also need some sort of script interpreter. I use the version of ash built into busybox; RedHat uses their custom nash program on their ramdisks.

You'll also need the mount command: you're going to need to mount the /proc filesystem and later on your root filesystem.

Bits and pieces

Building the image

Once you've created your initrd directory tree and populated it with files, you need to create a filesystem image. Instructions on doing this can be found elsewhere, although I'll try to include them here when I have more time.

You'll probably want to compress the image using gzip. If your image is on the large (> 4M) size, you may want to include the ramdisk_size option in your kernel command line.

Other sources of information

The "initrd.txt" file in the Linux documentation is a useful source of information about the initrd boot process. On systems running RedHat linux, you can create an initrd image using the mkinitrd command and then loopback mount the result to see what it looks like.
lars@larsshack.org