1

GRUB version: 2.04-20

One Linux kernel only; I need to have two GRUB entries to boot the kernel with different set of kernel options. For the time being, after each grub-mkconfig or update-grub2 which produces one entry with GRUB_CMDLINE_LINUX_DEFAULT options, I manually add another one with the different set.

Is there any way to get two entries of the same kernel with different kernel options (one respecting GRUB_CMDLINE_LINUX_DEFAULT plus another one) after running grub-mkconfig or update-grub2? I suppose some custom script in /etc/grub.d?

Added bonus, proper way to disable os-prober? For the time being, I've renamed os-prober script so that it's not found.

Krackout
  • 2,642
  • 12
  • 26

1 Answers1

0

to get two grub menu entries at boot, those are defined in (Redhat for example) /boot/efi/EFI/redhat/grub.cfg

in your grub.cfg you will see menuentry {...} where the open & close curly braces are separated by around 15 lines. But each menuentry corresponds to what you see in the grub boot menu at boot time. They normally correspond to the last 5 or so kernel versions.

Simply edit this file and clone your menu entry of interest then modify the kernel options you wish, and adjust the menu entry title accordingly so you can pick it when the grub boot menu show up.

Like was said for the GRUB_DISABLE_OS_PROBER="true" that you put in /etc/default/grub then when you run grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg (on redhat for example) then that /boot/efi/EFI/redhat/grub.cfg is modified and that's where everything happens. Don't run grub2-mkconfig after manually editing the /boot/efi/.../grub.cfg file otherwise you'll undo your custom menu entry. I'm not a grub2 expert, I know just enough to be dangerous and kinda point you to the correct location. Is there a better way to manage grub menu entries, like a high level elegant way like what /etc/default/grub is I don't know I've never researched enough. These may help:

Looking for the right way to rename the GRUB boot entries

https://askubuntu.com/questions/81660/how-can-i-edit-my-grub-bootloader-entries-hide-rename-remove

and it would be the linuxefi line from a given menu entry, such as:

linuxefi /vmlinuz-3.10.0-1160.45.1.el7.x86_64 root=UUID=800e924a-a869-4152-9503-9d9cfecbd16e ro verbose fips=1 boot=UUID=4f3da85a-71a9-4f6e-bc5f-dfd23a880b08 modprobe.blacklist=nouveau nouveau.modeset=0

my /etc/default/grub has exactly GRUB_CMDLINE_LINUX="verbose fips=1 boot=UUID=4f3da85a-71a9-4f6e-bc5f-dfd23a880b08 modprobe.blacklist=nouveau nouveau.modeset=0"

so just modify those corresponding parameters.

ron
  • 6,575
  • sorry if it's not clear in the question: I'm currently adding the entry I need exactly the way you suggest; what I need is to be done automatically. So that I don't need to re-add it whenever kernel is updated (grub2-mkconfig is invoked automatically in that case, and it's the proper thing to do). – Krackout Jan 31 '22 at 20:15
  • 1
    for having it done and retained automatically, when you figure that out you let me know I'd be interested :) – ron Jan 31 '22 at 20:19
  • maybe this... https://unix.stackexchange.com/questions/62733/how-to-correctly-set-up-the-right-grub-2-default-menu-entry – ron Jan 31 '22 at 20:22