How to modify boot menu, boot menu options, and kernel options?

Hi there,

I’ve been flailing a bit trying to figure out how Rocky 8.x does boot management, and after a few false starts trying to figure this out, it looks it’s systemd-boot.

I ended up way down a rabbit hole because grubby and the various grub2 packages are also installed, but that looks like a red herring, so now what I’m trying to reconcile is how to get bootctl to recognize what’s in /boot/loader/entries, although I just copied the contents into /boot/efi/loader/entries. bootctl recognizes them (with errors) but can’t boot from them, and ends up failing through to GRUB, which can.

So I guess after multiple edits of this posting, I think my question is: what is the default boot manager for Rocky?

And what about the default boot loader?

And when the boot manager is GRUB, is /etc/default/grub still the correct place to make changes?

And when using EFI, is /etc/grub2-efi.cfg the correct target when running grub2-mkconfig?

thanks,
Klaus

grub.cfg does control the basic behavior of grub and booting. Are you sure you are installed and booting via UEFI? Your /boot/efi/EFI/rocky directory does not appear normal.

[root@xmpp01 ~]# ls -l /boot/efi/EFI/rocky/
total 6100
-rwx------. 1 root root     130 Nov 17 22:29 BOOTX64.CSV
-rwx------. 1 root root     144 Jul 14  2022 grub.cfg
-rwx------. 1 root root    7028 Jul 14  2022 grub.cfg.rpmsave
-rwx------. 1 root root 2525120 Feb 14 12:06 grubx64.efi
-rwx------. 1 root root  856856 Nov 17 22:29 mmx64.efi
-rwx------. 1 root root  947216 Nov 17 22:29 shim.efi
-rwx------. 1 root root  947216 Nov 17 22:29 shimx64.efi
-rwx------. 1 root root  939648 Nov 17 22:29 shimx64-rocky.efi

You’re missing many efi files. You might want to check if /sys/firmware/efi exists, which will tell you if you are indeed booting via UEFI. You should also have an entirely separate /boot/efi partition, which is a requirement in UEFI scenarios.

Given the contents of your EFI/rocky directory I can give a basic outline of how it should work.
First in /etc there should be two grub links pointing to /boot/grub2/grub.cfg

lrwxrwxrwx.  1 root     root       22 Feb 14 14:06 grub2.cfg -> ../boot/grub2/grub.cfg
lrwxrwxrwx   1 root     root       22 Feb 14 14:06 grub2-efi.cfg -> ../boot/grub2/grub.cfg

The grub.cfg in rocky is a stub file pointing to the partition that contains your vmlinuz and boot loader files /boot/loader/entries

To update the grub menu parameter (not kernel parameters ) like the timeout the command is:

grub2-mkconfig -o /boot/grub2/grub.cfg

To change kernel parameters you have to use the grubby command. Read the man page. But, understand that to add parameters you have to state all the kernel commandline parameters as grubby can’t append. What that means in particular is that when adding parameters you have to state all of them including the “root=UUID=” portion of the commandline.

1 Like

If the /boot/efi was quite empty, then the system does not boot with EFI, but in legacy mode – how could you have booted?
Therefore, adding files to /boot/efi does not help anything.

In legacy mode the grub.cfg and grubenv are in /boot/grub2/. The symlink “grubenv” in that location is confusing.

You have Rocky 9, don’t you? Rocky 8 and 9 do differ.

Yes I am on rocky 9. I guess the real test if the OP is booting efi or not is just to issue this command:
efibootmgr
So looks like they screwed up the links in /etc by installing the efi file system. But even so the command to update the grub.cfg is as I indicated.
So the efi file system installed a grub.cfg stub file in /rocky which is counter intuitive if rocky 8 uses the old format where grub.cfg in EFI/ rocky is the real config. Confusing.

As it turned out, /boot/efi was going missing from /etc/fstab due to a bug in one of our in-house pieces of automation. Definitely Rocky 8, definitely using EFI to boot, just no mount of the EFI partition when the system was running.

