Grub.cfg for UEFI boot

I cloned a Rocky 8.6 installation from a “legacy” system to a new system with UEFI boot. I managed to make almost all the required changes, adding an ESP (EFI System Partition) etc. The only remaining problem is that package grub2-efi-x64 is supposed to install a /boot/efi/EFI/rocky/grub.cfg file that is actually a shim that chains to the standard /boot/grub2/grub.cfg file. However, such a file was not created.

As a test, I copied the /boot/grub2/grub.cfg file to /boot/efi/EFI/rocky and after doing that the system boots properly. Following some Fedora documentation, I then deleted /boot/efi/EFI/rocky/grub.cfg and tried to “dnf reinstall grub2-efi-x64”. There were no error messages, but the desired /boot/efi/EFI/rocky/grub.cfg was not created.
I note that “rpm -ql grub2-efi-x64” indicated that the desired file should be created.

Is this a known bug in Rocky 8,.6 (or even RHEL 8.6)? Is there a workaround that’s better than having to copy grub.cfg every time it changes?

I would make sure you have more than just grub2-efi-x64 package. The primary ones you need would be efibootmgr and grub2-efi-x64. The others should be brought in as deps.

[root@ipa01 ~]# rpm -qa | grep efi
efibootmgr-16-1.el8.x86_64
grub2-tools-efi-2.02-123.el8.x86_64
efi-filesystem-3-3.el8.noarch
efivar-37-4.el8.x86_64
efivar-libs-37-4.el8.x86_64
grub2-efi-x64-2.02-123.el8.x86_64

There is a /etc/grub-efi.cfg symlink owned by that package which points to the missing file. You can try to run grub2-install --target=x86_64-efi --bootloader-id=rocky --boot-directory=/boot --efi-directory=/boot/efi --recheck --verbose /dev/sdX and then regenerate the grub config at /boot/efi/EFI/rocky/grub.cfg and see if that gets you further.

If I had to guess, it might be that you are missing a few key packages that would help with creating that file. But it’s hard to tell on systems I converted two plus years ago.

I had all the packages except for efivar-37-4.el8.x86_64. I installed the missing package and, unfortunately, that did not fix the problem.
grub2-efi-x64 does install the /etc/grub-efi.cfg symlink but not the file that this symlink points to. I also tried to remove grub2-efi-x64, verify that none of its files remained, and then install grub2-efi-x64. That also didn’t fix the problem.
I’ll try the grub2-install after I figure out what it is supposed to do.

I have two Alma 8 with EFI. Alas, both of them were CentOS 8 initially. Anyway, symlinks in them are:

grub2.cfg -> ../boot/grub2/grub.cfg
grub2-efi.cfg -> ../boot/efi/EFI/almalinux/grub.cfg

and the “real grub.cfg” is in /boot/efi/EFI/almalinux/

Therefore, if I want to recreate the config (e.g. after change in /etc/defaults/grub) I do:

grub2-mkconfig -o /boot/efi/EFI/almalinux/grub.cfg

In comparison, Alma 9 has both symlinks pointing to /boot/grub2/grub.cfg and the
/boot/efi/EFI/almalinux/grub.cfg is a “shim”, like:

search --no-floppy --fs-uuid --set=dev 14fba295-2e84-407a-b8e6-585762695e95
set prefix=($dev)/grub2

export $prefix
configfile $prefix/grub.cfg

Grub manual of AL8 does know those commands, so perhaps one could have a shim in Rocky 8 too.

However, does kernel install/removal (and similar operations) touch only BLS entries, or does it follow the symlink to /boot/efi/EFI/almalinux/grub.cfg and do changes there?

Furthermore,

[root@Alma8 ~]# rpm -qf /boot/efi/EFI/almalinux/grub.cfg
grub2-efi-x64-2.02-123.el8_6.8.alma.x86_64

[root@Alma8 ~]# rpm -qlv grub2-efi-x64
drwx------    2 root    root                        0 Jun 18 15:27 /boot/efi/EFI/almalinux/fonts
-rwx------    1 root    root                        0 Jun 18 15:27 /boot/efi/EFI/almalinux/grub.cfg
...

The package claims to own the file, but does not actually provide a file (as it has to be generated, just like, for example the sssd.conf).
Unless …

[root@Alma8 ~]# rpm -q --scripts grub2-efi-x64
posttrans scriptlet (using /bin/sh):
if [ -d /sys/firmware/efi ] && [ ! -f /boot/efi/EFI/almalinux/grub.cfg ]; then
    grub2-mkconfig -o /boot/efi/EFI/almalinux/grub.cfg || :
fi

There I have it: grub2-mkconfig -o /boot/efi/EFI/almalinux/grub.cfg

I bet that Rocky version has grub2-mkconfig -o /boot/efi/EFI/rocky/grub.cfg in that script.

My original posting was incorrect. The Fedora documentation I was looking at do not apply. I installed Rocky 8.6 from scratch and discovered that /boot/efi/EFI/rocky/grub.cfg is NOT a shim; it is the real grub.cfg. With the new installation, the symlink /etc/grub2.cfg still points to /boot/grub2/grub.cfg. However, there is no file /boot/grub2/grub.cfg. The symlink /etc/grub2-efi.cfg points to the file that exists at /boot/efi/EFI/rocky/grub.cfg.
So, perhaps the Fedora documentation indicates that in a future RHEL release /boot/efi/EFI/rocky/grub.cfg will be a shim.
Thanks all who replied.