Editing grub entries

Hello. Maybe someone can help me. I just converted RHEL to Rocky using the migrate2rocky script, but my grub menu still shows entries for old kernels with os name “Red Hat…” even though I have removed those kernels. How can I delete those old RH entries from grub.

In other words, the question is why the removal of kernel packages did not remove corresponding entries?

The default in el8 is apparently for GRUB to use BLS (Boot Loader Specification). In BLS the menu entries are not in the grub.cfg, but as separate files in /boot/loader/entries/. The grub.cfg merely calls the BLS. This makes entry updates simpler: rather than edit a file, installer (dnf) can add or remove file.

If your system has BLS in use, then look from /boot/loader/entries/. If it contains entries that do not have corresponding kernel and initrd files, then you can remove those entries.

Thanks for your help. That did the trick!

I did notice though that when I select the “rescue” entry from the grub menu (I tried because I was curious), it shows the Red Hat logo before booting into rescue mode. I am trying to “de-RedHat” my PC. Any advice? Much appreciated.

A kernel that we normally use has associated initrd-image. The image is created when kernel is installed and it contains the bare minimum of drivers that the kernel needs for mounting the root filesystem, etc. In other words, the content depends on what your system has/needs.

The installation media has much larger initrd-image, because it must have drivers for all supported hardware.

The rescue, like installer, must be self-sufficient, i.e. have large initrd-image.

There is a package dracut-config-rescue that apparently can make the dracut to generate a rescue image.
See: How do I disable the creation of the rescue boot image on CentOS? - Unix & Linux Stack Exchange
and: How to re-generate rescue kernel image for current kernel?

@jlehtone , just wondering, but can he not also execute the command
I am wondering if maybe executing (in verbose mode):

dracut -f -v

then,

grub2-mkconfig -o /boot/grub2/grub.cfg

By doing that the command would look for the kernel-associated files and rebuild the grub.cfg file properly.

Would you agree that it could rebuild the grub.cfg file with the properly branded kernels and etcetera.

1 Like

Disclaimer: I haven’t used dracut. From its man:

  • dracut generates initrd-image
  • your command replaces image for currently running kernel
  • without --hostonly the image is good for rescue, but not for booting the system

If BLS is in use … no idea who updates the entries.

Some operations, e.g. installing kmod-nvidia from ELRepo updates all images.

1 Like