Skip to contentSkip to conversation

Add GRUB_DISABLE_UUID

PATCH In review Javier Martinez Canillas 3 participants 4 messages Oct 22, 2019 – Oct 24, 2019

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 Add GRUB_DISABLE_UUID

From: Peter Jones <[email protected]>

The grub-mkconfig and 10_linux scripts by default attempt to use a UUID to set the root kernel command line parameter and the $root GRUB environment variable.

The former can be disabled by setting the GRUB_DISABLE_LINUX_UUID variable to "true", but there is currently no way to disable the latter.

The generated grub config uses the search command with the --fs-uuid option to find the device that has to be set as $root, i.e:

search --no-floppy --fs-uuid --set=root ...

This is usually more reliable but in some cases it may not be appropriate, so this patch introduces a new GRUB_DISABLE_UUID variable that can be used to disable searching for the $root device by filesystem UUID.

When disabled, the $root device will be set to the value specified in the device.map as found by the grub-probe --target=compatibility_hint option.

When setting GRUB_DISABLE_UUID=true, the GRUB_DISABLE_LINUX_UUID and GRUB_DISABLE_LINUX_PARTUUID variables will also be set to "true" unless these have been explicitly set to "false".

That way, the GRUB_DISABLE_UUID variable can be used to force using the device names for both GRUB and Linux.

---

Changes in v3:
- Make the patch more consistent with the logic in commit 51be3372ec8 ("templates: Update grub script template files").
- Add Reviewed-by tag from Daniel Kiper.

Changes in v2:
- Explain better in the commit message why the GRUB_DISABLE_UUID variable is needed and the difference with the existing GRUB_DISABLE_LINUX_UUID/ GRUB_DISABLE_LINUX_PARTUUID variables.
- Remove logic that disabled setting the root cmdline param to either the filesystem UUID or partition UUID and instead use the existing variables to disable this.

 docs/grub.texi            |  9 +++++++++
 util/grub-mkconfig.in     | 10 ++++++++++
 util/grub-mkconfig_lib.in |  4 ++--
 3 files changed, 21 insertions(+), 2 deletions(-)
docs/grub.texi +9 -0
index d788efe440f..c25ab7a5fe7 100644
@@ -1441,6 +1441,15 @@ enable the use of partition UUIDs, set this option to @samp{false}.
 If this option is set to @samp{true}, disable the generation of recovery
 mode menu entries.
 
+@item GRUB_DISABLE_UUID
+Normally, @command{grub-mkconfig} will generate menu entries that use
+universally-unique identifiers (UUIDs) to identify various filesystems to
+search for files.  This is usually more reliable, but in some cases it may
+not be appropriate.  To disable this use of UUIDs, set this option to
+@samp{true}. Setting this option to @samp{true}, will also set the options
+@samp{GRUB_DISABLE_LINUX_UUID} and @samp{GRUB_DISABLE_LINUX_PARTUUID} to
+@samp{true}, unless they have been explicilty set to @samp{false}.
+
 @item GRUB_VIDEO_BACKEND
 If graphical video support is required, either because the @samp{gfxterm}
 graphical terminal is in use or because @samp{GRUB_GFXPAYLOAD_LINUX} is set,
util/grub-mkconfig.in +10 -0
index a6ce375ed18..fb7fd4902f4 100644
@@ -158,6 +158,15 @@ if test -f ${sysconfdir}/default/grub ; then
   . ${sysconfdir}/default/grub
 fi
 
+if [ "x${GRUB_DISABLE_UUID}" = "xtrue" ]; then
+  if [ -z "${GRUB_DISABLE_LINUX_UUID}" ]; then
+    GRUB_DISABLE_LINUX_UUID="true"
+  fi
+  if [ -z "${GRUB_DISABLE_LINUX_PARTUUID}" ]; then
+    GRUB_DISABLE_LINUX_PARTUUID="true"
+  fi
+fi
+
 # XXX: should this be deprecated at some point?
 if [ "x${GRUB_TERMINAL}" != "x" ] ; then
   GRUB_TERMINAL_INPUT="${GRUB_TERMINAL}"
