nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/0015-Add-GRUB_DISABLE_UUID.patch

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