EFI system partition: Difference between revisions

From ArchWiki
(Undo revision 488383 by Zombielinux (talk) - the number is not the type, it can change as entries are added or removed from the list in future versions)
(→‎Mount the partition: add "/boot/efi")
Line 43: Line 43:
== Mount the partition ==
== Mount the partition ==


{{Expansion|Add {{ic|/boot/efi}}|Talk:EFISTUB#ESP mount points}}
The kernels and initramfs files need to be accessible by the [[boot loader]] or UEFI itself to successfully boot the system. Thus if you want to keep the setup simple, your boot loader choice limits the available mount points for EFI System Partition.


In case of [[EFISTUB]], the kernels and initramfs files should be stored in the EFI System Partition. For sake of simplicity, you can also use the ESP as the {{ic|/boot}} partition itself instead of a separate {{ic|/boot}} partition, for EFISTUB booting. In other words, after creating and formatting the EFI System Partition as instructed above, simply [[mount]] it at {{ic|/boot}}.
The simplest scenarios for mounting EFI System Partition are:
 
* [[mount]] ESP to {{ic|/boot/efi}} and use a [[boot loader]] which has a driver for your root file system (eg. [[GRUB]], [[rEFInd]]).
* [[mount]] ESP to {{ic|/boot}}. This is the preferred method when directly booting a [[EFISTUB]] kernel from UEFI.


Also see [[#Using bind mount]].
Also see [[#Using bind mount]].

Revision as of 09:41, 11 December 2017

The EFI System Partition (also called ESP or EFISYS) is a FAT32 formatted physical partition (in the main partition table of the disk, not under LVM or software RAID etc.) from where the UEFI firmware launches the UEFI bootloader and application.

It is an OS independent partition that acts as the storage place for the EFI bootloaders and applications to be launched by the EFI firmware. It is mandatory for UEFI boot.

Warning: If dual-booting with an existing installation of Windows on a UEFI/GPT system, avoid reformatting the UEFI partition, as this includes the Windows .efi file required to boot it. In other words, use the existing partition as is and simply #Mount the partition.

Create the partition

The following two sections show how to create an EFI System Partition (ESP).

Note: It is recommended to use GPT for UEFI boot, because some UEFI firmwares do not allow UEFI-MBR boot.

It is recommended to keep ESP size at 512 MiB although smaller/larger sizes are fine. [1]

According to a Microsoft note[2], the minimum size for the EFI System Partition (ESP) would be 100 MB, though this is not stated in the UEFI Specification. Note that for Advanced Format 4K Native drives (4-KB-per-sector) drives, the size is at least 256 MiB, because it is the minimum partition size of FAT32 drives (calculated as sector size (4KB) x 65527 = 256 MiB), due to a limitation of the FAT32 file format.

GPT partitioned disks

Choose one of the following methods to create an ESP for a GPT partitioned disk:

  • fdisk/gdisk: Create a partition with partition type EFI System (EFI System in fdisk or EF00 in gdisk). Proceed to #Format the partition section below.
  • GNU Parted: Create a FAT32 partition and in Parted set/activate the boot flag (not legacy_boot flag) on that partition. Proceed to #Mount the partition section below.

MBR partitioned disks

Create a partition with partition type EFI System using fdisk. Proceed to #Format the partition.

Format the partition

After creating the ESP, you must format it as FAT32:

# mkfs.fat -F32 /dev/sdxY

If you used GNU Parted above, it should already be formatted.

If you get the message WARNING: Not enough clusters for a 32 bit FAT!, reduce cluster size with mkfs.fat -s2 -F32 ... or -s1; otherwise the partition may be unreadable by UEFI.

Mount the partition

The kernels and initramfs files need to be accessible by the boot loader or UEFI itself to successfully boot the system. Thus if you want to keep the setup simple, your boot loader choice limits the available mount points for EFI System Partition.

The simplest scenarios for mounting EFI System Partition are:

  • mount ESP to /boot/efi and use a boot loader which has a driver for your root file system (eg. GRUB, rEFInd).
  • mount ESP to /boot. This is the preferred method when directly booting a EFISTUB kernel from UEFI.

Also see #Using bind mount.

Known issues

ESP on RAID

It is possible to make the ESP part of a RAID1 array, but doing so brings the risk of data corruption, and further considerations need to be taken when creating the ESP. See [3] and [4] for details.

Tips and tricks

Using bind mount

Instead of mounting the ESP itself to /boot, you can mount a directory of the ESP to /boot using a bind mount (see mount(8)). This allows pacman to update the kernel directly while keeping the ESP organized to your liking.

Note:
  • This requires a kernel and bootloader compatible with FAT32. This is not an issue for a regular Arch install, but could be problematic for other distributions (namely those that require symlinks in /boot). See the forum post here.
  • You must use the root= kernel parameter in order to boot using this method.

Just like in EFISTUB#Alternative ESP Mount Points, copy all boot files to a directory on your ESP, but mount the ESP outside /boot (e.g. /esp). Then bind mount the directory:

# mount --bind /esp/EFI/arch/ /boot

After verifying success, edit your Fstab to make the changes persistent:

/etc/fstab
/esp/EFI/arch /boot none defaults,bind 0 0

See also