@@ -227,6 +236,7 @@ export GRUB_DEFAULT \
   GRUB_DISABLE_LINUX_UUID \
   GRUB_DISABLE_LINUX_PARTUUID \
   GRUB_DISABLE_RECOVERY \
+  GRUB_DISABLE_UUID \
   GRUB_VIDEO_BACKEND \
   GRUB_GFXMODE \
   GRUB_BACKGROUND \
util/grub-mkconfig_lib.in +2 -2
index 0f801cab3e4..3e12b2c0e6a 100644
@@ -156,7 +156,7 @@ prepare_grub_to_access_device ()
   if [ "x$fs_hint" != x ]; then
     echo "set root='$fs_hint'"
   fi
-  if fs_uuid="`"${grub_probe}" --device $@ --target=fs_uuid 2> /dev/null`" ; then
+  if [ "x${GRUB_DISABLE_UUID}" != "xtrue" ] && fs_uuid="`"${grub_probe}" --device $@ --target=fs_uuid 2> /dev/null`" ; then
     hints="`"${grub_probe}" --device $@ --target=hints_string 2> /dev/null`" || hints=
     echo "if [ x\$feature_platform_search_hint = xy ]; then"
     echo "  search --no-floppy --fs-uuid --set=root ${hints} ${fs_uuid}"
@@ -173,7 +173,7 @@ grub_get_device_id ()
   IFS='
 '
   device="$1"
-  if fs_uuid="`"${grub_probe}" --device ${device} --target=fs_uuid 2> /dev/null`" ; then
+  if [ "x${GRUB_DISABLE_UUID}" != "xtrue" ] && fs_uuid="`"${grub_probe}" --device ${device} --target=fs_uuid 2> /dev/null`" ; then
     echo "$fs_uuid";
   else
     echo $device |sed 's, ,_,g'
Signature · 1 line
2.21.0
#1 lore raw

Adding Nicholas...

Quoted 25 lines · Javier Martinez Canillas

From: Peter Jones <[email protected]>

The grub-mkconfig and 10_linux scripts by default attempt to use a UUID to set the root kernel command line parameter and the $root GRUB environment variable.

The former can be disabled by setting the GRUB_DISABLE_LINUX_UUID variable to "true", but there is currently no way to disable the latter.

The generated grub config uses the search command with the --fs-uuid option to find the device that has to be set as $root, i.e:

search --no-floppy --fs-uuid --set=root ...

This is usually more reliable but in some cases it may not be appropriate, so this patch introduces a new GRUB_DISABLE_UUID variable that can be used to disable searching for the $root device by filesystem UUID.

When disabled, the $root device will be set to the value specified in the device.map as found by the grub-probe --target=compatibility_hint option.

When setting GRUB_DISABLE_UUID=true, the GRUB_DISABLE_LINUX_UUID and GRUB_DISABLE_LINUX_PARTUUID variables will also be set to "true" unless these have been explicitly set to "false".

Quoted 6 lines

That way, the GRUB_DISABLE_UUID variable can be used to force using the device names for both GRUB and Linux.

Nicholas, are you OK with that patch right now? If yes and you could add your RB that would be perfect.

Quoted 61 lines

---

Changes in v3:
- Make the patch more consistent with the logic in commit 51be3372ec8 ("templates: Update grub script template files").
- Add Reviewed-by tag from Daniel Kiper.

Changes in v2:
- Explain better in the commit message why the GRUB_DISABLE_UUID variable is needed and the difference with the existing GRUB_DISABLE_LINUX_UUID/ GRUB_DISABLE_LINUX_PARTUUID variables.
- Remove logic that disabled setting the root cmdline param to either the filesystem UUID or partition UUID and instead use the existing variables to disable this.

 docs/grub.texi            |  9 +++++++++
 util/grub-mkconfig.in     | 10 ++++++++++
 util/grub-mkconfig_lib.in |  4 ++--
 3 files changed, 21 insertions(+), 2 deletions(-)
docs/grub.texi +9 -0
index d788efe440f..c25ab7a5fe7 100644
@@ -1441,6 +1441,15 @@ enable the use of partition UUIDs, set this option to @samp{false}.
 If this option is set to @samp{true}, disable the generation of recovery
 mode menu entries.
 
