I've implemented the feature so grub-mkconfig is able to use root=LABEL=xxxx as kernel parameter to identify the root filesystem and posted to https://savannah.gnu.org/bugs/index.php?66300 as bugreport.

In order to ease the implementation process I am communicating it to the development mailing list and also attaching here the patch also.


Can this change be kindly accepted? There are a lot of internet resources for users trying to implement this procedure and even report that users modify /boot/grub/grub.cfg file manually to achieve this.

Thanks.

BTW: CC me as I am not subscribed to the list, thanks.

From 7eeef13b492ec3d91c3b6c49653fab95a27f4792 Mon Sep 17 00:00:00 2001
From: "David C. Manuelda" <stormb...@gmail.com>
Date: Tue, 8 Oct 2024 13:04:54 +0200
Subject: [PATCH] Introduce grub-mkconfig filesystem label support:

This feature will allow grub-mkconfig to be able to identify root
filesystem via label kernel parameter (root=LABEL=xxxx). To enable
this feature, UUIDs and PARTUUIDs needs to be disabled (with
GRUB_DISABLE_LINUX_UUID and GRUB_DISABLE_LINUX_PARTUUID set to true)
and the newly introduced variable GRUB_DISABLE_LINUX_LABEL set to false.

To maintain compatibility with older kernels and existing configs
the default value for GRUB_DISABLE_LINUX_LABEL is true so unless
this value is changed the current functionality is not affected.

Signed-off-by: David C. Manuelda <stormb...@gmail.com>
---
 docs/grub.texi          |  7 +++++++
 util/grub-mkconfig.in   |  2 ++
 util/grub.d/10_linux.in | 29 +++++++++++++++++++++--------
 3 files changed, 30 insertions(+), 8 deletions(-)

diff --git a/docs/grub.texi b/docs/grub.texi
index 2ea6c56d1..4ecb708ae 100644
--- a/docs/grub.texi
+++ b/docs/grub.texi
@@ -1499,6 +1499,13 @@ Linux device names. When @samp{GRUB_DISABLE_LINUX_PARTUUID} is set to
 the MSDOS partition scheme) or newer.  This option defaults to @samp{true}.  To
 enable the use of partition UUIDs, set this option to @samp{false}.
 
+@item GRUB_DISABLE_LINUX_LABEL
+@command{grub-mkconfig} can pick labels to identify root filesystem to the Linux
+kernel via a @samp{root=LABEL=...} kernel parameter. To enable it disable both
+@samp{GRUB_DISABLE_LINUX_UUID} and @samp{GRUB_DISABLE_LINUX_PARTUUID} with
+a @samp{true} value and set this option to @samp{false}. To maintain compatibility
+with older kernels this option defaults to @samp{true}.
+
 @item GRUB_DISABLE_RECOVERY
 If this option is set to @samp{true}, disable the generation of recovery
 mode menu entries.
diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in
index 32c480dae..ed670ffcc 100644
--- a/util/grub-mkconfig.in
+++ b/util/grub-mkconfig.in
@@ -202,6 +202,7 @@ if [ "x${GRUB_ACTUAL_DEFAULT}" = "xsaved" ] ; then GRUB_ACTUAL_DEFAULT="`"${grub
 export GRUB_DEVICE \
   GRUB_DEVICE_UUID \
   GRUB_DEVICE_PARTUUID \
+  GRUB_DEVICE_LABEL \
   GRUB_DEVICE_BOOT \
   GRUB_DEVICE_BOOT_UUID \
   GRUB_DISABLE_OS_PROBER \
@@ -244,6 +245,7 @@ export GRUB_DEFAULT \
   GRUB_DISABLE_UUID \
   GRUB_DISABLE_LINUX_UUID \
   GRUB_DISABLE_LINUX_PARTUUID \
+  GRUB_DISABLE_LINUX_LABEL \
   GRUB_DISABLE_RECOVERY \
   GRUB_VIDEO_BACKEND \
   GRUB_GFXMODE \
diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
index cc393be7e..bc14056f2 100644
--- a/util/grub.d/10_linux.in
+++ b/util/grub.d/10_linux.in
@@ -45,24 +45,37 @@ esac
 
 : ${GRUB_CMDLINE_LINUX_RECOVERY:=single}
 
-# Default to disabling partition uuid support to maintian compatibility with
+# Default to disabling partition uuid support to maintain compatibility with
 # older kernels.
 : ${GRUB_DISABLE_LINUX_PARTUUID=true}
 
+# Default to disabling partition label support to maintain compatibility with
+# older kernels.
+: ${GRUB_DISABLE_LINUX_LABEL=true}
+
 # btrfs may reside on multiple devices. We cannot pass them as value of root= parameter
 # and mounting btrfs requires user space scanning, so force UUID in this case.
-if ( [ "x${GRUB_DEVICE_UUID}" = "x" ] && [ "x${GRUB_DEVICE_PARTUUID}" = "x" ] ) \
+if ( [ "x${GRUB_DEVICE_UUID}" = "x" ] && [ "x${GRUB_DEVICE_PARTUUID}" = "x" ] && [ "x${GRUB_DEVICE_LABEL}" = "x" ] ) \
     || ( [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \
-	&& [ "x${GRUB_DISABLE_LINUX_PARTUUID}" = "xtrue" ] ) \
+	&& [ "x${GRUB_DISABLE_LINUX_PARTUUID}" = "xtrue" ] \
+    && [ "x${GRUB_DISABLE_LINUX_LABEL}" = "xtrue" ] ) \
     || ( ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \
-	&& ! test -e "/dev/disk/by-partuuid/${GRUB_DEVICE_PARTUUID}" ) \
+	&& ! test -e "/dev/disk/by-partuuid/${GRUB_DEVICE_PARTUUID}" \
+	&& ! test -e "/dev/disk/by-label/${GRUB_DEVICE_LABEL}" ) \
     || ( test -e "${GRUB_DEVICE}" && uses_abstraction "${GRUB_DEVICE}" lvm ); then
   LINUX_ROOT_DEVICE=${GRUB_DEVICE}
-elif [ "x${GRUB_DEVICE_UUID}" = "x" ] \
-    || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ]; then
-  LINUX_ROOT_DEVICE=PARTUUID=${GRUB_DEVICE_PARTUUID}
 else
-  LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}
+  if ( [ "x${GRUB_DEVICE_UUID}" = "x" ] \
+      || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] ); then
+    if ( [ "x${GRUB_DEVICE_PARTUUID}" = "x" ] \
+      || [ "x${GRUB_DISABLE_LINUX_PARTUUID}" = "xtrue" ] ); then
+      LINUX_ROOT_DEVICE=LABEL=${GRUB_DEVICE_LABEL}
+    else
+      LINUX_ROOT_DEVICE=PARTUUID=${GRUB_DEVICE_PARTUUID}
+    fi
+  else
+      LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}
+  fi
 fi
 
 case x"$GRUB_FS" in
-- 
2.46.2

Attachment: OpenPGP_0x813A1725FA18B780.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to