What in Fedora controls whether the latest installed kernel is booted on next boot?

published Aug 30, 2023

It's a simple environment variable set in a simple file.

What in Fedora controls whether the latest installed kernel is booted on next boot?

Fedora's script /usr/lib/kernel/install.d/20-grub.install — which runs every time a new kernel is installed — sources file /etc/default/grub  (this file is part of the GRUB packages installed on a normal Fedora system) and file /etc/sysconfig/kernel.

This install.d script can, during the kernel installation process, automatically set the latest-installed kernel to be the default GRUB entry to boot, and therefore the system will boot that kernel upon next reboot.  While I have no experience with other boot loaders, I suspect similar scripts should be available for other bootloaders your system may have opted into.

There are two options to ensure your system automatically boots to the latest kernel after an upgrade:

  1. Variable UPDATEDEFAULT is set to yes in /etc/sysconfig/kernel.  Unless option 2 overrides it via its own variable, then this value is used.  This is the more general option as it can be used by bootloaders other than GRUB.  The default (unset) action from this variable is to do nothing.
  2. Variable GRUB_UPDATE_DEFAULT_KERNEL is set to true in /etc/default/grub, or is left unset if option 1 is in effect.  If set to false, it prohibits this behavior even if option 1 is in effect.  If unset, and option 1 is also unset, then the kernel install process will not update the default kernel to boot.

In GRUB-enabled systems (most Fedora systems) this mechanism only has a practical effect if:

  1. GRUB has been told to use the saved default via the /etc/default/grub variable GRUB_DEFAULT=saved, and
  2. GRUB on the system is configured to use the Boot Loader Specification (BLS) via variable GRUB_ENABLE_BLSCFG=true (the default on modern Fedora systems).

That's all.