You are here

GRUB for EFI Systems

Installing and configuring GRUB for an EFI system is a simple matter of a few commands to make the EFI System partition available, to install the appropriate version of the GRUB package, to install GRUB (the bootloader not the package) in the EFI System partition, and to update the configuration. The steps given here can be used to repair GRUB, to install and configure GRUB for EFI on distributions that don't do it for you in the installe -- such as Tanglu 1.0. On a multi-boot system with multiple GRUB bootloaders installed, this process can also be used to update the GRUB of one installation after kernel updates in another installation. Commands have been given for several systems -- Tanglu, based on Debian, Sabayon, based on Gentoo, openSUSE, and Arch -- to illustrate that using GRUB for EFI systems is fairly standard.


The steps outlined here are ususally not necessary in a reliable system like Ubuntu and its derivatives which use its tools, or openSuSE which was one of the first distributions to support EFI systems. It may be necessary in other systems where ocassionally, a reconfiguration after a kernel update may cause the list of operating systems to boot in the GRUB menu to be incomplete. It may also be necessary in a system where EFI installation may not be available on an installer in a distribution that otherwise supports EFI systems, such as Tanglu.

I have run into both cases, the first on a Sabayon system, where my Voyager installation wasn't listed in the Sabayon installed GRUB after a Sabayon kernel update. The second when installing Tanglu 1.0 which doesn't support EFI installation from their live installer. In this case I installed Tanglu that had several working GRUB EFI bootloaders from other Linux installations on my multi boot laptop by booting the installation ISO DVD in EFI mode from Windows Boot Manager and using the live installer to install Tanglu without mounting the EFI system partition or installing the GRUB bootloader. I could then boot Tanglu in EFI mode by reconfiguring the GRUB of the other installations to include Tanglu in their menus.

The EFI Partition's Role in Using GRUB

To use the EFI version of GRUB -- many distributions have an EFI version and a non-EFI version of GRUB 2 -- there has to be an EFI System partition available on the system, as this is where this version of GRUB is installed. This partition already exists in computers preinstalled with Windows 8/8.1. It can be created in computers with prior versions of Windows along with configuring the disk to use a GPT partition table, but will require a clean install of Windows. The EFI System partition has to be formatted in FAT32 and has to have the "boot" flag set when viewed with parted.

parted list of partitions
Partition 2 is shown with the label EFI SYSTEM and with the "boot" flag.

or "EF00" when viewed with gdisk.

gdisk list of partitions
Partition 2 is shown with the label EFI system and with the "EF00" flag.

The second requirement for this partition is that it must be mounted for the installed system, and is added to /etc/fstab by EFI capable installers as part of the GRUB installation long as the proper flag, mentioned above, is present. But when installing GRUB for the first time or reinstalling from an already running system, you should verify that the EFI partition is mounted and mount it, if it is not. This can be done as root, or with sudo, by entering:

mount /dev/sda2 /boot/efi

Be sure to change /dev/sda2 to the device name of your own EFI partition, in my case it is /dev/sda2.

The process of installing GRUB to the EFI system partition writes to the firmware to make this partition available for booting.

Contents of EFI directory within the EFI System Partition
The contents of the EFI directory in/boot/efi, the mount point of the EFI System Partition

Installing the Appropriate GRUB Package

The GRUB package specifically for EFI systems or a version of GRUB that is appropriate for both EFI and non EFI systems needs to be installed; the latter is usually called GRUB2 as opposed to GRUB or GRUB-LEGACY. For example, the current version of this package for Tanglu is grub-efi-amd64. On other systems it may have "EFI" in the name to indicate that it is the EFI version or it may be version 2.xxxx as opposed to version 0.9x or something close. The version of GRUB at or neat version 0.99 is the GRUB legacy and will not work for EFI systems.

Distribution GRUB for EFI package name
Manjaro grub 2.02beta2-8.2
Sabayon sys-boot/grub-2.00-r6
openSUSE grub 2.02~beta2
Tanglu grub-efi-2.02~beta2-17
ROSA grub2-efi-2.00-60-rosa2014.1

Before installing the bootloader you should confirm that the computer was booted in EFI mode. This can be done with:

[ -d /sys/firmware/efi ] echo "EFI boot on HDD" || echo "Legacy boot on HDD"

If the system was booted in EFI mode, this command will return:

EFI boot on HDD

and if it was not booted in EFI mode,

Legacy boot on HDD

