6b2dd0f
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
f4c76c0
From: Peter Jones <pjones@redhat.com>
f4c76c0
Date: Thu, 4 Sep 2014 16:49:25 -0400
31cddd6
Subject: [PATCH] Add GRUB_DISABLE_UUID.
f4c76c0
f4c76c0
This will cause "search --fs-uuid --set=root ..." not to be generated by
f4c76c0
grub2-mkconfig, and instead simply attempt to use the grub device name
f4c76c0
as it understands it.
f4c76c0
f4c76c0
Signed-off-by: Peter Jones <pjones@redhat.com>
f4c76c0
---
f4c76c0
 docs/grub.texi            |  7 +++++++
752ceb1
 util/grub-mkconfig.in     | 22 +++++++++++++++++++---
f4c76c0
 util/grub-mkconfig_lib.in |  4 ++--
752ceb1
 3 files changed, 28 insertions(+), 5 deletions(-)
f4c76c0
f4c76c0
diff --git a/docs/grub.texi b/docs/grub.texi
752ceb1
index 2adfa97bee8..2fd32608c01 100644
f4c76c0
--- a/docs/grub.texi
f4c76c0
+++ b/docs/grub.texi
752ceb1
@@ -1441,6 +1441,13 @@ enable the use of partition UUIDs, set this option to @samp{false}.
f4c76c0
 If this option is set to @samp{true}, disable the generation of recovery
f4c76c0
 mode menu entries.
f4c76c0
 
f4c76c0
+@item GRUB_DISABLE_UUID
f4c76c0
+Normally, @command{grub-mkconfig} will generate menu entries that use
f4c76c0
+universally-unique identifiers (UUIDs) to identify various filesystems to
f4c76c0
+search for files.  This is usually more reliable, but in some cases it may
f4c76c0
+not be appropriate.  To disable this use of UUIDs, set this option to
f4c76c0
+@samp{true}.
f4c76c0
+
f4c76c0
 @item GRUB_VIDEO_BACKEND
f4c76c0
 If graphical video support is required, either because the @samp{gfxterm}
f4c76c0
 graphical terminal is in use or because @samp{GRUB_GFXPAYLOAD_LINUX} is set,
f4c76c0
diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in
752ceb1
index bc5a3f17541..b0a8626dd1c 100644
f4c76c0
--- a/util/grub-mkconfig.in
f4c76c0
+++ b/util/grub-mkconfig.in
752ceb1
@@ -133,12 +133,12 @@ fi
f4c76c0
 
f4c76c0
 # Device containing our userland.  Typically used for root= parameter.
f4c76c0
 GRUB_DEVICE="`${grub_probe} --target=device /`"
f4c76c0
-GRUB_DEVICE_UUID="`${grub_probe} --device ${GRUB_DEVICE} --target=fs_uuid 2> /dev/null`" || true
752ceb1
-GRUB_DEVICE_PARTUUID="`${grub_probe} --device ${GRUB_DEVICE} --target=partuuid 2> /dev/null`" || true
f4c76c0
+GRUB_DEVICE_UUID_GENERATED="`${grub_probe} --device ${GRUB_DEVICE} --target=fs_uuid 2> /dev/null`" || true
752ceb1
+GRUB_DEVICE_PARTUUID_GENERATED="`${grub_probe} --device ${GRUB_DEVICE} --target=partuuid 2> /dev/null`" || true
f4c76c0
 
f4c76c0
 # Device containing our /boot partition.  Usually the same as GRUB_DEVICE.
f4c76c0
 GRUB_DEVICE_BOOT="`${grub_probe} --target=device /boot`"
f4c76c0
-GRUB_DEVICE_BOOT_UUID="`${grub_probe} --device ${GRUB_DEVICE_BOOT} --target=fs_uuid 2> /dev/null`" || true
f4c76c0
+GRUB_DEVICE_BOOT_UUID_GENERATED="`${grub_probe} --device ${GRUB_DEVICE_BOOT} --target=fs_uuid 2> /dev/null`" || true
f4c76c0
 
f4c76c0
 # Filesystem for the device containing our userland.  Used for stuff like
