How to setup boot (+shim) for self compiled version of grub?

Hi,

usually both the grub2-efi-x64 package as well as the shim package provide all that is needed to boot including support for secure boot. I have a case on my hand where I’ll need additional capabilities from grub that I’ll have to patch in myself. Compiling grub from sources and applying the patches was the easy part, but now I am stuck with what I need to do the let the system boot.

I removed the grub-efi-x64 package manually with rpm and installed the compiled version of grub with make install and ran grub-mkconfig -o /boot/grub2/grub.cfg. Now I get an error during boot:

Failed to open \EFI\fedora\grubx64.efi
Failed to load Image : Not found
start_image() returned Not found, falling back to default loader

I am far from knowledgeable on the boot process and in Fedora case the packages install what they need themself. If I understand this correctly I would need to reinstall grub, in this case maybe with grub-install manually, but I am really not sure. I am in this case not even sure if grubx64.efi is supposed to be the file that links to grub or the binary for shim.

Any help in this matter would really be appreciated. If you need more information let me know about it.

You may need to run grub-install unless make install already did that. Also I expect that secure boot won’t work and kernel updates won’t work either.

For EFI, in my custom installer, I use:

# (1) Install the required packages
dnf --comment="Install GRUB" install grub2-efi-x64 grub2-efi-x64-modules shim

# (2) create a GRUB config
grub2-mkconfig -o /boot/grub2/grub.cfg

For BIOS, I need to add:

grub2-install --target=i386-pc $DISK_PATH

before (1) and (2).


To make sure I don’t miss any part of the workflow, I reinstall the kernel after that, which invokes a series of operations that updates the GRUB config, add new boot entries etc.

The process of applying GRUB should be more or less straightforward


I’m not sure how did you build your version of GRUB, but I’d definitely fork and update the Fedora package ‘grub2’ and patch that, rather then the upstream sources.

Just look at how many downstream patches Fedora uses on ‘grub2’
https://src.fedoraproject.org/rpms/grub2/tree/rawhide

The SPECfile also doesn’t seem to be trivial, so there might be a lot of going on there:
https://src.fedoraproject.org/rpms/grub2/blob/rawhide/f/grub2.spec

Easy to say it for me “just re-build a Fedora package”, I’m a seasoned Fedora package maintainer. :slight_smile:
However if you’re not used to building custom RPM packages, that would be challenging.

I’m willing to help, if you want, and rebuild the Fedora ‘grub2’ package for you, so at least you would have the package composed in the right way.

let me know if you want to try this road.