Unified Extensible Firmware Interface

From ArchWiki
Revision as of 18:16, 16 August 2010 by Rransom (Talk | contribs) (Linux Bootloaders for UEFI: use Template:Package AUR (see Category:Template for other templates))

Jump to: navigation, search

Unified Extensible Firmware Interface (or UEFI for short ) is a new type of firmware that was initially designed by Intel (as EFI) mainly for its Itanium based systems. It introduces new ways of booting an OS that is distinct from the commonly used "MBR boot code" method followed for BIOS systems. It started as Intel's EFI upto version 1.1 and then a group of companies called the UEFI forum took over its development from which it was called Unified EFI starting with version 2.0 . As of 22 May 2010, UEFI Specification 2.3 is the most recent version.

Note: This article is not a Apple-Intel Mac specific one. It applies to any system using (U)EFI firmware like Sony Vaio Z series, HP EliteBooks, some Dell servers etc. Apple's EFI implementation is neither a EFI 1.1 version nor UEFI 2.x version but includes features of both. This kind of firmware does not fall under any one UEFI version so it is not a standard EFI firmware.

Booting an OS using BIOS

A BIOS or Basic Input-Output System is the very first program that is executed once the system is switched on. After all the hardware are initialized and the POST operation is completed, the BIOS executes the first boot code in the first device in the device booting list.

If the list starts with a CD/DVD drive, then the El-Torito entry in the CD/DVD is executed. This is how bootable CD/DVD works. If the list starts with a HDD, then BIOS executes the very first 440 bytes MBR boot code. The boot code then chainloads or bootstraps a much larger and complex bootloader which then loads the OS.

Basically, the BIOS does not know how to read a partition table or filesystem. All it does is initialize the hardware, then load and run the 440-byte boot code.

Multi-booting using BIOS

Since very little can be achieved by a program which fits into the 440-byte boot code area, multi-booting using BIOS requires a multi-boot capable bootloader (multi-boot refers to booting multiple operating systems, not to booting a kernel in the Multiboot format specified by the GRUB developers). So usually a common bootloader like GRUB or LILO would be loaded by the BIOS, and it would load an operating system by either chain-loading or directly loading the kernel.

Booting an OS using (U)EFI

(U)EFI firmware does not support booting through the above mentioned method which is the only way supported by BIOS. UEFI has support for reading both the partition table as well as understanding filesystems.

The commonly used UEFI firmwares support both MBR and GPT partition table. EFI in Apple-Intel Macs are known to support Apple Partition Map also apart from MBR and GPT. Most of the UEFI firmwares have support for accessing FAT12 (floppy disks) , FAT16 and FAT32 filesystems in HDD and ISO9660 (and UDF) in CD/DVDs. EFI in Apple-Intel Macs can access HFS/HFS+ filesystems also apart from the mentioned ones.

UEFI does not launch any boot code in the MBR whether it exists or not. Instead it uses a special partition in the partition table called "EFI SYSTEM PARTITION" in which files required to be launched by the firmware is stored. Each vendor can store its files under <EFI SYSTEM PARTITION>/EFI/<VENDOR NAME>/ folder and can use the firmware or its shell (EFI shell) to launch the boot program. An EFI System Partition is usually formatted as FAT32.

Under UEFI, every program whether they are OS loaders or some utilities (like memory testing apps) or recovery tools outside the OS, should be a UEFI Application corresponding to the EFI firmware architecture. Most of the UEFI firmware in the market, including recent Apple Macs use x86_64 EFI firmware. Only some older macs use i386 EFI firmware while no non-Apple UEFI system is known to use i386 EFI firmware.

A x86_64 EFI firmware does not include support for launching 32-bit EFI apps unlike the 64-bit Linux and Windows which include such support. Therefore the bootloader must be compiled for that architecture correctly.

Multi-booting using UEFI

Since each OS or vendor can maintain its own files within the EFI SYSTEM PARTITION without afffecting the other, multi-booting using UEFI is just a matter of launching a different UEFI application corresponding to the particular OS's bootloader. This removes the need for relying on chainloading mechanisms of one bootloader to load another to switch OSes.

Multi-booting Linux on UEFI with Windows

Windows Vista (SP1+) and 7 x64 versions support booting natively using UEFI firmware. But for this they need GPT partitioning of the HDD used for UEFI booting. Windows x64 versions support either UEFI-GPT booting or BIOS-MBR booting. Windows 32-bit versions support only BIOS-MBR booting. Follow the instructions provided in the forum link given in the references sections as to how to do this.

This limitation does not exist in Linux as linux supports all 4 combinations of booting - UEFI-GPT, UEFI-MBR, BIOS-GPT, BIOS-MBR. If Linux and Windows are in the same HDD and boot using UEFI, then the linux bootloader must be configured to boot from GPT. This is a limitation of Windows, not Linux.

Linux Kernel Configuration for UEFI

Incase of linux, kernel support for EFI is very important. For this the following options in kernel configuration should be enabled :

CONFIG_EFI - Should be built-in in the kernel, not compiled as module

CONFIG_EFI_VARS - UEFI Runtime Variables Support - Enables UEFI Runtime services support in linux kernel. This is optional (ie. can be compiled as a module), but it is still recommended to be compiled as built-in in the kernel.

