[linux-lvm] booting a dm+lvm2 kernel

Christophe Saout christophe at saout.de
Thu Jan 1 15:42:01 UTC 2004


Sorry for interrupting your discussion, but if someone is modifying the
initrd script to work with LVM2 or writing a new one, I've perhaps some

Some time ago I used a simple initrd that just ran lvm vgscan and let
the kernel do the rest. But some days ago the system hung while it had
snapshots mounted. It didn't boot. Why? Well, having the snapshots
mounted the minor numbers changed and the kernel didn't find the root
filesystem anymore.

So I modified my initrd to used pivot_root to mount the root filesystem
itself. I can now give root=/dev/vg/root directly as parameter to the
kernel instead of having to rely on lilo to resolve the numeric
major:minor (that caused the trouble).

The only backdraw: If there isn't an /initrd on the root filesystem,
pivot_root fails. Perhaps I could let the script put the detected
major:minor into /proc/sys/kernel/real-root-dev instead of using
pivot_root. (I didn't because another binary like ls would need more

I also switched to ash as shell (a very small bourne-compatible shell).

And I added udev to the initrd. The static /dev entries on the initrd
are only the basic ones, like /dev/console, /dev/null and so.
/dev/mapper/initrd is created dynamically using /proc/misc, and the
existing block devices are created using udev and /sys/block/* (if /dev
isn't devfs).

I think these are alls things that an updated initrd could recognize.

So it could:
a) look whether a 2.4 or 2.6 kernel is used and if udev is available (if
it is, use udev and a minimalistic /dev, if not, copy the existing
b) look for a small shell that is bourne-compatible (/bin/ash if found,
/bin/sh (probably bash) else).
c) if LVM2 is used add dynamic /dev/mapper/control detection and use
lvm2 tool, use lvm1 else
d) try to use pivot_root if available and/or write the recognized
major:minor to /proc/sys/kernel/real-root-dev
e) use partial activation mode if available
f) figure out the used binaries and libraries and copy them (just like
the old initrd does) and strip them
g) add the possibility to load modules

You can find my Athlon or P3 optimized initrd on my page:
http://www.saout.de/misc/ (after gunzipping it you can mount it using
mount initrd.blablabla /mnt -o loop).

More information about the linux-lvm mailing list