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 /proc
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:
http://poochiereds.net/svn/lvm2create_initrd
As always, comments and/or patches are welcome.
Signature · 1 line
Jeff Layton <[email protected]>
lvm2create_initrd.sh +21 -1
@@ -77,7 +77,7 @@ # include in the path some dirs from the real root filesystem # for chroot, blockdev -PATH="/sbin:/bin:/usr/sbin:/usr/bin:/lib/lvm-200" +PATH="/sbin:/bin:/usr/sbin:/usr/bin:/lib/lvm-200:/initrd/bin:/initrd/sbin" PRE="initrd:" 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 +fi + +# 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 +fi + +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
Quoted 12 lines · Jeff Layton
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 /procThis 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.
Quoted 6 lines
Attached is a patch to Miguel's original script. The current one is available from:
http://poochiereds.net/svn/lvm2create_initrd
As always, comments and/or patches are welcome.
Alas, I think I've solved this problem in the wrong place. The real problem is that the LVM startup script on Debian that runs prior to the mountall script doesn't add the --mknodes flag when it runs vgscan.
I think that's the correct place to have it fix the device entries. I'm working with the maintainer of the lvm-common debian package now to see if we can get the fix rolled into their package.
So the only change that should be needed to Miguel's script is to add /initrd entries to the PATH.
Cheers,
Jeff