简体   繁体   中英

How to list and edit GRUB2's "menuentry" in command-line under Centos-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.

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).

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM