What is the correct command to use to update grub after editing the kernel's menu entries?

My system is UEFI and the version of Fedora is 37, 64bit.

I use the following command to edit grub:

sudo nano /etc/default/grub

Results of Google Search have given me two different ways to update grub. They are:

  1. sudo grub2-mkconfig -o /etc/grub2.cfg

    followed by

    sudo grub2-mkconfig -o /etc/grub2-efi.cfg

    reboot machine

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

    reboot machine

Which is correct: (1) or (2)?


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

/etc/grub2.cfg and /etc/grub2-efi.cfg are links to /boot/grub2/grub.cfg

/boot/efi/EFI/fedora/grub.cfg is used to point to /boot/grub2/grub.cfg

ref: https://fedoraproject.org/wiki/Changes/UnifyGrubConfig

1 Like

Your answer is that both (1) and (2) are correct…

Thanks for the wiki, Joe.

P.S.: Debian’s command to update grub is so much simpler. It’s just sudo update-grub

1 Like

True, but you can always alias it.

1 Like

Hey @grumpey can I also get some answers to my ticket? Thanks

I am puzzled why Fedora does not “aliased” it.

Debian has “aliased” it so that all Debian-based distros such as Ubuntu used it “universally”.

No. (1) did the same (correct) job twice. Either half of (1) gets it done.

(2) was incorrect. /boot/efi/EFI/fedora/grub.cfg is a file, not a link. The main purpose of that file is to tell grub2 how to find grub2/grub.cfg (which partition it is in). Your command incorrectly puts the contents that should be in grub2/grub.cfg into EFI/fedora/grub.cfg instead. That might then seem to work (or might be badly messed up). But even if it seems to work, unless something later restores or corrects the EFI/fedora/grub.cfg file, future automatic updates will be messed up.


According to GRUB 2, sub-heading " Updating the GRUB configuration file" …I quote:

Use the following commands:

sudo grub2-mkconfig -o /etc/grub2.cfg

sudo grub2-mkconfig -o /etc/grub2-efi.cfg

It seems to readers that they have to execute both these commands in sequence, yes? The statement does not say “Use either one of the following commands”…

Thanks very much for the warning. I guess the best fix now is to re-install the distro.

sudo dnf reinstall grub2-efi* grub2-common will restore /boot/efi/EFI/fedora/grub.cfg

As an example, on my install, that file contains:

search --no-floppy --fs-uuid --set=dev 859aa50d-cd9b-4103-bc73-7a192dbef8e0
set prefix=($dev)/grub2

export $prefix
configfile $prefix/grub.cfg

Edit fixed, thanks @john2fx


You don’t need anything that drastic. I expect the answer Joe gave is correct on how to use the standard tools to replace that file (I generally don’t do it that way myself)

But I assume you accidentally failed to show half that file. Otherwise, what you showed must not be whatever is actually in use on your system.

It should be something like:

search --no-floppy --fs-uuid --set=dev c6bdae4c-c458-4c1f-8e05-7b66eddadcbf
set prefix=($dev)/grub2

export $prefix
configfile $prefix/grub.cfg

I would fix one simply by copying that and editing in the correct UUID (of your boot partition). There are many easy ways to discover the UUID of your boot partition. It is typically in /etc/fstab as the way that partition gets mounted.

So either to check whether the command Joe gave you worked, or to fix things if it didn’t, you could just edit the right contents into that file (5 lines including the unnecessary blank line in the middle, that tools put there by default).

1 Like

What does the asterisk after grub2-efi signify?

If will re-install anything you have installed that matches that regex.

1 Like

The command sudo dnf list grub2-efi* gives information that might help you understand what would be (or was) done by the command Joe gave you.

1 Like

Until recently the path to grub.cfg file was different on UEFI and BIOS based systems.

Please take note of the following Docs page Working with the GRUB 2 Boot Loader :: Fedora Docs

This works under one condition only.
The user must first remove the existing /boot/efi/EFI/fedora/grub.cfg and /boot/grub2/grub.cfg. At that point the reinstall will create both files with the proper content. If the files already exist they will not be overwritten.


Sorry for reopening this thread that is very old, but on fedora if you were to run ls -l /etc/grub*cfg you would find this. Very clearly symlinks (aliases) that both point to the same grub.cfg file.

# ls -l /etc/grub*cfg
lrwxrwxrwx. 1 root root 22 May 28 19:00 /etc/grub2.cfg -> ../boot/grub2/grub.cfg
lrwxrwxrwx. 1 root root 22 May 28 19:00 /etc/grub2-efi.cfg -> ../boot/grub2/grub.cfg

I will close this thread after this post.