f4c76c0
 # choosing Hurd filesystem module.
752ceb1
@@ -158,6 +158,21 @@ if test -f ${sysconfdir}/default/grub ; then
f4c76c0
   . ${sysconfdir}/default/grub
f4c76c0
 fi
f4c76c0
 
752ceb1
+if [ "x$GRUB_DISABLE_UUID" != "xtrue" ]; then
752ceb1
+  if [ -z "$GRUB_DEVICE_UUID" ]; then
752ceb1
+    GRUB_DEVICE_UUID="$GRUB_DEVICE_UUID_GENERATED"
752ceb1
+  fi
752ceb1
+  if [ -z "$GRUB_DEVICE_BOOT_UUID" ]; then
752ceb1
+    GRUB_DEVICE_BOOT_UUID="$GRUB_DEVICE_BOOT_UUID_GENERATED"
752ceb1
+  fi
752ceb1
+  if [ -z "$GRUB_DEVICE_UUID" ]; then
752ceb1
+    GRUB_DEVICE_UUID="$GRUB_DEVICE_UUID_GENERATED"
752ceb1
+  fi
752ceb1
+  if [ -z "$GRUB_DEVICE_PART_UUID" ]; then
752ceb1
+    GRUB_DEVICE_PART_UUID="$GRUB_DEVICE_PART_UUID_GENERATED"
752ceb1
+  fi
f4c76c0
+fi
f4c76c0
+
f4c76c0
 # XXX: should this be deprecated at some point?
f4c76c0
 if [ "x${GRUB_TERMINAL}" != "x" ] ; then
f4c76c0
   GRUB_TERMINAL_INPUT="${GRUB_TERMINAL}"
752ceb1
@@ -227,6 +242,7 @@ export GRUB_DEFAULT \
f4c76c0
   GRUB_DISABLE_LINUX_UUID \
752ceb1
   GRUB_DISABLE_LINUX_PARTUUID \
f4c76c0
   GRUB_DISABLE_RECOVERY \
f4c76c0
+  GRUB_DISABLE_UUID \
f4c76c0
   GRUB_VIDEO_BACKEND \
f4c76c0
   GRUB_GFXMODE \
f4c76c0
   GRUB_BACKGROUND \
f4c76c0
diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in
752ceb1
index 0f801cab3e4..1001a12232b 100644
f4c76c0
--- a/util/grub-mkconfig_lib.in
f4c76c0
+++ b/util/grub-mkconfig_lib.in
f4c76c0
@@ -156,7 +156,7 @@ prepare_grub_to_access_device ()
f4c76c0
   if [ "x$fs_hint" != x ]; then
f4c76c0
     echo "set root='$fs_hint'"
f4c76c0
   fi
f4c76c0
-  if fs_uuid="`"${grub_probe}" --device $@ --target=fs_uuid 2> /dev/null`" ; then
f4c76c0
+  if [ "x$GRUB_DISABLE_UUID" != "xtrue" ] && fs_uuid="`"${grub_probe}" --device $@ --target=fs_uuid 2> /dev/null`" ; then
f4c76c0
     hints="`"${grub_probe}" --device $@ --target=hints_string 2> /dev/null`" || hints=
f4c76c0
     echo "if [ x\$feature_platform_search_hint = xy ]; then"
f4c76c0
     echo "  search --no-floppy --fs-uuid --set=root ${hints} ${fs_uuid}"
f4c76c0
@@ -173,7 +173,7 @@ grub_get_device_id ()
f4c76c0
   IFS='
f4c76c0
 '
f4c76c0
   device="$1"
f4c76c0
-  if fs_uuid="`"${grub_probe}" --device ${device} --target=fs_uuid 2> /dev/null`" ; then
f4c76c0
+  if [ "x$GRUB_DISABLE_UUID" != "xtrue" ] && fs_uuid="`"${grub_probe}" --device ${device} --target=fs_uuid 2> /dev/null`" ; then
f4c76c0
     echo "$fs_uuid";
f4c76c0
   else
f4c76c0
     echo $device |sed 's, ,_,g'