+@item GRUB_DISABLE_UUID
+Normally, @command{grub-mkconfig} will generate menu entries that use
+universally-unique identifiers (UUIDs) to identify various filesystems to
+search for files.  This is usually more reliable, but in some cases it may
+not be appropriate.  To disable this use of UUIDs, set this option to
+@samp{true}. Setting this option to @samp{true}, will also set the options
+@samp{GRUB_DISABLE_LINUX_UUID} and @samp{GRUB_DISABLE_LINUX_PARTUUID} to
+@samp{true}, unless they have been explicilty set to @samp{false}.
+
 @item GRUB_VIDEO_BACKEND
 If graphical video support is required, either because the @samp{gfxterm}
 graphical terminal is in use or because @samp{GRUB_GFXPAYLOAD_LINUX} is set,
util/grub-mkconfig.in +9 -0
index a6ce375ed18..fb7fd4902f4 100644
@@ -158,6 +158,15 @@ if test -f ${sysconfdir}/default/grub ; then
   . ${sysconfdir}/default/grub
 fi
 
+if [ "x${GRUB_DISABLE_UUID}" = "xtrue" ]; then
+  if [ -z "${GRUB_DISABLE_LINUX_UUID}" ]; then
+    GRUB_DISABLE_LINUX_UUID="true"
+  fi
+  if [ -z "${GRUB_DISABLE_LINUX_PARTUUID}" ]; then
+    GRUB_DISABLE_LINUX_PARTUUID="true"
+  fi
+fi
+
 # XXX: should this be deprecated at some point?
 if [ "x${GRUB_TERMINAL}" != "x" ] ; then
   GRUB_TERMINAL_INPUT="${GRUB_TERMINAL}"

util/grub-mkconfig.in export GRUB_DEFAULT \ · line 239

Quoted 4 lines
util/grub-mkconfig.in +1 -0
@@ -227,6 +236,7 @@ export GRUB_DEFAULT \
   GRUB_DISABLE_LINUX_UUID \
   GRUB_DISABLE_LINUX_PARTUUID \
   GRUB_DISABLE_RECOVERY \
+  GRUB_DISABLE_UUID \

I will move this before GRUB_DISABLE_LINUX_UUID before committing. I hope this is not a problem for you.

Daniel

#2 lore raw
Quoted 2 lines · Daniel Kiper

Adding Nicholas...

I thought that updated my CC list adding him but that wasn't the case...

Quoted 96 lines · Javier Martinez Canillas
Quoted 25 lines

From: Peter Jones <[email protected]>

The grub-mkconfig and 10_linux scripts by default attempt to use a UUID to set the root kernel command line parameter and the $root GRUB environment variable.

The former can be disabled by setting the GRUB_DISABLE_LINUX_UUID variable to "true", but there is currently no way to disable the latter.

The generated grub config uses the search command with the --fs-uuid option to find the device that has to be set as $root, i.e:

search --no-floppy --fs-uuid --set=root ...

This is usually more reliable but in some cases it may not be appropriate, so this patch introduces a new GRUB_DISABLE_UUID variable that can be used to disable searching for the $root device by filesystem UUID.

When disabled, the $root device will be set to the value specified in the device.map as found by the grub-probe --target=compatibility_hint option.

When setting GRUB_DISABLE_UUID=true, the GRUB_DISABLE_LINUX_UUID and GRUB_DISABLE_LINUX_PARTUUID variables will also be set to "true" unless these have been explicitly set to "false".

Quoted 6 lines

That way, the GRUB_DISABLE_UUID variable can be used to force using the device names for both GRUB and Linux.

Nicholas, are you OK with that patch right now? If yes and you could add your RB that would be perfect.

Quoted 60 lines

---

Changes in v3:
- Make the patch more consistent with the logic in commit 51be3372ec8 ("templates: Update grub script template files").
- Add Reviewed-by tag from Daniel Kiper.

