GRUB/EFI examples

From ArchWiki

The factual accuracy of this article or section is disputed.

Reason: Many of the examples below indicate that the GRUB EFI binary (grubx64.efi) needs to be copied to a special location (e.g, esp/EFI/BOOT/bootx64.efi). Although this may work, this is the fallback filename. Other options may also work, like using efibootmgr or UEFI shell. (Discuss in Talk:GRUB/EFI examples)

It is well known that different motherboard manufactures implement UEFI differently. The purpose of this page is to show hardware-specific methods known to work when installing/restoring GRUB in EFI mode.

Note: In the entire article esp denotes the mountpoint of the EFI system partition aka ESP.

Acer

Aspire V3-571G (Possibly other Aspire One laptops as well)

Some variations of this laptop have a only partial EFI compatibility due to originally shipping with Windows 7 only. Later revisions of this laptop shipped with more complete UEFI compatibility. Due to this the earlier revisions can only boot GRUB if it is placed where the Windows bootloader binary is expected (esp/EFI/BOOT/bootx64.efi). However the binary can only be booted manually from the boot menu (on key F12), likely because it is missing Microsoft signatures. A solution to this problem is to upgrade to the newer version of the system firmware, however the process is not straight forward as earlier revisions of the machine are locked out of upgrading for some reason.

Warning: This can potentially render your machine permanently inoperational if done incorrectly! Proceed with caution.

