1

I upgraded from Fedora 38 to Fedora 40 more or less smoothly. Yet, when new kernels are installed, the grub configuration is not updated.

The command grep vmlinuz /boot/grub2/grub.cfg shows

 linux /boot/vmlinuz-6.8.8-300.fc40.x86_64 root=UUID=0e08d465-d601-478f-be17-a2663626588c ro
 linux /boot/vmlinuz-6.8.8-100.fc38.x86_64 root=UUID=0e08d465-d601-478f-be17-a2663626588c ro
 linux /boot/vmlinuz-6.3.12-200.fc38.x86_64 root=UUID=0e08d465-d601-478f-be17-a2663626588c ro

but I do not have 6.3.12 installed, and ls /boot/loader/entries gives me

 vmlinuz-6.8.8-100.fc38.x86_64
 vmlinuz-6.8.8-300.fc40.x86_64
 vmlinuz-6.8.9-300.fc40.x86_64

agreeing with rpm -q kernel as well:

 kernel-6.8.8-100.fc38.x86_64
 kernel-6.8.8-300.fc40.x86_64
 kernel-6.8.9-300.fc40.x86_64

Yes, grub2-mkconfig -o /boot/grub2/grub.cfg restores the config, with the command grep vmlinuz /boot/grub2/grub.cfg now giving

 linux /boot/vmlinuz-6.8.9-300.fc40.x86_64 root=UUID=0e08d465-d601-478f-be17-a2663626588c ro
 linux /boot/vmlinuz-6.8.8-300.fc40.x86_64 root=UUID=0e08d465-d601-478f-be17-a2663626588c ro
 linux /boot/vmlinuz-6.8.8-100.fc38.x86_64 root=UUID=0e08d465-d601-478f-be17-a2663626588c ro

but grub2-mkconfig is not supposed to be run each time a kernel is installed.

What is going on?

1 Answer 1

3

With the /boot/loader/entries in existence and up to date, there should be no mention of individual kernels in /boot/grub2/grub.cfg: instead, the configuration should be invoking the GRUB command blscfg which will cause GRUB to read /boot/loader/entries and use the information within. In other words, grep blscfg /boot/grub2/grub.cfg should return something like:

# The blscfg command parses the BootLoaderSpec files stored in /boot/loader/entries and
insmod blscfg
blscfg

If your grub2-mkconfig updates the list of kernels into /boot/grub2/grub.cfg, it means you must have an old version of the script /etc/grub.d/10_linux still active, or you must have added GRUB_ENABLE_BLSCFG=false to /etc/default/grub.

However, since RHEL 8 (and corresponding Fedora versions) the default kernel postinstall scripts now assume that blscfg is in use, and so the grub2-mkconfig doesn't need to be invoked after installing a new kernel, unless GRUB_ENABLE_BLSCFG=false is used in /etc/default/grub.

In RHEL/Fedora, kernel package post-transaction scripts will invoke /bin/kernel-install add <kernel version> ... on installation and /bin/kernel-install remove <kernel-version> ... on removal. The /bin/kernel-install will in turn invoke any scripts it finds in directories /etc/kernel/install.d/ and /usr/lib/kernel/install.d (with files in the former directory overriding any files with the same names in the latter) with similar add/remove and kernel version arguments.

The last script to execute on both installation and removal should be /usr/lib/kernel/install.d/99-grub-mkconfig.install: it runs grub2-mkconfig, but only if /etc/default/grub has GRUB_ENABLE_BLSCFG set to the exact string false. Any deviation will cause the script to assume the bootloader is capable of using /boot/loader/entries, and so the script will exit without doing anything.

If all this seems fine, look into your /etc/grub.d/ directory. Do you perhaps have a 10_linux.rpmnew or similar in there?

If you have such a file, backup your old (possibly customized) 10_linux file and replace it with the 10_linux.rpmnew (or similar) file, then run grub2-mkconfig -o /boot/grub2/grub.cfg one final time.

Apparently the /etc/grub.d/10_linux file might come from the grub2-tools package, so a dnf reinstall grub2-tools might be necessary if there is no 10_linux.rpmnew or similar file present.

9
  • I do not have any mention to blscfg in /boot/grub2/grub.cfg. Yes, I do have a 10_linux in /etc/grub.d/, but no 10_linux.rpmnew. I did a dnf reinstall grub2-tools, and the 10_linux is identical to the one I had. In fact, the full /etc/grub.d/ is identical. I also have a 40_custom, since I have several extra entries in my boot: double boot, Ventoy, USB boot, reboot, etc. But I do not know then how my system populates /boot/grub2/grub.cfg with the installed kernels. Commented May 20 at 14:10
  • I also have the lines insmod blscfg and blscfgin 10_linux. But not in /boot/grub2/grub.cfg, even after a new grub2-mkconfig -o /boot/grub2/grub.cfg. Commented May 20 at 14:18
  • Please see my edit.
    – telcoM
    Commented May 20 at 15:44
  • Actually, it is the opposite: I have GRUB_ENABLE_BLSCFG="true" in /etc/default/grub. Commented May 20 at 16:09
  • 1
    I removed the export BLS_POPULATE_MENU="true" line from /etc/default/grub. Now grub2-mkconfig -o /boot/grub2/grub.cfg still works, yet instead of the explicit menu entries for each kernel, it reads insmod blscfg and blscfg. I guess that is the appropriate behaviour. Commented May 20 at 18:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .