summaryrefslogtreecommitdiff
path: root/sys-boot/grub/files/grub-1.98-add-legacy-rootfs-detection.patch
diff options
context:
space:
mode:
Diffstat (limited to 'sys-boot/grub/files/grub-1.98-add-legacy-rootfs-detection.patch')
-rw-r--r--sys-boot/grub/files/grub-1.98-add-legacy-rootfs-detection.patch83
1 files changed, 83 insertions, 0 deletions
diff --git a/sys-boot/grub/files/grub-1.98-add-legacy-rootfs-detection.patch b/sys-boot/grub/files/grub-1.98-add-legacy-rootfs-detection.patch
new file mode 100644
index 00000000..1fadd461
--- /dev/null
+++ b/sys-boot/grub/files/grub-1.98-add-legacy-rootfs-detection.patch
@@ -0,0 +1,83 @@
+diff -ur grub2-orig/util/grub-mkconfig.in grub2-new/util/grub-mkconfig.in
+--- grub2-orig/util/grub-mkconfig.in 2010-01-28 15:01:46.746567396 +0100
++++ grub2-new/util/grub-mkconfig.in 2010-01-28 15:38:48.560587115 +0100
+@@ -119,8 +119,8 @@
+ 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 grub2-orig/util/grub-mkconfig_lib.in grub2-new/util/grub-mkconfig_lib.in
+--- grub2-orig/util/grub-mkconfig_lib.in 2010-01-28 15:01:46.740383831 +0100
++++ grub2-new/util/grub-mkconfig_lib.in 2010-01-28 15:38:10.474013430 +0100
+@@ -188,3 +188,65 @@
+ done
+ echo "$a"
+ }
++
++legacy_find_root_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_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"
++}
++