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