#3145 PR merged
: Support saving and restoring hybrid BIOS/UEFI bootloader setup and clean up bootloader detection¶
Labels: enhancement
, bug
, cleanup
, fixed / solved / done
pcahyna opened issue at 2024-02-06 18:06:¶
Pull Request Details:¶
-
Type: Bug Fix / Enhancement
-
Impact: High
-
Reference to related issue (URL): also helps with the problem in #3128
-
How was this pull request tested?
Full backup and recovery on a hybrid UEFI/BIOS bootloader setup, with UEFI firmware. -
Description of the changes in this pull request:
- Fixes a bug where a system with hybrid BIOS/UEFI boot was
restored without the BIOS bootloader (
GRUB2
) and on subsequentmkrescue
it will abort because it can't detect the bootloader - the BIOS bootloader was not found in the boot sector and the presence of the BIOS boot partition confused the EFI bootloader detection. In detail: - Support BOOTLOADER=GRUB/GRUB2 with UEFI. This will happen with hybrid boot: BOOTLOADER=GRUB2 indicates that there is the BIOS version of GRUB2 installed and at the same time, USING_UEFI_BOOTLOADER=1 indicates theat there is also an EFI bootloader. Note that it is now perfectly legal to have USING_UEFI_BOOTLOADER=1 and BOOTLOADER neither EFI nor GRUB2-EFI nor ELILO. This will happen with hybrid BIOS/UEFI booting: BOOTLOADER will be detected as GRUB2, but USING_UEFI_BOOTLOADER=1.
- Detect GRUB2 earlier - when saving layout. We used to distinguish between GRUB and GRUB2 when reinstalling the bootloader. This meant that the saved bootloader was wrong: GRUB for GRUB2. Detect GRUB2 earlier, already at the moment when we guess the bootloader, and save the correct value. This should help with the problem reported in PR #3128 (misdetection of GRUB2 as GRUB on any non-SUSE distro).
- Don't look for EFI bootloader in the start of disk. EFI bootloader is not installed to the start of the disk, but to the EFI System partition as a regular file. It is this futile to search for EFI bootloaders in the first sectors of disks. If we find "EFI", it is only because there is a GPT, and "EFI PART" is the GPT signature (this does not tell anything about the presence of an EFI bootloader). See https://github.com/rear/rear/commit/67ac463446a5b140ea1eb1d9268e86422f869ebf#r138332329 .
- Delete the code that checked for 'Hah!IdontNeedEFI' as a special case - it is not needed now. The code effectively skipped the check for EFI when there was a BIOS boot partition. Its presence does not indicate the absence of an EFI bootloader, though. We could be on an UEFI machine with the disk partitioned in hybrid (BIOS/UEFI compatible) mode. In this case ReaR can error out if legacy GRUB is not installed, because it does not find any bootloader (the EFI check is skipped).
- Fixes a bug where a system with hybrid BIOS/UEFI boot was
restored without the BIOS bootloader (
pcahyna commented at 2024-02-08 15:52:¶
@rear/contributors I plan to merge it tomorrow unless there are objections.
[Export of Github issue for rear/rear.]