Rocky Linux 9 conversion with migrate2rocky9.sh fails while updating GRUB on UEFI

Hi everyone,

I’m experiencing an issue during the conversion of RHEL systems to Rocky Linux.

The issue seems to affect conversions to Rocky Linux 9, while the same conversion procedure on RHEL 8 systems to Rocky Linux 8 completes successfully without this GRUB issue.

During the Rocky Linux 9 conversion, the process fails while updating the GRUB configuration with the following error:

Running `grub2-mkconfig -o /boot/efi/EFI/rocky/grub.cfg' will overwrite the GRUB wrapper.
Please run `grub2-mkconfig -o /boot/grub2/grub.cfg' instead to update grub.cfg.
GRUB configuration file was not updated.

Error updating the grub config.

An error occurred while we were attempting to convert your system to Rocky Linux. Your system may be unstable. Script will now exit to prevent possible damage.

It appears that the conversion process is trying to execute:

grub2-mkconfig -o /boot/efi/EFI/rocky/grub.cfg

but on Rocky Linux 9 this file is an EFI GRUB wrapper, and the actual GRUB configuration should instead be generated with:

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

The systems are booting in UEFI mode.

An important detail is that I have tested the same conversion procedure on multiple systems:

  • RHEL 8 → Rocky Linux 8: conversion completes successfully and I don’t encounter this GRUB error.
  • RHEL 9 → Rocky Linux 9: conversion fails during the GRUB configuration update with the error shown above.

Has anyone else encountered this issue specifically when converting RHEL 9 systems to Rocky Linux 9?

Is this a known issue or incompatibility in the conversion script related to the GRUB/UEFI configuration used by Rocky Linux 9?

Also, what is the recommended recovery procedure after the conversion stops at this point?

Would manually running:

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

I have not rebooted the affected system after the failed conversion.

Thank you in advance to anyone who can share their experience or provide guidance on the correct procedure to follow.

Manually running grub2-mkconfig -o /boot/grub2/grub.cfg should fix the problem.

After running that, could you please run:

efibootmgr -v
ls -l /boot/efi/EFI/rocky/
grubby --default-kernel

We want to make sure the Rocky kernel is in place for you

Hi @jdieter,

I wanted to provide a final update on this issue.

After comparing the previous version of migrate2rocky9.sh with the latest upstream version, I confirmed that the problem was caused by the incorrect GRUB configuration path:

grub2-mkconfig -o /boot/efi/EFI/rocky/grub.cfg

I noticed that this has now been corrected in the recent commit “Fix EL9 migration recovery and EFI setup”, which uses:

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

I performed another RHEL 9 to Rocky Linux 9 migration using the updated script, and everything completed successfully without any EFI/GRUB errors.

The issue is now resolved.

A special thanks to @jdieter, both for your assistance in this thread and for fixing the migration script.

I also want to thank the entire Rocky Linux community for the continuous support and the great work behind this project.

It’s great to see how quickly issues are addressed and improvements are made.

Thanks again!

So glad to hear that fixed the problem! Thank you for getting back to us!

On the positive side, it did not overwrite that wrapper.


The background:

  • Legacy BIOS loads GRUB, which loads /boot/grub2/grub.cfg
  • UEFI loads GRUB (from ESP, EFI System Partition), which loads /boot/efi/EFI/rocky/grub.cfg

Up to RHEL 8 that was it. The downside was that location of grub.cfg did depend on whether you did boot with legacy or UEFI. That complicated maintenance of grub.cfg.

In RHEL 9 the /boot/efi/EFI/<vendorname>/grub.cfg is a tiny wrapper that does two things:

  • Makes GRUB mount the filesystem that contains the /boot/grub2/grub.cfg file
  • Makes GRUB include the contents of /boot/grub2/grub.cfg into its configuration

As result all[1] RHEL/Rocky 9 and 10 systems have the actual GRUB config in /boot/grub2/grub.cfg

The wrapper is created during installation as it refers to the UUID of the filesystem (that contains the /boot/grub2/grub.cfg file) – unique on every system.


Technically, the grub2-mkconfig -o /boot/efi/EFI/rocky/grub.cfg is not total doom as GRUB will use the resulting grub.cfg in boot, but if user/something does later update the /boot/grub2/grub.cfg, then they will wonder why their changes are ignored.


[1] Caveat: As arch x86_64 user, my “all” does not necessarily cover all architectures.

and also reads the kernel definitions in /boot/loader/entries/ that are then populated in the grub boot menu. This is unique to RH and is called the “Boot Loader System”, “bls” for shortname.
If you edit /etc/default/grub.cfg for kernel parameters then you have to use this format of the mkconfig command:

grub2-mkconfig -o /boot/grub2/grub.cfg --update-bls-cmdline

to also populate the parameters in the /boot/loader/entries/ file(s).

The wrapper, /boot/efi/EFI/rocky/grub.cfg, contains:

configfile $prefix/grub.cfg

while the /boot/grub2/grub.cfg contains lines, like:

  load_env -f ${config_directory}/grubenv

insmod blscfg
blscfg

  source ${prefix}/user.cfg

  source ${config_directory}/custom.cfg

  source $prefix/custom.cfg

Hence I would say that the /boot/grub2/grub.cfg does read grubenv, user.cfg, custom.cfg, and the BLS entries (if any exists), but that the wrapper does not (directly).