Ask Your Question
1

Installing new kernel always puts new Fedora entry at the top of GRUB menu, despite my custom menu entry

asked 2017-08-17 19:14:20 -0600

terrycloth gravatar image

updated 2017-08-17 23:53:05 -0600

I have a custom GRUB menu entry that I want to always appear at the top of the GRUB menu. This menu entry lives in /etc/grub.d/09_FIRST, so that it should appear before 10_linux. However, whenever I install system updates that include a new kernel, the new Fedora entry gets bumped to the top of the GRUB menu, until I manually run grub2-mkconfig. It was my understanding that installing a new kernel should run grub2-mkconfig --- so what's going on here?

My system:

  • Fedora 26 Workstation x86_64 with UEFI motherboard
  • grub2-2.02-0.46.fc26
  • latest kernel: 4.12.5
↪  cat /etc/default/grub
# ========== Defaults from Fedora ==========

GRUB_TIMEOUT="5"
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DISABLE_SUBMENU="true"
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="rd.luks.uuid=luks-8e45f2c9-cbd1-45ef-b916-981302ac347f rd.luks.uuid=luks-43b66853-1753-405e-bb93-2eec26187889 rhgb quiet"
GRUB_DISABLE_RECOVERY="true"


# ========= Custom settings ==========

GRUB_TIMEOUT="-1"
GRUB_GFXMODE="auto"
GRUB_TERMINAL_OUTPUT="gfxterm"
GRUB_GFXPAYLOAD_LINUX="keep"

GRUB_SAVEDEFAULT="false"
GRUB_COLOR_NORMAL="white/black"
GRUB_COLOR_HIGHLIGHT="black/white"
GRUB_DEFAULT="FIRST"
GRUB_FONT="/boot/efi/EFI/fedora/themes/DejaVuSansMono.pf2"
edit retag flag offensive close merge delete

Comments

Ubuntu updates grub config after every kernel installation. Some time ago I've read some devs were discussing same feature for fedora, but it haven't materialised yet. There are some answers you can adapt to achieve it yourself https://unix.stackexchange.com/questi...

ozeszty gravatar imageozeszty ( 2017-08-18 03:31:52 -0600 )edit

2 Answers

Sort by » oldest newest most voted
2

answered 2017-08-18 02:22:50 -0600

hedayat gravatar image

updated 2017-08-19 04:09:31 -0600

No, installing a new kernel does NOT run grub2-mkconfig. It directly edits the grub.conf file in your /boot directory. BTW, if the title, or the id of your custom entry is FIRST, it should be booted by default even if it is not the first entry in grub menu. Otherwise, put the id of your custom entry in GRUB_DEFAULT. For example, assume the custom entry is (stolen from info grub2 ;)):

menuentry 'Example GNU/Linux distribution' --class gnu-linux --id example-gnu-linux {
        ...
     }

You can set: GRUB_DEFAULT=example-gnu-linux, and it should be booted by default regardless of its position in the menu.

Update: If you want grub2-mkconfig to be run after each kernel install, you can create /etc/kernel/install.d directory and put an executable (e.g. shell script) in it. During kernel installation, it'll be called with these parameters: add "$KERNEL_VERSION" "$BOOT_DIR_ABS" "$KERNEL_IMAGE", in which you probably should only care about the first parameter: add (because the script will also run when a kernel is removed, in which case you probably don't need to run grub2-mkconfig).

All you need to do is to call grub2-mkconfig with appropriate parameters when the first argument of the script is add

edit flag offensive delete link more

Comments

The "FIRST" entry is automatically selected, but it's no longer at the top of the GRUB menu after installing a new Fedora kernel. This is maybe a small issue, since the default menu entry is preserved, but the aesthetic change bugs me.

terrycloth gravatar imageterrycloth ( 2017-08-18 20:31:40 -0600 )edit

I guess the solution is to always run grub2-mkconfig myself, or ask that the kernel packages do it for me.

terrycloth gravatar imageterrycloth ( 2017-08-18 20:32:17 -0600 )edit
2

Actually, kernel packages don't do it themselves. kernel packages call /bin/kernel-install to do that. And the actual modification is done by grubby. So maybe you should ask grubby to add the entry above the topmost kernel entry.. or some other suggestion. I don't think that it'll be accepted to call grub2-mkconfig, as it is much more intrusive than editing grub.cfg directly (not everybody would like that!). BTW, there is something you can do! I update my answer for that.

hedayat gravatar imagehedayat ( 2017-08-19 04:02:42 -0600 )edit

I'd already sent my report against the kernel on the Red Hat Bugzilla, so I guess we'll see what they say, or if they move it to Grubby or what. Interested readers can follow the discussions there.

https://bugzilla.redhat.com/show_bug....

Your suggestion about the kernel-install script is interesting. I'll take a look at that too. Thanks!

terrycloth gravatar imageterrycloth ( 2017-08-19 18:58:11 -0600 )edit
1

answered 2017-08-18 02:10:20 -0600

jmt gravatar image

Installing a new kernel does not run grub2-mkconfig so you will have to run it yourself. This is a bit annoying.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-08-17 19:14:20 -0600

Seen: 575 times

Last updated: Aug 19 '17