How to list and edit GRUB2's "menuentry" in command-line under Centos-8?
Asked Answered
M

2

8

How to list GRUB2's “menuentries” in command-line under Centos-8? The used workable method "fgrep menuentry /etc/grub2.conf" failed.

Because at Centos-8/RHEL-8, they DO NOT store menuentry in /etc/grub2.conf. Instead, they search and build entries at booting runtime.

And how to add a custom cmdline parameter to special menuentry? There is no menuentry in /etc/grub2.conf, I can not edit any menuentry.

Murdoch answered 20/3, 2020 at 4:24 Comment(2)
"grub2 meny entries" : /boot/grub2/grub.cfgHeliotaxis
/etc/grub2.cfg is a symbol link to /boot/grub2/grub.cfg, there is no "menuentry" in /boot/grub2/grub.cfg.Murdoch
K
13

Grub menu entries in RHEL/CentOS 8 are assembled from various files and scripts so we won't see static entries as was the case for previous versions of the OSes. (You can see the un-expanded boot entry configuration files located in the /boot/loader/entries/ directory)

In order to view the default menu entry, you can use:

grubby --info DEFAULT

In order to view all the menu entries, you can use:

grubby --info ALL

The latter also gives us the corresponding index for each of the entries that can be useful. For instance, the following will list the meny entry details for the 3rd entry:

grubby --info 2

In order to customize a specific entry you can do so by either referencing the index:

grubby --args amd_iommu=on --update-kernel 2

Or by simply using the kernel version as the following for the current kernel:

grubby --args amd_iommu=on --update-kernel=/boot/vmlinuz-$(uname -r) 

Once you do a modification to an entry, the options should be expanded and listed in the corresponding entry file in /boot/loader/entries/ (otherwise you will see variables).

Keneth answered 1/11, 2020 at 21:55 Comment(0)
M
1

Unfortunately, grubby won't list menu entries that you've added to /boot/grub2/custom.cfg (loaded by /etc/grub.d/41_custom). I'm not sure if it will include entries loaded in /etc/grub.d/40_custom, either.

I've had some success seeing grub's menu entries by compiling grub2-emu and running that:

https://github.com/Jolicloud/grub2/blob/master/util/grub-emu.c

It's available in some repositories as the grub-emu or grub2-emu package. It shows you a simulation of the grub menu, as it would appear at boot time.

Multitudinous answered 4/6, 2021 at 20:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.