CONFIG_EFI_PARTITION - enables GUID Partition Table support in the kernel, required if compiling for UEFI systems.

Note 1: For Linux to access UEFI Runtime Services, the UEFI Firmware processor architecture and the Linux kernel processor architecture must match. This is independent of the bootloader used and its compiled processor architecture.

Note 2: If the UEFI Firmware arch and Linux Kernel arch are different, then the "noefi" kernel parameter must be used to avoid the kernel panic and boot successfully. The "noefi" option instructs the kernel not to access the UEFI Runtime Services.

Linux Bootloaders for UEFI

ELILO - LInux LOader for EFI - Not developed anymore

GRUB-Legacy - Vanilla versions do not support UEFI, nor does Archlinux patched versions. Only Fedora's patched GRUB (patches from Intel) is known to support UEFI. grub-fedora Github repo. AUR package - Template:Package AUR

GRUB2 - UEFI booting is officially supported by upstream but Archlinux does not officially build GRUB2 UEFI packages. Try AUR package - Template:Package AUR or Template:Package AUR according to your (U)EFI Arch.

rEFIt - EFI boot menu and toolkit mainly for Macs - Although it is known to load linux kernel directly, it is still immature for linux booting when compared to GRUB/GRUB2.

Compiling GRUB2 for UEFI

GRUB2 for (U)EFI should be compiled as follows


./configure --with-platform=efi --target=TARGET_EFI_ARCH


TARGET_EFI_ARCH can be either x86_64 for 64-bit EFI firmware or i386 for 32-bit EFI firmware. This "target" option denotes the EFI firmware arch. for which grub2 should be compiled, not the architecture of the linux kernel grub2 may boot.

It is possible to use UEFI 64-bit firmware + GRUB2 as x86_64-EFI app loading a i686 Archlinux kernel, as long as the kernel does not try to access UEFI Runtime Services. Vice-versa situation is also possible. But a UEFI x86_64 firmware cannot launch GRUB2 i386-EFI app.

After compilation, grub-mkimage should be used to obtain a GRUB2 UEFI binary. The "grub.efi" along with all the modules and the "grub.cfg" file should be copied to a folder within the EFI System Partition. Copying the required files to your /boot partition will not help here unless that partition is formatted as FAT32. Otherwise copy the files to <EFI SYSTEM PARTITION>/EFI/<YOUR_GRUB2_FOLDER>/ .

Generate your final grub2 efi application using the grub-mkimage command as follows

./grub-mkimage -d . -o <EFI_SYS_PART>/EFI/<GRUB2_FOLDER>/grub.efi -O TARGET_EFI_ARCH-efi -p "" <Modules_You_Require_in_grub.efi>

Note : The -p "" option is important for creating a portable grub.efi app.

Alternatively you can use the grub2_efi.sh shell script (link provided in external links section) to compile and install GRUB2 for UEFI systems from Source.

A "grub.cfg" created for BIOS based GRUB2 will be sufficient for the UEFI GRUB2 as long as all the paths in the file are absolute paths. The "grub.efi" binary can be launched using the firmware's "Boot from file" option or using the EFI Shell.

Creating a EFI SYSTEM PARTITION in Linux

For MBR partitioned disks :

Create a 200 MB FAT32 partition using GNU Parted/GParted. Change the type code of that partition to 0xEF using fdisk, cfdisk or sfdisk.


Create a 200 MB partition using fdisk with partition type 0xEF and format it as FAT32 using mkfs.vfat -F32 /dev/<THAT_PARTITION>

For GPT partitioned disks :

Create a 200 MB FAT32 partition using GNU Parted/GParted. Set "boot" flag on for that partition.


Create a 200 MB partition using GPT fdisk (aka gdisk) with gdisk type code "EF00". Then format that partition as FAT32 using mkfs.vfat -F32 /dev/<THAT_PARTITION>

Note 1: Setting "boot" flag in parted in a MBR partition marks that partition as active, while the same "boot" flag in a GPT partition marks that partition as "EFI System Partition".

Note 2: Do not use fdisk, cfdisk or sfdisk to change the type codes in a GPT disk. Do not use GPT fdisk on a MBR disk, it will be automatically converted to GPT (without data loss, but with boot failure).


  1. Wikipedia's page on UEFI
  2. Wikipedia's page on EFI SYSTEM Partition
  3. Homepage of rEFIt
  4. UEFI Forum - contains the official UEFI Specifications - GUID Partition Table is part of UEFI Specification.
  5. Intel's page on EFI
  6. Intel's Tianocore Project for Open-Source UEFI firmware
  7. GRUB2 wiki pages describing steps to compile for UEFI - http://grub.enbug.org/TestingOnEFI and http://grub.enbug.org/TestingOnMacbook
  8. Microsoft's Windows and GPT FAQ - Contains info on Windows UEFI booting also
  9. A InsanelyMac forum post describing steps to modify existing Windows x64 BIOS-MBR based installations to boot from UEFI-GPT

External Links

  1. A Linux Bash Shell script to compile and install GRUB2 for UEFI from Source