The Debian wiki chose to echo "EFI boot on HDD" for a positive confirmation and "Legacy boot on HDD", but you can use any other text.

Then install the GRUB package with whatever is appropriate for your distribution with the customary method of aquiring administrative privliges for your distribution. If the distribution has separate packages for EFI and non-EFI systems, as do Debian and its derivatives, be sure to install the EFI version. In Tanglu the appropriate command is:

sudo apt-get install grub-efi-amd64

On Sabayon, in binary package management mode, the command as root is:

equo install grub
Distribution command to install the grub package
pacman -S grub
equo install grub
zypper install grub
apt-get install grub-efi-amd64
urpmi grub2-efi

Installing the GRUB Bootloader to EFI Partition and EFI Firmware

The next step is to install the bootloader to the EFI partition. The same command will also install it to the EFI firmware, so it will show up as a firmware device in the EFI settings -- and by extension in the Windows BCD store -- making it available when powering on the computer to then load the installed OSes. The command is some form of grub-install [options] or grub2-install [options]. The table below shows the specific command for some distributions.

Distribution command to install GRUB to ESP
Arch and Derivtives (e.g. Antergos, Manjaro)
grub-install --target=x86_64-efi --efi-directory=$esp --bootloader-id=grub_uefi --recheck
for example, in my case, for Arch,
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=arch --recheck
grub2-install --target=x86_64-efi
grub2-install --target=x86_64-efi

It is beneficial to examine the full generic version of this command for the version of GRUB in Arch and its derivatives,

grub-install --target=x86_64-efi --efi-directory=$esp --bootloader-id=grub_uefi --recheck

The $esp, above refers to EFI system partition mount point, which should be mounted before this command. In most distributions this $esp must be /boot/efi and this command option may not even be available. --bootloader-id=grub_uefi sets the name of the directory created in $esp/EFI. In most distributions this may not be an option either, and the name of the directory is automatically set as the distribution name in all lower-case.

The Debian wiki states that the installation can be verifed with:

file /boot/efi/EFI/debian/grubx64.efi

which uses the file command to verify the GRUB .efi executable exists in the appropriate location. The appropriate distribution name would be substituted for "debian" in the above command. And in the case of Arch, "/boot/efi" would be substituted with whatever was specified by the option "--efi-directory" and "debian" would be replaced with what was specified by the option "--bootloader-id" On Tanglu without a proper root account, it is necessary to use sudo again with:

sudo file /boot/efi/EFI/tanglu/grubx64.efi

The result for a proper installation on Debian is:

/boot/efi/EFI/debian/grubx64.efi: PE32+ executable (EFI application) x86-64 (stripped to external PDB), for MS Windows

On my Tanglu installation, I get the same but with "tanglu" instead of "debian" as it should be and on my Arch installation it is:

/boot/efi/EFI/arch/grubx64.efi: PE32+ executable (EFI application) x86-64 (stripped to external PDB), for MS Windows

Configuring or Updating the GRUB Bootloader

The following step is necessary for GRUB to actually offer its menu after reboot including the other OSes installed on the system. It is also necessary after updating kernels if the distribution does not automatically perform this step or after modifying the /etc/defaults/grub file. On Tanglu or Debian systems enter

sudo update-grub

on Sabayon and Gentoo, enter

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

This GRUB reconfiguration step is the only one that is completely different between Debian systems and others, in that the command is entirely different instead of being some variation of the same command. The non-Debian distributions also require the GRUB .cfg file as an input to the command, where Debian doesn't need such a file. The commands are listed in the following table for some distributions. Note that the non Debian based distributions are generally the same with only subtle differneces.

Distribution command to install GRUB to ESP
Tanglu and other Debian based distros including Ubuntu
sudo update grub
Arch and Derivtives (e.g. Manjaro)
grub-mkconfig -o /boot/grub/grub.cfg
grub2-mkconfig -o /boot/grub/grub.cfg
grub2-mkconfig -o /boot/grub2/grub.cfg


Hopefully, this overview has shown clearly how easy it is to install or reinstall and configure the EFI version of GRUB when confronted with the necessity of repairing a GRUB configuration for EFI or when not properly handeled by an installer for EFI systems. The steps are standard among various distributions and involve making the EFI System partition available, installing the appropriate version of the GRUB package, installing GRUB, the bootloader not the package on the system, and updating the configuration.

The Debian, Gentoo, and Arch wikiwikis; the Debian forum, and the openSUSE active documentation chapter on GRUB2 may be useful in learning more.