The following steps can be taken to bypass the restriction and upgrade to a later revision firmware:

  • Acquire an incompatible 2.x version of the BIOS firmware for the same model machine from Acer[dead link 2023-04-23 ⓘ] Acer CDN direct linkArchive.org mirror.
  • Extract the archive to obtain the flasher executable (eg. Q5WV1221.exe).
  • Open this executable in a hex editor of your choice (a good simple one is ghex).
  • In the hex editor search for the block flag string DisableSecureCapsuleFlash=1.
  • Change the ASCII string so that it becomes DisableSecureCapsuleFlash=0 (That's changing the last byte from hex 31 to 30).
  • Save the modified binary.
  • Obtain a copy of FreeDOS, flash it to a boot media and put your modified binary on the boot media as well (more on that here Flashing BIOS from Linux#FreeDOS)
  • Run your modified binary from within FreeDOS and follow the instructions on screen. Upon completion you should have your firmware upgrade to the officially unsupported 2.x version.
  • You can now install GRUB normally as described here GRUB#UEFI systems.

More info:

Apple Macs

Use bless command from within macOS to set grubx64.efi as the default boot option. You can also boot from the macOS install disc and launch a Terminal there if you only have Linux installed. In the Terminal, create a directory and mount the EFI system partition:

# cd /Volumes
# mkdir efi
# mount -t msdos /dev/disk0s1 /Volumes/efi

Then run bless on grub.efi and on the EFI system partition to set them as the default boot options.

# bless --folder=/Volumes/efi --file=/Volumes/efi/EFI/GRUB/grubx64.efi --setBoot
# bless --mount=/Volumes/efi --file=/Volumes/efi/EFI/GRUB/grubx64.efi --setBoot

Asus

Z68 Family and U47 Family

# cp esp/EFI/GRUB/grubx64.efi esp/shellx64.efi

After this launch the UEFI Shell from the UEFI setup/menu (in ASUS UEFI BIOS, switch to advanced mode, press Exit in the top right corner and choose "Launch EFI shell from filesystem device"). The GRUB menu will show up and you can boot into your system. Afterwards you can use efibootmgr to setup a menu entry, for example if you have the EFI system partition on /dev/sda1:

# efibootmgr --create --disk /dev/sda --part 1 --write-signature --loader /EFI/GRUB/grubx64.efi --label "GRUB" --verbose

If your motherboard has no such option (or even if it does), you can use UEFI shell to create a UEFI boot option for the Arch partition temporarily.

Once you boot into the UEFI shell, add a UEFI boot menu entry:

Shell> bcfg boot add 0 FS0:\EFI\GRUB\grubx64.efi "GRUB"

The factual accuracy of this article or section is disputed.

Reason: Refers to a grub-install command, but the one above is using efibootmgr? (Discuss in Talk:GRUB/EFI examples)

where FS0: is the mapping corresponding to the EFI system partition and \EFI\GRUB\grubx64.efi is the the from the --bootloader-id from the grub-install command above.

This will temporarily add a UEFI boot option for the next boot to get into Arch. Once in Arch, modprobe efivars and confirm that efibootmgr creates no errors (no errors meaning you successfully booted in UEFI mode). Then GRUB installation can be performed again and should successfully permanently add a boot entry in the UEFI menu.

ux32vd

Note: The BIOS does not allow computer to boot from GPT disk if there is no properly set-up UEFI boot entry. The disk even may not be seen in BIOS in this case. The fix is to make a proper UEFI boot entry.

There is a caveat. If the machine was booted from MBR then grub-install (or efibootmgr) will fail to create the UEFI boot entry with the following error:

EFI variables are not supported on this system

You first need to boot the machine with EFI and then create the boot entry. This can be done the way described for Z68 Family: by copying esp/EFI/GRUB/grubx64.efi into esp/shellx64.efi and selecting "Launch EFI shell from filesystem device". After successful boot it is possible to create a boot entry using grub-install or efibootmgr.

P8Z77 Family

The factual accuracy of this article or section is disputed.

Reason: This procedure is most likely no longer necessary and you can just create the entry via efibootmgr. (Discuss in Talk:GRUB/EFI examples)

Install GRUB and copy the modified UEFI Shell binary to ESP.

The EFI system partition should contain just two files:

/Shell.efi
/EFI/GRUB/grubx64.efi

Within UEFI shell

Shell> bcfg boot dump -v
Shell> bcfg boot add 1 FS0:\EFI\GRUB\grubx64.efi "GRUB"
Shell> exit
  • Reboot the machine and enter the BIOS.
  • Navigate to the Boot section and adjust the boot order to with the "GRUB" being the one on the SSD.
  • Boot to this entry and enjoy.

M5A97

Finish the standard Arch install procedures, making sure that you partition your boot hard disk as GPT.

Install GRUB and copy the modified UEFI Shell binary to ESP.

The reason that we need this shell application is that the efibootmgr command will fail silently during grub-install.

After this launch the UEFI Shell from the UEFI setup/menu (in ASUS UEFI BIOS, switch to advanced mode, press Exit in the top right corner and choose "Launch EFI shell from filesystem device"). The UEFI shell will show up. From here we need to add our GRUB entry to the NVRAM.

Shell> bcfg boot add 3 FS0:\EFI\GRUB\grubx64.efi "GRUB"

where FS0: is the mapping corresponding to the EFI system partition and 3 is the zero based boot entry index.

Tip: UEFI Shell commands usually support -b option which makes output pause after each page. map lists recognized filesystems (fs0, ...) and data storage devices (blk0, ...). Run help -b to list available commands. See Unified Extensible Firmware Interface#Important UEFI Shell commands for more information.

To list the current boot entries you can run:

Shell> bcfg boot dump -v

Asrock

Z97M Pro4

The factual accuracy of this article or section is disputed.

Reason: If efibootmgr works when launched from the installed system, why would it not work when grub-install executes it? (Discuss in Talk:GRUB/EFI examples)

This is a similar procedure to Asus Z68 Family. This was tested on a Z97M Pro4 BIOS P1.90.

# cp esp/EFI/GRUB/grubx64.efi esp/shellx64.efi

After this launch the UEFI Shell from the UEFI setup/menu (in ASROCK UEFI BIOS, goto Exit tab and choose "Launch EFI Shell From Filesystem Device"). The GRUB menu will show up and you can boot into your system. Afterwards you can use efibootmgr to setup a menu entry, for example if you have the EFI system partition on /dev/sda1:

# efibootmgr --create --disk /dev/sda --part 1 --write-signature --loader /EFI/GRUB/grubx64.efi --label "GRUB" --unicode

Dell

PowerEdge T30

The Dell UEFI implementation needs the UEFI firmware workaround to load grub. Otherwise it will drop into a "no OS found" screen.

Latitude E7450

In addition to the UEFI firmware workaround (without which GRUB is not launched), the Dell Latitude seems to require to have the EFI system partition mounted on /boot. When ESP is mounted on /efi, GRUB fails to find the configuration files and launches the rescue console.

MSI

These MSI motherboards seem to want the EFI program to exist in a different location from where GRUB installs it. Do one of the following after following the instructions for installing GRUB:

B250M PRO-VH

# mkdir esp/EFI/BOOT
# cp esp/EFI/grub/grubx64.efi esp/EFI/BOOT/shellx64.efi

B150 PC MATE / B250 PC MATE / H110I PRO / Z370 GAMING PLUS / MPG B760I EDGE WIFI

Install GRUB to the default/fallback boot path.

HP

EliteBook 840 G1 & Probook 6570b

See HP EliteBook 840 G1#UEFI Setup for details.

Note: The procedures in the link above probably also work for a range of other HP models.

Intel

S5400 Family

This article or section needs expansion.

Reason: Does it support booting from the default/fallback boot path esp/EFI/BOOT/BOOTia32.efi? If it does, the instructions could be simplified. (Discuss in Talk:GRUB/EFI examples)

This board can run in BIOS or in EFI mode. BIOS mode requires an MBR partitioned hard drive, EFI - a GPT hard drive. Please note that this board operates on the Intel EFI v1.10 specification, and is IA32 (32-bit) only. The normal procedure for UEFI installation can be followed, with the exception of the following changes.

  • Instead of using the grub-efi-x86_64 target, grub-efi-i386 has to be used
  • The bcfg command is not available for pre-UEFI (v2.0) firmware. A startup.nsh file can be used on the root of the EFI system partition containing the path to the bootloader. For example: FS0:\EFI\GRUB\grubia32.efi has to be placed in the startup.nsh file on the root of the EFI system partition.
  • The grub.cfg file has to be placed in the same directory as the grub EFI binary, otherwise GRUB will not find it and enter the interactive shell.

Lenovo

K450 IdeaCentre

The EFI system partition requires the file \EFI\BOOT\BOOTx64.efi to be present in order to boot, otherwise you will receive "Error 1962: No operating system found. Boot sequence will automatically repeat."

Install GRUB to the default/fallback boot path.

This is a workaround for what is likely a bug in the UEFI implementation.

M92p ThinkCentre

This system whitelists UEFI boot entries. It will boot from a entry called "Red Hat Enterprise Linux" or "Windows Boot Manager"(Jan. 2021). So specify the bootloader-id appropriately:

# grub-install --target=x86_64-efi --efi-directory=esp --bootloader-id="Red Hat Enterprise Linux" --recheck --debug

or

# grub-install --target=x86_64-efi --efi-directory=esp --bootloader-id="Windows Boot Manager" --recheck --debug

It is also possible to edit your EFI config with efibootmgr. First, list your boot entries:

# efibootmgr

Delete old entry for Windows Boot Manager:

# efibootmgr -Bb 0000

Now create a new bootentry which points to your desired bootloader on your hard drive. Be aware: -p defines on which partition your EFI system partition lies.

# efibootmgr -c -d /dev/sda -p 1 -L "Windows Boot Manager" -l "\EFI\boot\grubx64.efi"

This will set up your EFI to boot the entry "Windows Boot Manager" and load the grub bootloader.

X270 Thinkpad

The factual accuracy of this article or section is disputed.

Reason: There is no need to do anything special for UEFI booting on this laptop. (Discuss in Talk:GRUB/EFI examples#X270)

Install GRUB to the default/fallback boot path.