ArticlesRocky Linux

Grub2 EFI Update Error

Introduction

On Rocky Linux 9.4 and later, running grub2-mkconfig against efi may fail. A recent grub2 update changed how you should rebuild the GRUB config.

Problem

When attempting to update the GRUB configuration by directly targeting the EFI path, the command fails indicating the file should not be overwritten.

This occurs when running:

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

The command will output the following error, and the configuration will not be updated:

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.

Resolution

To correctly update the GRUB configuration on Rocky Linux 9.4 and newer, you must generate the configuration file in the /boot/grub2/ directory instead of the /boot/efi/EFI/rocky/ directory.

Run the following:

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

This will successfully generate and update the main GRUB configuration file. The EFI stub will automatically load this configuration on boot.

Root Cause

On modern EFI systems, the file at /boot/efi/EFI/rocky/grub.cfg is no longer the main configuration file. Instead, it acts as a simple "stub" or "wrapper" that contains minimal code to load the actual configuration from /boot/grub2/grub.cfg.

This change prevents users from overwriting the critical EFI stub file, which could break the boot process, particularly on systems where that stub is signed for Secure Boot. The error message is an intentional safeguard to enforce the new, safer procedure for updating GRUB configuration.

Related Articles

Rocky Linux System Startup Guide