Difference between revisions of "GRUB/EFI examples"

From ArchWiki
Jump to: navigation, search
(13 intermediate revisions by 6 users not shown)
Line 1: Line 1:
[[Category:Storage]]
+
[[Category:Boot loaders]]
 
{{Article summary start}}
 
{{Article summary start}}
{{Article summary text|It is well know that different motherboard manufactures implement UEFI differently.  Asus is no exception.  Upon completing a wipe, users may find themselves unable to boot.  Below are the steps known to fix the EFI booting of systems with this hardware.}}
+
{{Article summary text|It is well know 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.}}
 
{{Article summary heading|Related Articles}}
 
{{Article summary heading|Related Articles}}
 
{{Article summary wiki|Grub}}
 
{{Article summary wiki|Grub}}
 
{{Article summary end}}
 
{{Article summary end}}
  
=== Asus Z77 Boards ===
+
== Apple Mac EFI systems ==
 +
=== Generic Macs ===
 +
Use bless command from within Mac OS X to set {{ic|grubx64.efi}} as the default boot option. You can also boot from the Mac OS X 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 {{ic|grub.efi}} and on the EFI partition to set them as the default boot options.
 +
 
 +
# bless --folder=/Volumes/efi --file=/Volumes/efi/efi/arch_grub/grubx64.efi --setBoot
 +
# bless --mount=/Volumes/efi --file=/Volumes/efi/efi/arch_grub/grubx64.efi --setBoot
 +
 
 +
