Sorry, previous patch was missing support for GRUB_DEVICE_LABEL and therefore it was not working correctly
This is the correct version: From 9a7779989f803b0df8054f77d99dbb75ecd3520f 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. GRUB_DEVICE_LABEL is also added to mkconfig can look for them. 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 | 3 +++ util/grub.d/10_linux.in | 29 +++++++++++++++++++++-------- 3 files changed, 31 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..8f6b866af 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in @@ -135,6 +135,7 @@ fi GRUB_DEVICE="`${grub_probe} --target=device /`" GRUB_DEVICE_UUID="`${grub_probe} --device ${GRUB_DEVICE} --target=fs_uuid 2> /dev/null`" || true GRUB_DEVICE_PARTUUID="`${grub_probe} --device ${GRUB_DEVICE} --target=partuuid 2> /dev/null`" || true +GRUB_DEVICE_LABEL="`${grub_probe} --device ${GRUB_DEVICE} --target=fslabel 2> /dev/null`" || true # Device containing our /boot partition. Usually the same as GRUB_DEVICE. GRUB_DEVICE_BOOT="`${grub_probe} --target=device /boot`" @@ -202,6 +203,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 +246,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 _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel