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