More info at https://help.ubuntu.com/community/UEFIBooting#Apple_Mac_EFI_systems_.28both_EFI_architecture.29.
 +
 
 +
{{Note|TODO: GRUB upstream Bazaar mactel branch http://bzr.savannah.gnu.org/lh/grub/branches/mactel/changes. No further update from grub developers.}}
 +
{{Note|TODO: Experimental "bless" utility for Linux by Fedora developers - {{AUR|mactel-boot}}. Requires more testing.}}
 +
 
 +
== Asus ==
 +
=== Z68 Family and U47 Family===
 +
# cp /boot/efi/EFI/arch_grub/grubx64.efi /boot/efi/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 GRUB2 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 uefi partition in /dev/sda1: (read [[Unified_Extensible_Firmware_Interface]])
 +
 
 +
efibootmgr -c -g -d /dev/sda -p 1 -w -L "Archlinux Grub" -l '\EFI\arch_grub\grubx64.efi'
 +
 
 +
If your motherboard has no such option (or even if it does), you can use UEFI shell ([[Unified_Extensible_Firmware_Interface#UEFI_Shell]]) to create a UEFI boot option for the Arch partition temporarily.
 +
 
 +
Once you boot into the EFI shell, add a UEFI boot menu entry:
 +
Shell> bcfg boot add 0 fs1:\EFI\arch_grub\grubx64.efi "Arch Linux (GRUB2)"
 +
where {{ic|fs1}} is the mapping corresponding to the UEFI System Partition and {{ic|\EFI\arch_grub\grubx64.efi}} is the the from the {{ic|--bootloader-id}} from the {{ic|grub-install}} command above.
 +
 
 +
This will temporarily add a UEFI boot option for the next boot to get into Arch. Once in Arch, modprobe {{ic|efivars}} and confirm that {{ic|efibootmgr}} creates no errors (no errors meaning you successfully booted in UEFI mode).  Then [[Grub2#Install_to_UEFI_SYSTEM_PARTITION]] can be performed again and should successfully permanently add a boot entry in the UEFI menu.
 +
 
 +
=== P8Z77 Family ===
 
*Boot to live media and chroot into the target system.
 
*Boot to live media and chroot into the target system.
 
'''FROM WITHIN THE CHROOT'''
 
'''FROM WITHIN THE CHROOT'''
Line 18: Line 52:
 
*Reboot and enter the BIOS (the Delete key will do this).
 
*Reboot and enter the BIOS (the Delete key will do this).
 
*Using the arrow keys, move to the 'exit' menu and drop down to the EFI shell you just downloaded and copied to three places.
 
*Using the arrow keys, move to the 'exit' menu and drop down to the EFI shell you just downloaded and copied to three places.
* You will need to add an entry to your boot menu manually.  Below is an example, see the [[https://wiki.archlinux.org/index.php/UEFI#Launching_UEFI_Shell Launching_UEFI_Shell]] article for more.  Below is an example added a new entry to a menu with 3 current entries.
+
* You will need to add an entry to your boot menu manually.  Below is an example, see the [[UEFI#Launching UEFI Shell]] article for more.  Below is an example added a new entry to a menu with 3 current entries.
 
'''FROM WITHIN THE EFI SHELL'''
 
'''FROM WITHIN THE EFI SHELL'''
 
  Shell> bcfg boot dump -v
 
  Shell> bcfg boot dump -v
Line 26: Line 60:
 
* Navigate to the 'Boot' section and adjust the boot order to your liking with the "Arch Linux (grub manually added)" being the one on your SSD.
 
* Navigate to the 'Boot' section and adjust the boot order to your liking with the "Arch Linux (grub manually added)" being the one on your SSD.
 
* Boot to this entry and enjoy your system.
 
* Boot to this entry and enjoy your system.
 +
 +
=== M5A97===
 +
Finish the standard Arch install procedures, making sure that you install {{Pkg|grub-efi-x86_64}} and partition your boot hard disk as GPT.
 +
 +
From [https://wiki.archlinux.org/index.php/Grub#Install_to_UEFI_system_partition]:
 +
 +
The UEFI system partition will need to be mounted at {{ic|/boot/efi/}} for the GRUB install script to detect it:
 +
 +
# mkdir -p /boot/efi
 +
# mount -t vfat /dev/sdXY /boot/efi
 +
 +
Where X is your boot hard disk and Y is the efi partition you created earlier.
 +
 +
Install GRUB UEFI application to {{ic|/boot/efi/EFI/arch_grub}} and its modules to {{ic|/boot/grub/x86_64-efi}} using:
 +
 +
# modprobe dm-mod
 +
# grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=arch_grub --recheck --debug
 +
# mkdir -p /boot/grub/locale
 +
# cp /usr/share/locale/en\@quot/LC_MESSAGES/grub.mo /boot/grub/locale/en.mo
 +
 +
Generate a configuration for GRUB
 +
 +
# grub-mkconfig -o /boot/grub/grub.cfg
 +
 +
Then copy the [http://dl.dropbox.com/u/17629062/Shell2.zip modified UEFI Shell v2 binary] UefiShellX64.efi into your ESP root.
 +
 +
# cp ~/Shell2/UefiShellX64.efi /mnt/boot/efi/shellx64.efi
 +
 +
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 UEFI app to the bootloader.
 +
 +
Shell> bcfg boot add 3 fs0:\EFI\Arch_Grub\grubx64.efi "Arch_Grub"
 +
 +
where {{ic|fs0}} is the mapping corresponding to the UEFI System Partition and {{ic|3}} is the zero based boot entry index.
 +
 +
To list the current boot entries you can run:
 +
 +
Shell> bcfg boot dump -v
 +
 +
== Intel ==
 +
=== S5400 Family ===
 +
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 i386 only. The normal procedure for UEFI installation can be followed, with the exception of the following changes.
 +
* Instead of using the {{ic|grub-efi-x86_64}} package, {{ic|grub-efi-i386}} has to be used
 +
* The {{ic|bcfg}} command is not available for pre-UEFI (v2.0) firmware. A {{ic|startup.nsh}} file can be used on the root of the EFI partition containing the path to the bootloader. For example:
 +
{{ic|fs0:\EFI\arch_grub\boot.efi}}
 +
has to be placed in the {{ic|startup.nsh}} file on the root of the EFI partition.
 +
* The {{ic|grub.cfg}} file has to be placed in the same directory as the grub EFI file, otherwise grub will not find it and enter the interactive shell

Revision as of 19:49, 9 June 2013

Template:Article summary start Template:Article summary text Template:Article summary heading Template:Article summary wiki Template:Article summary end

Apple Mac EFI systems

Generic Macs

Use bless command from within Mac OS X to set grubx64.efi as the default boot option. You can also boot from the Mac OS X 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 partition to set them as the default boot options.

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

More info at https://help.ubuntu.com/community/UEFIBooting#Apple_Mac_EFI_systems_.28both_EFI_architecture.29.

Note: TODO: GRUB upstream Bazaar mactel branch http://bzr.savannah.gnu.org/lh/grub/branches/mactel/changes. No further update from grub developers.
Note: TODO: Experimental "bless" utility for Linux by Fedora developers - mactel-bootAUR. Requires more testing.

Asus

Z68 Family and U47 Family

# cp /boot/efi/EFI/arch_grub/grubx64.efi /boot/efi/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 GRUB2 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 uefi partition in /dev/sda1: (read Unified_Extensible_Firmware_Interface)

efibootmgr -c -g -d /dev/sda -p 1 -w -L "Archlinux Grub" -l '\EFI\arch_grub\grubx64.efi'

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

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

Shell> bcfg boot add 0 fs1:\EFI\arch_grub\grubx64.efi "Arch Linux (GRUB2)"

where fs1 is the mapping corresponding to the UEFI System Partition and \EFI\arch_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 Grub2#Install_to_UEFI_SYSTEM_PARTITION can be performed again and should successfully permanently add a boot entry in the UEFI menu.

P8Z77 Family

  • Boot to live media and chroot into the target system.

FROM WITHIN THE CHROOT

# mount -t vfat /dev/sdXY /boot/efi
# grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=arch --recheck
# grub-mkconfig -o /boot/grub/grub.cfg
# mkdir /boot/efi/boot && cd /boot/efi
# wget https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/ShellBinPkg/UefiShell/X64/Shell.efi
# cp Shell.efi shellx64.efi && cp Shell.efi /boot/efi/boot
# umount /boot/efi
  • Reboot and enter the BIOS (the Delete key will do this).
  • Using the arrow keys, move to the 'exit' menu and drop down to the EFI shell you just downloaded and copied to three places.
  • You will need to add an entry to your boot menu manually. Below is an example, see the UEFI#Launching UEFI Shell article for more. Below is an example added a new entry to a menu with 3 current entries.

FROM WITHIN THE EFI SHELL

Shell> bcfg boot dump -v
Shell> bcfg boot add 3 fs0:\EFI\arch\grubx64.efi "Arch Linux (grub manually added)"
Shell> exit
  • Reboot the machine and enter the BIOS.
  • Navigate to the 'Boot' section and adjust the boot order to your liking with the "Arch Linux (grub manually added)" being the one on your SSD.
  • Boot to this entry and enjoy your system.

M5A97

Finish the standard Arch install procedures, making sure that you install grub-efi-x86_64 and partition your boot hard disk as GPT.

From [1]:

The UEFI system partition will need to be mounted at /boot/efi/ for the GRUB install script to detect it:

# mkdir -p /boot/efi
# mount -t vfat /dev/sdXY /boot/efi

Where X is your boot hard disk and Y is the efi partition you created earlier.

Install GRUB UEFI application to /boot/efi/EFI/arch_grub and its modules to /boot/grub/x86_64-efi using:

# modprobe dm-mod
# grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=arch_grub --recheck --debug
# mkdir -p /boot/grub/locale
# cp /usr/share/locale/en\@quot/LC_MESSAGES/grub.mo /boot/grub/locale/en.mo

Generate a configuration for GRUB

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

Then copy the modified UEFI Shell v2 binary UefiShellX64.efi into your ESP root.

# cp ~/Shell2/UefiShellX64.efi /mnt/boot/efi/shellx64.efi

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 UEFI app to the bootloader.

Shell> bcfg boot add 3 fs0:\EFI\Arch_Grub\grubx64.efi "Arch_Grub"

where fs0 is the mapping corresponding to the UEFI System Partition and 3 is the zero based boot entry index.

To list the current boot entries you can run:

Shell> bcfg boot dump -v

Intel

S5400 Family

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 i386 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 package, 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 partition containing the path to the bootloader. For example:

fs0:\EFI\arch_grub\boot.efi has to be placed in the startup.nsh file on the root of the EFI partition.

  • The grub.cfg file has to be placed in the same directory as the grub EFI file, otherwise grub will not find it and enter the interactive shell