Fix root device detection for lvm2
PATCH 1/1 Fix root device detection for lvm2
If you have a single / filesystem on lvm2, the boot process will hang waiting for a root filesystem that never appears. This patch modifies the logic in deciding what the root device actually is, and allows the initramfs to succesfully load the root filesystem.
The attached patch has been in use in the debian "grub2" packages for quite a while, so I assume it's safe to use :)
util/grub.d/10_linux.in +2 -1
@@ -43,7 +43,8 @@ esac if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \ - || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" ; then + || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \ + || [ "`grub-probe -t abstraction --device ${GRUB_DEVICE} | sed -e 's,.*\(lvm\).*,\1,'`" = "lvm" ] ; then LINUX_ROOT_DEVICE=${GRUB_DEVICE} else LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}
Quoted 6 lines · sean finney
Index: b/util/grub.d/10_linux.in
===================================================================
util/grub.d/10_linux.in line 50
Quoted 9 lines
util/grub.d/10_linux.in +2
-1@@ -43,7 +43,8 @@ esac if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \ - || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" ; then + || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \ + || [ "`grub-probe -t abstraction --device ${GRUB_DEVICE} | sed -e 's,.*\(lvm\).*,\1,'`" = "lvm" ] ; then LINUX_ROOT_DEVICE=${GRUB_DEVICE} else LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}
Applied with some chages. Thanks
Signature · 2 lines
Regards Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 8 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 7 lines · sean finney
Index: b/util/grub.d/10_linux.in
===================================================================util/grub.d/10_linux.in +0
-0@@ -43,7 +43,8 @@ esac
Quoted 9 lines
util/grub.d/10_linux.in line 50
Quoted 7 lines
util/grub.d/10_linux.in +2
-1if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \ - || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" ; then + || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \ + || [ "`grub-probe -t abstraction --device ${GRUB_DEVICE} | sed -e 's,.*\(lvm\).*,\1,'`" = "lvm" ] ; then LINUX_ROOT_DEVICE=${GRUB_DEVICE} else LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}Applied with some chages. Thanks
The changes seem to have been to simplify the test to:
[ "x`grub-probe -t abstraction --device ${GRUB_DEVICE}`" = "xlvm" ]Unfortunately this is an incorrect simplification. grub-probe can print multiple abstractions, and does in the case of e.g. LVM on RAID. If it is correct to avoid UUIDs for plain LVM, it is also correct to avoid them for LVM on RAID.
Signature · 1 line
Colin Watson [[email protected]]
Quoted 21 lines · Colin Watson
Quoted 9 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 7 lines · sean finney
Index: b/util/grub.d/10_linux.in
===================================================================util/grub.d/10_linux.in +0
-0@@ -43,7 +43,8 @@ esacQuoted 10 lines
util/grub.d/10_linux.in line 50
Quoted 8 lines
util/grub.d/10_linux.in +2
-1if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \ - || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" ; then + || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \ + || [ "`grub-probe -t abstraction --device ${GRUB_DEVICE} | sed -e 's,.*\(lvm\).*,\1,'`" = "lvm" ] ; then LINUX_ROOT_DEVICE=${GRUB_DEVICE} else LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}Applied with some chages. Thanks
Quoted 10 lines
The changes seem to have been to simplify the test to:
[ "x`grub-probe -t abstraction --device ${GRUB_DEVICE}`" = "xlvm" ]Unfortunately this is an incorrect simplification. grub-probe can print multiple abstractions, and does in the case of e.g. LVM on RAID. If it is correct to avoid UUIDs for plain LVM, it is also correct to avoid them for LVM on RAID.
Ok I agree. The problem with original patch was that it would accept ttttlvmuuu too. Feel free to fix.
Signature · 2 lines
Regards Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 5 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 4 lines · Colin Watson
The changes seem to have been to simplify the test to:
[ "x`grub-probe -t abstraction --device ${GRUB_DEVICE}`" = "xlvm" ]
Quoted 7 lines
Quoted 4 lines
Unfortunately this is an incorrect simplification. grub-probe can print multiple abstractions, and does in the case of e.g. LVM on RAID. If it is correct to avoid UUIDs for plain LVM, it is also correct to avoid them for LVM on RAID.
Ok I agree. The problem with original patch was that it would accept ttttlvmuuu too. Feel free to fix.
Fair enough. Done (r2503).
Signature · 1 line
Colin Watson [[email protected]]