I've tried manually specifying a boot device, by editing the menu items
while in the grub menu - to confirm that it works before tackling
propagation. And I just confirmed it again - no, none of them work.
I manually change "search --no-floppy --set=root --fs-uuid ..." to
"<...> --label my\ label", and "linux <...> root=UUID=..." to "linux
<...> root=LABEL=my\ label". The boot process stops at "No root device
specified. Boot arguments must include a root= parameter".
root= is not handled by GRUB but by kernel. You need to consult separately with kernel and initramfs scripts on how to handle it and it's separate from handling search line.
But even if whitespace works, there is still an issue with all the other
possible symbols. Which are also escaped differently in
/dev/disk/by-label/ . So to keep the scope of the change to a minimum, I
suggest a "label is only supported with no weird stuff in it" approach.
That is the road to creating unbootable system. It's better not to push such a risk to the distros.
On 27/09/23 19:22, Vladimir 'phcoder' Serbinenko wrote:
>
>
> Le mer. 27 sept. 2023, 08:52, darkpenguin <darkpenguin@posteo.de
> <mailto:darkpenguin@posteo.de>> a écrit :
>
> Here is an updated patch that uses GRUB_ENABLE_LINUX_LABEL=true instead.
>
> Supporting whitespace or other symbols in the label doesn't make sense
> until we can figure out how to properly specify them in grub.cfg - so
> far, nothing I've tried works (escaping, quoting, %20, \x20).
>
> Escaping and quoting both work as long as escaping/quoting is propagated
> to actual generated grub.cfg
>
>
>
> ---
> diff --git a/util/grub-mkconfig.in <http://grub-mkconfig.in>
> b/util/grub-mkconfig.in <http://grub-mkconfig.in>
> index 32c480dae..fb5000d3f 100644
> --- a/util/grub-mkconfig.in <http://grub-mkconfig.in>
> +++ b/util/grub-mkconfig.in <http://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 <http://grub-mkconfig_lib.in>
> b/util/grub-mkconfig_lib.in <http://grub-mkconfig_lib.in>
> index 08953287c..dd726c4b3 100644
> --- a/util/grub-mkconfig_lib.in <http://grub-mkconfig_lib.in>
> +++ b/util/grub-mkconfig_lib.in <http://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)"
> + else
> + device="--fs-uuid ${fs_uuid}"
> + fi
> +
> if [ "x$hints" != x ]; then
> echo "if [ x\$feature_platform_search_hint = xy ]; then"
> - echo " search --no-floppy --fs-uuid --set=root ${hints}
> ${fs_uuid}"
> + echo " search --no-floppy --set=root ${hints} ${device}"
> echo "else"
> - echo " search --no-floppy --fs-uuid --set=root ${fs_uuid}"
> + echo " search --no-floppy --set=root ${device}"
> echo "fi"
> else
> - echo "search --no-floppy --fs-uuid --set=root ${fs_uuid}"
> + echo "search --no-floppy --set=root ${device}"
> fi
> fi
> IFS="$old_ifs"
> diff --git a/util/grub.d/10_linux.in <http://10_linux.in>
> b/util/grub.d/10_linux.in <http://10_linux.in>
> index cc393be7e..04b973fe7 100644
> --- a/util/grub.d/10_linux.in <http://10_linux.in>
> +++ b/util/grub.d/10_linux.in <http://10_linux.in>
> @@ -61,6 +61,9 @@ if ( [ "x${GRUB_DEVICE_UUID}" = "x" ] && [
> "x${GRUB_DEVICE_PARTUUID}" = "x" ] )
> elif [ "x${GRUB_DEVICE_UUID}" = "x" ] \
> || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ]; then
> LINUX_ROOT_DEVICE=PARTUUID=${GRUB_DEVICE_PARTUUID}
> +elif [ "x${GRUB_ENABLE_LINUX_LABEL}" = "xtrue" ] \
> + && [ -b "/dev/disk/by-label/$(blkid -l -t UUID=${GRUB_DEVICE_UUID}
> -s LABEL -o value)" ]; then
> + LINUX_ROOT_DEVICE=LABEL="$(blkid -l -t UUID=${GRUB_DEVICE_UUID} -s
> LABEL -o value)"
> else
> LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}
> fi
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org <mailto:Grub-devel@gnu.org>
> https://lists.gnu.org/mailman/listinfo/grub-devel
>
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
>
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel