[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[linux-lvm] Patch for Miguel Cabeca's lvm2create_initrd script

Ok -- I think I have it now (for real this time :-). I've overhauled the
mechanism for cleaning up device entries:

1) we first remove /rootvol/dev/mapper
2) mknod a /rootvol/dev/mapper/control device file
3) chroot to /rootvol, mount /proc, run /sbin/vgmknodes, and umount

This should make all the correct device entries and vg symlinks under
/dev, and should allow the initrd images to cope with the renumbering of
major/minor numbers, as I've found sometimes happens on kernel upgrades.

Attached is a patch to Miguel's original script. The current one is
available from:


As always, comments and/or patches are welcome.
Jeff Layton <jtlayton poochiereds net>
Index: lvm2create_initrd.sh
--- lvm2create_initrd.sh	(revision 70)
+++ lvm2create_initrd.sh	(working copy)
@@ -77,7 +77,7 @@
 # include in the path some dirs from the real root filesystem
 # for chroot, blockdev
 echo "$PRE Remounting / read/write"
@@ -144,6 +144,26 @@
 echo "$PRE Umounting /proc"
 umount /proc
+# make /rootvol/proc if it doesn't exist
+if [ ! -d /rootvol/proc ]; then
+    mkdir /rootvol/proc
+# remove old /dev/mapper directory
+echo "$PRE Removing old /dev/mapper directory on $rootvol"
+rm -rf /rootvol/dev/mapper
+# create /dev/mapper/control device on /rootvol
+if test -n "$MAJOR" -a -n "$MINOR" ; then
+    echo "$PRE Creating /dev/mapper/control device on $rootvol"
+    mkdir -p -m 755 /rootvol/dev/mapper
+    mknod -m 600 /rootvol/dev/mapper/control c $MAJOR $MINOR
+echo "$PRE Creating LVM2 devices on $rootvol"
+cd /rootvol
+( chroot . sh -c 'mount -t proc none /proc; /sbin/vgmknodes; umount /proc' )
 echo "$PRE Changing roots"
 cd /rootvol
 mkdir -p initrd

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]