I built a new VM where /boot/efi is once again present as expected, and lo and behold, expectations are now met when I modify /etc/default/grub and run grub2-mkconfig /etc/grub2-efi.cfg.

Sorry for the long, convoluted original post, and then the somewhat confusing edit, and thank you @nazunalika for your sanity check. Definitely LUSER error.

cheers,
Klaus

Automation is awesome (once it does the right thing). :slight_smile:


These are two AlmaLinux 8 systems; one with EFI, other with legacy:

[EFI ~]# ls /sys/firmware/efi
config_table  efivars  fw_platform_size  fw_vendor  mok-variables  runtime  runtime-map  systab  tables  vars
[EFI ~]# ll /boot/grub2/
total 0
lrwxrwxrwx. 1 root root 28 Nov  8 20:54 grubenv -> ../efi/EFI/almalinux/grubenv
[EFI ~]# ll /boot/efi/EFI/almalinux/
total 4876
-rwx------. 1 root root     122 Aug 23  2022 BOOTX64.CSV
drwx------. 2 root root    4096 Nov  8 20:54 fonts
-rwx------. 1 root root    6484 Jul 31  2021 grub.cfg
-rwx------. 1 root root    1024 Nov 27 15:36 grubenv
-rwx------. 1 root root 2219312 Nov  8 20:54 grubx64.efi
-rwx------. 1 root root  859504 Aug 23  2022 mmx64.efi
-rwx------. 1 root root  944496 Aug 23  2022 shimx64-almalinux.efi
-rwx------. 1 root root  944576 Aug 23  2022 shimx64.efi

[legacy ~]# ls /sys/firmware/efi
ls: cannot access '/sys/firmware/efi': No such file or directory
[legacy ~]# ll /boot/grub2/
total 32
-rw-r--r--. 1 root root    84 Aug  4  2020 device.map
drwxr-xr-x. 2 root root  4096 Aug  4  2020 fonts
-rw-r--r--. 1 root root  6417 Jul 31  2021 grub.cfg
-rw-r--r--. 1 root root  1024 Nov 11 10:15 grubenv
drwxr-xr-x. 2 root root 12288 Aug  4  2020 i386-pc
[legacy ~]# ll /boot/efi/EFI/almalinux/
total 0

In other words, the path to grub.cfg on el8 does depend on the EFI/legacy.
The grub2-mkconfig does need that path.


Here are two AlmaLinux 9, legacy and EFI:

[legacy ~]# ls /sys/firmware/efi
ls: cannot access '/sys/firmware/efi': No such file or directory
[legacy ~]# ls -l /boot/grub2/grub.cfg 
-rwx------. 1 root root 6869 Nov 18 02:54 /boot/grub2/grub.cfg
[legacy ~]# ls -l /boot/efi/EFI/almalinux/grub.cfg
-rwx------. 1 root root 144 Nov 18 02:54 /boot/efi/EFI/almalinux/grub.cfg
[legacy ~]# cat /boot/efi/EFI/almalinux/grub.cfg
search --no-floppy --fs-uuid --set=dev 5f4e93f3-a45c-4dd7-82ff-99b6d88f77a4
set prefix=($dev)/grub2

export $prefix
configfile $prefix/grub.cfg


[EFI ~]# ls /sys/firmware/efi
config_table  efivars  esrt  fw_platform_size  fw_vendor  mok-variables  runtime  runtime-map  systab  vars
[EFI ~]# ls -l /boot/grub2/grub.cfg
-rwx------. 1 root root 6370 May 23  2022 /boot/grub2/grub.cfg
[EFI ~]# ls -l /boot/efi/EFI/almalinux/grub.cfg
-rwx------. 1 root root 144 May 20  2022 /boot/efi/EFI/almalinux/grub.cfg

On el9 the path to grub.cfg is always /boot/grub2/grub.cfg.
(The legacy system has stub in /boot/efi/EFI/*/ but does not use it.)