There are bazillions of grub2/EFI threads on the net, but I found it difficult to find an answer to the question above. We have been told that in grub2 the configuration file is /boot/grub/grub.cfg. But when there are boot problems grub2 might end up in a command prompt (aka emergency shell) without any error message. So before being able to solve any problems it would be nice to understand how grub2 exactly tries to locate its configuration file.

1 Answer 1


The first thing to understand that there is no fixed way. grub2 can be configured differently during installation and the name grub.cfg is by no way hard-coded. The second learning is that there is no single configuration file, e. g. my Ubuntu system at the time of writing uses 2 different files in sequence, both actually named grub.cfg.

By default grub2 does 2 essential things when starting:

  1. set the prefix variable to a value built-in during grub2 installation
  2. continue with configuration file $prefix/grub.cfg if it exists

(for more details refer to http://www.gnu.org/software/grub/manual/grub.html#GRUB-only-offers-a-rescue-shell )

The "if it exists" condition is the nasty one: If the file does not exist (e.g. because $prefix is not pointing to the right place) there is no error message what it tried to do and you just end up in the command prompt.

If you end up in the emergency shell the first things to check is the value of the prefix variable (using set command) and the contents of that directory (using ls and cat commands).

(The default behaviour could be overwritten by a built-in configuration file, but I don't think I have seen that used in practice.)

Ubuntu sets the prefix to the same place where the grubx64.efi and the shimx64.efi used for secure boot are located. So the first configuration file grub.cfg is loaded from the same directory where these EFI binaries reside. From Linux perspective the path is /boot/efi/EFI/ubuntu and from grub2 perspective (hd0,gpt1)/efi/ubuntu (the drive and partition numbers might vary depending on where your ESP i.e. EFI system partition is located, filenames in grub2 seem to be case insensitive so the EFI shown by Linux is shown as efi by grub2).

The first grub.cfg file contains only 3 statements:

  1. locate the partition containing the root file system by UUID (in systems using a separate boot file system locate the boot file system instead)
  2. set prefix to a new value of $root/boot/grub (using the $root value determined in the previous step, for systems with a separate boot partition this should be $root/grub)
  3. execute the configfile from location $prefix/grub.cfg

The latter is the Linux location /boot/grub/grub.cfg, which we are usually told.

  • its pretty good information, but why do you put up w/ all that jazz? why not just uninstall it?
    – mikeserv
    Dec 29, 2015 at 19:06

You must log in to answer this question.

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