#2763 PR merged: GRUB2_SEARCH_ROOT_COMMAND variable to overrule Grub2 search string

Labels: enhancement, fixed / solved / done

gdha opened issue at 2022-03-04 15:53:

Signed-off-by: Gratien D'haese gratien.dhaese@gmail.com

Relax-and-Recover (ReaR) Pull Request Template

Please fill in the following items before submitting a new pull request:

Pull Request Details:
  • Type: Enhancement

  • Impact: Normal

  • Reference to related issue (URL): #2500

  • How was this pull request tested? With an EFI USB disk

  • Brief description of the changes in this pull request: The GRUB2_SET_USB_ROOT variable was used locally in script 100_create_efiboot.sh. However, by adding it to the default.conf we are able to overrule the setting which was defined in the 100_create_efiboot.sh script. Now, it can be added to the local.conf file with a more precise setting according the end-user requirements.
    Furthermore, we also introduced the insmod xzio in the grub.conf file in case we were using the REAR_INITRD_COMPRESSION=lzma setting in the local.conf file.

jsmeix commented at 2022-03-07 08:23:

Currently GRUB2_SET_USB_ROOT is used at three places

# find usr/sbin/rear usr/share/rear/ -type f | xargs grep 'GRUB2_SET_USB_ROOT'

usr/share/rear/output/USB/Linux-i386/300_create_grub.sh:
# GRUB2_SET_USB_ROOT is used in the create_grub2_cfg() function:
GRUB2_SET_USB_ROOT="search --no-floppy --set=root --label $USB_DEVICE_BOOT_LABEL"

usr/share/rear/output/USB/Linux-i386/100_create_efiboot.sh:
# GRUB2_SET_USB_ROOT is used in the create_grub2_cfg() function:
GRUB2_SET_USB_ROOT="search --no-floppy --set=root --label $efi_label"

usr/share/rear/lib/bootloader-functions.sh:
test "$GRUB2_SET_USB_ROOT" && grub2_set_root_command="$GRUB2_SET_USB_ROOT"
...
test "$grub2_set_root_command" || grub2_set_root_command="search --no-floppy --set=root --file /boot/efiboot.img"

I wonder if that variable should be really named with _USB_ because
this would mean it can only used in case of OUTPUT=USB
but it seems its actual meaning is
to generally specify the GRUB2 --set=root command
regardless that currently this is maily used for OUTPUT=USB
but the create_grub2_cfg function in lib/bootloader-functions.sh
is currently also called in for OUTPUT=ISO
in output/ISO/Linux-i386/250_populate_efibootimg.sh
so perhaps some more generic GRUB2_SET_ROOT or
GRUB2_SET_ROOT_COMMAND would be a better name?

In general this shows again our currently somewhat messy
recovery system bootloader setup code which needs to be
generally cleaned up and overhauled as a separated task
e.g. see https://github.com/rear/rear/issues/2666
therein in particular item (a)
"Consistent calling of the create_grub2_cfg function in all scripts"
and https://github.com/rear/rear/issues/2648

gdha commented at 2022-03-07 10:30:

@jsmeix I agree it is a messy thing as a result of the many changes over time. However, what I'm trying to fix for the moment is that search --no-floppy --set=root --label REAR-LABEL is not bullet proof enough (at least not with EFI booting).
After many tests I think that search --no-floppy --set=root --file /EFI/BOOT/BOOTX86.efi works best on UEFI based systems (especially with USB booting). The ISO part uses the same method I noticed.
If we want to go for a more generic name then I think that GRUB2_SEARCH_ROOT_COMMAND would even closer to the action? What do you think?

jsmeix commented at 2022-03-07 11:16:

GRUB2_SEARCH_ROOT_COMMAND is perfect
because it describes best what it actually does.


[Export of Github issue for rear/rear.]