Changes in v2:
- Explain better in the commit message why the GRUB_DISABLE_UUID variable is needed and the difference with the existing GRUB_DISABLE_LINUX_UUID/ GRUB_DISABLE_LINUX_PARTUUID variables.
- Remove logic that disabled setting the root cmdline param to either the filesystem UUID or partition UUID and instead use the existing variables to disable this.

 docs/grub.texi            |  9 +++++++++
 util/grub-mkconfig.in     | 10 ++++++++++
 util/grub-mkconfig_lib.in |  4 ++--
 3 files changed, 21 insertions(+), 2 deletions(-)
docs/grub.texi +9 -0
index d788efe440f..c25ab7a5fe7 100644
@@ -1441,6 +1441,15 @@ enable the use of partition UUIDs, set this option to @samp{false}.
 If this option is set to @samp{true}, disable the generation of recovery
 mode menu entries.
 
+@item GRUB_DISABLE_UUID
+Normally, @command{grub-mkconfig} will generate menu entries that use
+universally-unique identifiers (UUIDs) to identify various filesystems to
+search for files.  This is usually more reliable, but in some cases it may
+not be appropriate.  To disable this use of UUIDs, set this option to
+@samp{true}. Setting this option to @samp{true}, will also set the options
+@samp{GRUB_DISABLE_LINUX_UUID} and @samp{GRUB_DISABLE_LINUX_PARTUUID} to
+@samp{true}, unless they have been explicilty set to @samp{false}.
+
 @item GRUB_VIDEO_BACKEND
 If graphical video support is required, either because the @samp{gfxterm}
 graphical terminal is in use or because @samp{GRUB_GFXPAYLOAD_LINUX} is set,
util/grub-mkconfig.in +9 -0
index a6ce375ed18..fb7fd4902f4 100644
@@ -158,6 +158,15 @@ if test -f ${sysconfdir}/default/grub ; then
   . ${sysconfdir}/default/grub
 fi
 
+if [ "x${GRUB_DISABLE_UUID}" = "xtrue" ]; then
+  if [ -z "${GRUB_DISABLE_LINUX_UUID}" ]; then
+    GRUB_DISABLE_LINUX_UUID="true"
+  fi
+  if [ -z "${GRUB_DISABLE_LINUX_PARTUUID}" ]; then
+    GRUB_DISABLE_LINUX_PARTUUID="true"
+  fi
+fi
+
 # XXX: should this be deprecated at some point?
 if [ "x${GRUB_TERMINAL}" != "x" ] ; then
   GRUB_TERMINAL_INPUT="${GRUB_TERMINAL}"
Quoted 9 lines

util/grub-mkconfig.in export GRUB_DEFAULT \ · line 239

Quoted 5 lines
util/grub-mkconfig.in +1 -0
@@ -227,6 +236,7 @@ export GRUB_DEFAULT \
   GRUB_DISABLE_LINUX_UUID \
   GRUB_DISABLE_LINUX_PARTUUID \
   GRUB_DISABLE_RECOVERY \
+  GRUB_DISABLE_UUID \

I will move this before GRUB_DISABLE_LINUX_UUID before committing. I hope this is not a problem for you.

Yes, I'm OK with that. Thanks.

Quoted 2 lines

Daniel

Best regards,

Signature · 3 lines
Javier Martinez Canillas
Software Engineer - Desktop Hardware Enablement
Red Hat
#3 lore raw
In reply to Daniel Kiper
Quoted 31 lines · Daniel Kiper

Adding Nicholas...

Quoted 28 lines · Javier Martinez Canillas

From: Peter Jones <[email protected]>

The grub-mkconfig and 10_linux scripts by default attempt to use a UUID to set the root kernel command line parameter and the $root GRUB environment variable.

The former can be disabled by setting the GRUB_DISABLE_LINUX_UUID variable to "true", but there is currently no way to disable the latter.

The generated grub config uses the search command with the --fs-uuid option to find the device that has to be set as $root, i.e:

search --no-floppy --fs-uuid --set=root ...

This is usually more reliable but in some cases it may not be appropriate, so this patch introduces a new GRUB_DISABLE_UUID variable that can be used to disable searching for the $root device by filesystem UUID.

