Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rhcos-4.6] buildextend-live: drop shim fallback.efi from ISO #2439

Merged
merged 4 commits into from Sep 17, 2021
Merged

[rhcos-4.6] buildextend-live: drop shim fallback.efi from ISO #2439

merged 4 commits into from Sep 17, 2021

Conversation

bgilbert
Copy link
Contributor

UEFI boots from removable media via the arch-specific default EFI application in /EFI/BOOT. When booted that way, shim chains to fallback.efi if it exists, and fallback.efi creates an EFI boot entry. That's not appropriate for removable media boot, since the media will probably never be present again. If a TPM is present, fallback.efi will additionally reboot the machine, and on some machines this leads to boot loops. Instead of all this, we just want shim to chain directly to GRUB.

Drop fallback.efi and its associated CSV from the EFI image. Replace it with a copy of GRUB in the right place for shim to chain to it.

Unlike 4.7+, the 4.6 live ISO doesn't attempt to support UEFI booting when copied to a USB stick (except for firmware that can do so via El Torito). Fixing this is a small change, so for consistency with newer releases, backport the commits to do so. Then apply a lightweight backport of #2435.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2004449

For BIOS systems, we're already adding an MBR and boot sector to the ISO
image so it can be dd'ed to a USB stick and booted as a hard disk.  For
UEFI systems, we're already generating an ESP and setting it as an
additional El Torito image.  For some UEFI firmware (e.g. EDK II) that
seems to be sufficient, but we should also create a GPT with an ESP
wrapping that El Torito image, for firmware that doesn't support
El Torito on hard disks.

For coreos/fedora-coreos-tracker#707.
05ba856 added an ESP to the ISO's hybrid GPT to help EFI systems that
won't boot El Torito from a hard disk.  However, when booting from the
ESP, GRUB won't read the grub.cfg from the main ISO image, and just drops
to a grub prompt.  Add a stub grub.cfg that points GRUB to the right
place.

Fixes: 05ba856 ("buildextend-live: hybridize live ISO for UEFI boot")
Fixes: coreos/fedora-coreos-tracker#724
Fixes: coreos/fedora-coreos-tracker#953
At runtime it's immediately overwritten by the GRUB menu, but it shows up
in console logs.  This will help validate automated tests.
UEFI boots from removable media via the arch-specific default EFI
application in /EFI/BOOT.  When booted that way, shim chains to
fallback.efi if it exists, and fallback.efi creates an EFI boot entry.
That's not appropriate for removable media boot, since the media will
probably never be present again.  If a TPM is present, fallback.efi will
additionally reboot the machine, and on some machines this leads to boot
loops.  Instead of all this, we just want shim to chain directly to GRUB.

Drop fallback.efi and its associated CSV from the EFI image.  Replace it
with a copy of GRUB in the right place for shim to chain to it.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2004449
@mike-nguyen
Copy link
Member

mike-nguyen commented Sep 17, 2021

I build this PR locally and used it to build RHCOS 4.6. I confirmed that the boot was successful on UEFI and BIOS. I also verified the fallback binary and CSV file were absent.


$ sudo mount -o loop rhcos-46.82.202109171615-0-live.x86_64.iso /mnt/iso
mount: /var/mnt/iso: WARNING: source write-protected, mounted read-only.
$ sudo mount -o loop,ro /mnt/iso/images/efiboot.img /mnt/efi
$ tree /mnt/efi
/mnt/efi
└── EFI
    ├── BOOT
    │   ├── BOOTX64.EFI
    │   └── grubx64.efi
    └── redhat
        ├── fonts
        ├── grub.cfg
        ├── grubx64.efi
        ├── mmx64.efi
        ├── shimx64.efi
        └── shimx64-redhat.efi

$ cat /mnt/efi/EFI/redhat/grub.cfg 
search --label "rhcos-46.82.202109171615-0" --set root --no-floppy
set prefix=($root)/EFI/redhat
echo "Booting via ESP..."
configfile $prefix/grub.cfg
boot

@bgilbert bgilbert merged commit 204318c into coreos:rhcos-4.6 Sep 17, 2021
@bgilbert bgilbert deleted the fallback-iso-bp/rhcos-4.6 branch September 17, 2021 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants