nalika / rpms / grub2

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