Failed to open grubx64.efi - Not Found

Open
#401 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
linux

Research direction

Reproduce the reported case in a qemu-kvm VM without NVRAM boot records, using the shown GRUB menu and the paths bootx64.efi and fbx64.efi. Compare chainloading bootx64.efi through GRUB with launching it from UEFI, then determine why the former reports Not Found and document or correct the behavior.

Written by the indexing model from the issue text.

Description

This feels somewhat related to #307, in that some other boot loader is running that is directed to run the shim.
https://askubuntu.com/questions/906776/error-failed-to-open-efi-boot-grubx64-efi-dual-booting
Is another example.

So, given a qemu-kvm virtual machine with no NVRAM boot records (a system restored from backups, in my case), I have a recovery disk with a grub menu that does the following.

if [ x"${grub_platform}" = xefi ]; then
    for bootfile in (*)/efi/boot/bootx64.efi; do
        if regexp "$osdisk" $bootfile; then
            regexp --set=1:thispart "([^/]*)/.*" $bootfile
            menuentry "Boot OS on ${thispart}" {
                chainloader ${bootfile}
            }
            break
        fi
    done
...

In the case of an Ubuntu 20.04 Qemu-kvm machine with my recovery disk as hd0, and the system disk as hd1, I get bootfile=(hd1,gpt2)/efi/boot/bootx64.efi. When choosing that menu option (or as in the image below, chainlodering it by hand), I get a Not Found error.
image
I find that if I set bootfile=(hd1,gpt2)/efi/boot/fbx64.efi, the system boots correctly (adds the record from boot.csv and everything).

However, I can boot from that bootx64.efi file in three ways, and it successfully executes fbx64.efi.

  1. Remove my recovery disk (UEFI picks the file by default)
  2. Use grub to run fwsetup, and use the Tianocore UEFI menu to boot directly from the file
  3. Run the "Internal EFI Shell", and execute bootx64.efi from there.

I can't tell if this is grub's fault for corrupting the environment, or if this is shim's fault for not knowing that it should be finding fbx64.efi. I'd love to learn more.

For now, I've slightly modified my grub config to include fbx64.efi:

if [ x"${grub_platform}" = xefi ]; then
    for file in /EFI/BOOT/GRUBX64.EFI /EFI/BOOT/FBX64.EFI /EFI/BOOT/BOOTX64.EFI; do
        search --no-floppy --file --hint=${osdisk}, --set=thispart ${file}
        if regexp "$osdisk" $thispart; then
            menuentry "Boot OS (${thispart})${file}" {
                chainloader (${thispart})${file}
            }
            break
        fi
    done
else
...

And that gets me unblocked. But I would be happier with something simpler like "Just chainload the bootx64.efi program."

Dominant language
C
Stars
1.1k
Forks
348
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rhboot/shim

All issues in rhboot/shim

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.