Comment 5 for bug 688261

Revision history for this message
Serge Hallyn (serge-hallyn) wrote : Re: [Bug 688261] Re: When in a multipath, boot from SAN environment, update-grub will make the system unbootable

After hours and hours trying to get grub-probe to do the right thing,
I've decided to temporarily work around it instead. Package is still
compiling, but hand-applied changes to the installed scripts allowed
me to run update-grub on multipath-enabled system. Patch:

diff -Nur -x '*.orig' -x '*~' grub2-mp1/util/grub-mkconfig.in grub2-mp1.new/util/grub-mkconfig.in
--- grub2-mp1/util/grub-mkconfig.in 2010-12-10 10:53:15.000000000 -0500
+++ grub2-mp1.new/util/grub-mkconfig.in 2010-12-10 22:36:19.658999131 -0500
@@ -120,15 +120,18 @@

 # Device containing our userland. Typically used for root= parameter.
 GRUB_DEVICE="`${grub_probe} --target=device /`"
-GRUB_DEVICE_UUID="`${grub_probe} --device ${GRUB_DEVICE} --target=fs_uuid 2> /dev/null`" || true
+#GRUB_DEVICE_UUID="`${grub_probe} --device ${GRUB_DEVICE} --target=fs_uuid 2> /dev/null`" || true
+GRUB_DEVICE_UUID="`blkid ${GRUB_DEVICE} | sed -e 's/ /\n/g' | grep UUID | cut -d \\" -f 2`"

 # Device containing our /boot partition. Usually the same as GRUB_DEVICE.
 GRUB_DEVICE_BOOT="`${grub_probe} --target=device /boot`"
-GRUB_DEVICE_BOOT_UUID="`${grub_probe} --device ${GRUB_DEVICE_BOOT} --target=fs_uuid 2> /dev/null`" || true
+#GRUB_DEVICE_BOOT_UUID="`${grub_probe} --device ${GRUB_DEVICE_BOOT} --target=fs_uuid 2> /dev/null`" || true
+GRUB_DEVICE_BOOT_UUID="`blkid ${GRUB_DEVICE_BOOT} | sed -e 's/ /\n/g' | grep UUID | cut -d \\" -f 2`"

 # Filesystem for the device containing our userland. Used for stuff like
 # choosing Hurd filesystem module.
-GRUB_FS="`${grub_probe} --target=fs / 2> /dev/null || echo unknown`"
+#GRUB_FS="`${grub_probe} --target=fs / 2> /dev/null || echo unknown`"
+GRUB_FS="`blkid ${GRUB_DEVICE} | sed -e 's/ /\n/g' | grep TYPE | cut -d \\" -f 2`"

 if test -f ${sysconfdir}/default/grub ; then
   . ${sysconfdir}/default/grub
diff -Nur -x '*.orig' -x '*~' grub2-mp1/util/grub-mkconfig_lib.in grub2-mp1.new/util/grub-mkconfig_lib.in
--- grub2-mp1/util/grub-mkconfig_lib.in 2010-12-10 10:53:15.000000000 -0500
+++ grub2-mp1.new/util/grub-mkconfig_lib.in 2010-12-10 22:38:15.778704576 -0500
@@ -65,9 +65,9 @@
   fi

   # abort if file is in a filesystem we can't read
- if ${grub_probe} -t fs $path > /dev/null 2>&1 ; then : ; else
- return 1
- fi
+ #if ${grub_probe} -t fs $path > /dev/null 2>&1 ; then : ; else
+ # return 1
+ #fi

   return 0
 }
@@ -108,20 +108,23 @@
   device=$1

   # Abstraction modules aren't auto-loaded.
- abstraction="`${grub_probe} --device ${device} --target=abstraction`"
+ #abstraction="`${grub_probe} --device ${device} --target=abstraction`"
+ abstraction=""
   for module in ${abstraction} ; do
     echo "insmod ${module}"
   done

- fs="`${grub_probe} --device ${device} --target=fs`"
+ #fs="`${grub_probe} --device ${device} --target=fs`"
+ fs="`blkid ${device} | sed -e 's/ /\n/g' | grep TYPE | cut -d \\" -f 2`"
   for module in ${fs} ; do
     echo "insmod ${module}"
   done

   # If there's a filesystem UUID that GRUB is capable of identifying, use it;
   # otherwise set root as per value in device.map.
- echo "set root='`${grub_probe} --device ${device} --target=drive`'"
- if fs_uuid="`${grub_probe} --device ${device} --target=fs_uuid 2> /dev/null`" ; then
+ #echo "set root='`${grub_probe} --device ${device} --target=drive`'"
+ #if fs_uuid="`${grub_probe} --device ${device} --target=fs_uuid 2> /dev/null`" ; then
+ if fs_uuid="`blkid ${device} | sed -e 's/ /\n/g' | grep UUID | cut -d \\" -f 2`"; then
     echo "search --no-floppy --fs-uuid --set ${fs_uuid}"
   fi
 }