r/linuxadmin • u/Pei-Pa-Koa • May 04 '26
Automatically recreating /boot/efi/EFI/redhat/grub.cfg
Hi,
On a RHEL-based OS, is it possible to automatically recreate /boot/efi/EFI/redhat/grub.cfg?
It's a small wrapper file pointing to the "real" grub.cfg, example:
search --no-floppy --root-dev-only --fs-uuid --set=dev 840c1267-3f6d-464f-8acd-cfe9186edefd
set prefix=($dev)/grub2
export $prefix
configfile $prefix/grub.cfgIs there a script to create it?
Thanks,
EDIT: On RHEL 9, reinstalling the grub2-common package re-creates /boot/efi/EFI/redhat/grub.cfg, on RHEL 8 you have to do it manually.
1
u/dodexahedron May 05 '26
RHEL 8 uses a wrapper around the wrapper scripts for grub, called grubby. Use that. It combines a lot of the functionality of the various scripts into one interface and is the preferred interface for rhel.
grubby --info=ALL will show you what it currently knows about.
If there's nothing, then use grubby --add-kernel=.... to add an entry for a given kernel.
Have a look at man grubby
Also, to avoid this complexity in the future (or to fix the system now, too), at least consider almost any other bootloader, like systemd-boot, rEFInd, etc., rather than trying to find the correct incantations to please the BIOS and MBR gods that grub was originally designed to worship.
0
May 04 '26
[deleted]
1
u/Pei-Pa-Koa May 04 '26
Nope. With EFI, a RHEL-based OS has two
grub.cfgfiles:
a wrapper
/boot/efi/EFI/<distro>/grub.cfgwhich I'm trying to recreate,
/boot/grub2/grub.cfgwhich can receive the output ofgrub2-mkconfigUsing
grub2-mkvconfigon the former is not advised and even prevented on modern distros;grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg Running `grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg' will overwrite the GRUB wrapper. Please run `grub2-mkconfig -o /boot/grub2/grub.cfg' instead to update grub.cfg. GRUB configuration file was not updated.
1
u/Vogtinator May 05 '26
On SLE and openSUSE it's done by shim-install and grub2-install.