When disabled, the $root device will be set to the value specified in the device.map as found by the grub-probe --target=compatibility_hint option.

When setting GRUB_DISABLE_UUID=true, the GRUB_DISABLE_LINUX_UUID and GRUB_DISABLE_LINUX_PARTUUID variables will also be set to "true" unless these have been explicitly set to "false".

That way, the GRUB_DISABLE_UUID variable can be used to force using the device names for both GRUB and Linux.

Quoted 6 lines
Quoted 3 lines

Nicholas, are you OK with that patch right now? If yes and you could add your RB that would be perfect.

I don't see any issues. Looks good to me.

"Reviewed-by: Nicholas Vinson <[email protected]>"

Thanks,
Nicholas Vinson

Quoted 77 lines
Quoted 62 lines

---

Changes in v3:
- Make the patch more consistent with the logic in commit 51be3372ec8 ("templates: Update grub script template files").
- Add Reviewed-by tag from Daniel Kiper.

Changes in v2:
- Explain better in the commit message why the GRUB_DISABLE_UUID variable is needed and the difference with the existing GRUB_DISABLE_LINUX_UUID/ GRUB_DISABLE_LINUX_PARTUUID variables.
- Remove logic that disabled setting the root cmdline param to either the filesystem UUID or partition UUID and instead use the existing variables to disable this.

  docs/grub.texi            |  9 +++++++++
  util/grub-mkconfig.in     | 10 ++++++++++
  util/grub-mkconfig_lib.in |  4 ++--
  3 files changed, 21 insertions(+), 2 deletions(-)
docs/grub.texi +9 -0
index d788efe440f..c25ab7a5fe7 100644
@@ -1441,6 +1441,15 @@ enable the use of partition UUIDs, set this option to @samp{false}.
  If this option is set to @samp{true}, disable the generation of recovery
  mode menu entries.
 
+@item GRUB_DISABLE_UUID
+Normally, @command{grub-mkconfig} will generate menu entries that use
+universally-unique identifiers (UUIDs) to identify various filesystems to
+search for files.  This is usually more reliable, but in some cases it may
+not be appropriate.  To disable this use of UUIDs, set this option to
+@samp{true}. Setting this option to @samp{true}, will also set the options
+@samp{GRUB_DISABLE_LINUX_UUID} and @samp{GRUB_DISABLE_LINUX_PARTUUID} to
+@samp{true}, unless they have been explicilty set to @samp{false}.
+
  @item GRUB_VIDEO_BACKEND
  If graphical video support is required, either because the @samp{gfxterm}
  graphical terminal is in use or because @samp{GRUB_GFXPAYLOAD_LINUX} is set,
util/grub-mkconfig.in +9 -0
index a6ce375ed18..fb7fd4902f4 100644
@@ -158,6 +158,15 @@ if test -f ${sysconfdir}/default/grub ; then
    . ${sysconfdir}/default/grub
  fi
 
+if [ "x${GRUB_DISABLE_UUID}" = "xtrue" ]; then
+  if [ -z "${GRUB_DISABLE_LINUX_UUID}" ]; then
+    GRUB_DISABLE_LINUX_UUID="true"
+  fi
+  if [ -z "${GRUB_DISABLE_LINUX_PARTUUID}" ]; then
+    GRUB_DISABLE_LINUX_PARTUUID="true"
+  fi
+fi
+
  # XXX: should this be deprecated at some point?
  if [ "x${GRUB_TERMINAL}" != "x" ] ; then
    GRUB_TERMINAL_INPUT="${GRUB_TERMINAL}"

util/grub-mkconfig.in export GRUB_DEFAULT \ · line 239

Quoted 4 lines
util/grub-mkconfig.in +1 -0
@@ -227,6 +236,7 @@ export GRUB_DEFAULT \
    GRUB_DISABLE_LINUX_UUID \
    GRUB_DISABLE_LINUX_PARTUUID \
    GRUB_DISABLE_RECOVERY \
+  GRUB_DISABLE_UUID \

I will move this before GRUB_DISABLE_LINUX_UUID before committing. I hope this is not a problem for you.

Daniel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel