Robert Millan wrote: > But if you just want grub-mkconfig not to break with btrfs in /, we need more > information on what calls are failing. There's a gazillon invocations of > grub-probe in there, I can't do anything without knowing which one is causing > the script to fail.
r...@gnu:/home/joey>grub-probe --target=device /boot # ext3 /dev/hda1 r...@gnu:/home/joey>grub-probe --target=device / # btrfs grub-probe: error: cannot find a device for / (is /dev mounted?). r...@gnu:/home/joey>grub-probe --device /dev/hda1 --target=fs_uuid a2c9d183-7f03-4451-b781-3e8fcd72c095 r...@gnu:/home/joey>grub-probe --device /dev/hda2 --target=fs_uuid grub-probe: error: unknown filesystem. I had meant to send the attached patch to #540786 yesterday (it's the patch that the patch I sent to #567077 depends on). This makes it fall back to the old method of parsing the fstab to find the info when grub-probe fails. See also: https://bugs.launchpad.net/debian/+source/grub2/+bug/450260 -- see shy jo
diff -ur old/grub2-1.98~20100126/util/grub-mkconfig.in grub2-1.98~20100126/util/grub-mkconfig.in
--- old/grub2-1.98~20100126/util/grub-mkconfig.in 2010-01-26 13:24:18.000000000 -0500
+++ grub2-1.98~20100126/util/grub-mkconfig.in 2010-01-26 22:58:03.291261320 -0500
@@ -119,8 +119,9 @@
fi
# 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="`${grub_probe} --target=device /`" || GRUB_DEVICE="`legacy_find_root_device`"
+GRUB_DEVICE_UUID="`${grub_probe} --device ${GRUB_DEVICE} --target=fs_uuid 2> /dev/null`" || \
+ GRUB_DEVICE_UUID="`legacy_convert_to_uuid ${GRUB_DEVICE}`"
# Device containing our /boot partition. Usually the same as GRUB_DEVICE.
GRUB_DEVICE_BOOT="`${grub_probe} --target=device /boot`"
diff -ur old/grub2-1.98~20100126/util/grub-mkconfig_lib.in grub2-1.98~20100126/util/grub-mkconfig_lib.in
--- old/grub2-1.98~20100126/util/grub-mkconfig_lib.in 2010-01-26 13:24:18.000000000 -0500
+++ grub2-1.98~20100126/util/grub-mkconfig_lib.in 2010-01-26 22:58:03.291261320 -0500
@@ -188,3 +188,79 @@
done
echo "$a"
}
+
+legacy_find_device ()
+{
+ mount_point=$1
+
+ # Autodetect current root device
+ device=
+ if [ -f /etc/fstab ] ; then
+ device="`awk '$1!~/^#/{
+ if ($2 ~ "^/+$") { $2 = "/"; } else { sub("/*$", "", $2); }
+ if ($2 == "'"$mount_point"'"){
+ print $1;
+ }
+ }' /etc/fstab | tail -n 1`"
+ fi
+
+ if [ -n "$device" ] ; then
+ case "$device" in
+ LABEL=* | UUID=*)
+ device="`findfs $device`"
+ device="`readlink -f "$device"`"
+ ;;
+ *)
+ device=`readlink -f "$device"`
+ ;;
+ esac
+ fi
+
+ echo $device
+}
+
+legacy_find_root_device ()
+{
+ echo "Cannot determine root device. Trying legacy probe method" >&2
+ device="`legacy_find_device /`"
+
+ if [ -z "$device" ]; then
+ echo "Cannot determine root device. Assuming /dev/sda1" >&2
+ echo "This error is probably caused by an invalid /etc/fstab" >&2
+ device=/dev/sda1
+ fi
+
+ echo $device
+}
+
+legacy_convert_to_uuid()
+{
+ echo "Cannot determine uuid of root device. Trying legacy probe method" >&2
+ local dev; dev="$1"
+
+ convert=false
+ case "$dev" in
+ /dev/disk/*)
+ ;;
+ /dev/mapper/*)
+ ;;
+ /dev/evms/[hs]d[a-z][0-9]*)
+ convert=:
+ ;;
+ /dev/evms/*)
+ ;;
+ /dev/md[0-9]*)
+ ;;
+ /dev/*)
+ convert=:
+ ;;
+ esac
+ if $convert; then
+ if [ -b "$dev" ]; then
+ uuid="`blkid -o value -s UUID "$dev" || true`"
+ fi
+ fi
+
+ echo "$uuid"
+}
+
signature.asc
Description: Digital signature

