#2655 PR merged: added grub bootloader for USB

Labels: enhancement, fixed / solved / done

DEvil0000 opened issue at 2021-07-12 17:53:

  • Type: New Feature / Enhancement
  • Impact: Normal
  • Reference to related issue (URL): partially #2648
  • How was this pull request tested?

tested output usb with:

  1. USB_BOOTLOADER=
  2. USB_BOOTLOADER=grub
    on apu2 board (coreboot/seabios) - no efi

  3. Brief description of the changes in this pull request:
    added option to write grub bootloader to usb (no efi)
    it may not be perfect but a good starting point

jsmeix commented at 2021-07-14 09:28:

@DEvil0000
thank you for this very much missing enhancement!

I appreciate the new USB_BOOTLOADER config variable
because - at least for me - it was an endless confusion
what "install a bootloader" actually means in ReaR
because in ReaR there are two separated bootloader install actions:

Installing the bootloader of the ReaR recovery system during "rear mkrescue"
versus
(re)-installing the bootloader of the recreated system during "rear recover".

With clearly named config variables like USB_BOOTLOADER
it is now at least clear what bootloader will be used
for the ReaR recovery system when it is made with OUTPUT=USB

jsmeix commented at 2021-07-19 07:25:

@DEvil0000
if you like and if you agree
I could do my requested changes
directly in your pull request code here.

DEvil0000 commented at 2021-07-19 08:22:

feel free to do changes.
Do you need write access to the branch at PR source?

jsmeix commented at 2021-07-19 08:34:

I have write access - this is why I asked you for permit.
I have write access because the pull request sources
are already within the ReaR upstream GitHub area,
e.g. one of your commits has URL

https://github.com/rear/rear/pull/2655/commits/249a977119251d0ce766aca7bf84514c301acca2

so the pull request sources already belong to
github.com/rear/rear where I have write access.

jsmeix commented at 2021-07-19 11:21:

Strange.
I can no longer change pull request code via the GitHub web interface.
I know I could do this in the past.

@rear/contributors
if there are no objections I would like to merge it as is tomorrow morning and
then I will further adapt and enhance things via a subsequent pull request from me.

Because USB_BOOTLOADER is a new config variable
we are free to implement how it should behave.

Currently I am thinking about something like:

  • USB_BOOTLOADER empty or unset (the default): Automatism what USB bootloader is used
  • USB_BOOTLOADER="extlinux": Enforce using syslinux/extlinux as USB bootloader
  • USB_BOOTLOADER="grub": Enforce using grub2 as USB bootloader
  • USB_BOOTLOADER="efi": Enforce EFI boot for USB

This is currently only some offhanded idea...

DEvil0000 commented at 2021-07-19 12:20:

keep in mind that efi is not very specific - it may be used with different bootloaders and efi payloads and so on.

jsmeix commented at 2021-07-19 12:36:

Yes, I have had a look at output/USB/Linux-i386/100_create_efiboot.sh
and because of what I saw there I intentionally proposed the unspecific

  • USB_BOOTLOADER="efi": Enforce EFI boot for USB

to basically run output/USB/Linux-i386/100_create_efiboot.sh as is.

If needed we may later further enhance things like

  • USB_BOOTLOADER="efi": Enforce EFI boot for USB (automatism what bootloader is used)
  • USB_BOOTLOADER="efi grub": Enforce EFI boot for USB with grub2 as bootloader
  • USB_BOOTLOADER="efi elilo": Enforce EFI boot for USB with elilo as bootloader

jsmeix commented at 2021-07-19 13:01:

I think EFI boot setup and BIOS boot setup
would normally exclude each other
but I fail to see how
output/USB/Linux-i386/100_create_efiboot.sh
and
output/USB/Linux-i386/300_create_extlinux.sh
exclude each other.

What I can see is that output/USB/Linux-i386/100_create_efiboot.sh
is only run when USING_UEFI_BOOTLOADER is true
but I fail to see how output/USB/Linux-i386/300_create_extlinux.sh
is not run when USING_UEFI_BOOTLOADER is true.

So - as far as I can currently see from plain looking at the code - it seems
output/USB/Linux-i386/300_create_extlinux.sh
is run in any case - in particular also on systems with UEFI firmware.

I wonder if that makes sense?

DEvil0000 commented at 2021-07-20 08:26:

I did not test or change that configuration combination / path in software.

There may be good reasons for this. In case of elilo.efi it does not run the grub config part in 100_create_efiboot.sh what makes me believe this case needs some syslinux/extlinux config then.
Also there is still the option of creating a boot device which can boot from legacy bios and efi method but I think thats not what was intended here. I am however not familiar with this.

jsmeix commented at 2021-07-20 14:09:

@DEvil0000
in your output/USB/Linux-i386/300_create_grub.sh there is

USB_REAR_DIR="$BUILD_DIR/outputfs/$USB_PREFIX"
if [ ! -d "$USB_REAR_DIR" ]; then
    mkdir -p $v "$USB_REAR_DIR" >/dev/null || Error "Could not create USB ReaR dir [$USB_REAR_DIR] !"
fi

but it seems USB_REAR_DIR is nowhere used
so I would like to know why that directory is created there
i.e. what the reason behind is why that directory is created?

USB_REAR_DIR also appears in output/USB/Linux-i386/300_create_extlinux.sh
but there it is used to write syslinux things there.

Is creating USB_REAR_DIR in output/USB/Linux-i386/300_create_grub.sh
perhaps only an obsolete leftover from some copy&paste?

DEvil0000 commented at 2021-07-21 11:10:

Maybe the directory USB_REAR_DIR should be created elsewhere but it is used to store the kernel and initrd later as well as parts of syslinux config if syslinux is used. For one of the following scripts it needed to exist.

jsmeix commented at 2021-07-21 12:44:

@DEvil0000
thank you for the info!

What a mess that old USB related code is!
The global looking variable USB_REAR_DIR is not used globally
but the $BUILD_DIR/outputfs/$USB_PREFIX directory is needed
so for now I at least explained things via
https://github.com/rear/rear/pull/2659/commits/b20858a41d6a3d709bbfe34633915e9ac070223e


[Export of Github issue for rear/rear.]