nalika / rpms / grub2

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