grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Allow specifying the boot device by its label instead of UUI


From: Vladimir 'phcoder' Serbinenko
Subject: Re: [PATCH] Allow specifying the boot device by its label instead of UUID
Date: Wed, 27 Sep 2023 22:41:07 +0200



Le mer. 27 sept. 2023, 18:26, darkpenguin <darkpenguin@posteo.de> a écrit :
Here it is, as a single patch, and in reply to the corresponding thread this time!

---
 util/grub-mkconfig.in     |  1 +
 util/grub-mkconfig_lib.in | 14 +++++++++++---
 util/grub.d/10_linux.in   |  3 +++
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in
index 32c480dae..fb5000d3f 100644
--- a/util/grub-mkconfig.in
+++ b/util/grub-mkconfig.in
@@ -244,6 +244,7 @@ export GRUB_DEFAULT \
   GRUB_DISABLE_UUID \
   GRUB_DISABLE_LINUX_UUID \
   GRUB_DISABLE_LINUX_PARTUUID \
+  GRUB_ENABLE_LINUX_LABEL \
   GRUB_DISABLE_RECOVERY \
   GRUB_VIDEO_BACKEND \
   GRUB_GFXMODE \
diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in
index 08953287c..dd726c4b3 100644
--- a/util/grub-mkconfig_lib.in
+++ b/util/grub-mkconfig_lib.in
@@ -158,14 +158,22 @@ prepare_grub_to_access_device ()
   fi
   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=
+
+    if [ "x${GRUB_ENABLE_LINUX_LABEL}" = "xtrue" ] \
+        && [ -b "/dev/disk/by-label/$(blkid -l -t UUID=${fs_uuid} -s LABEL -o value)" ]; then
+      device="--label $(blkid -l -t UUID=${fs_uuid} -s LABEL -o value)"

When you're outputting labels please avoid using UUIDs for anything. One use case for labels is when for some reason you have 2 filesystems with the same UUID but different labels. Granted this is a rare use case but if we go label route at all we can cover it as well. You already have the name of the device node, so you can just use it.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]