====== (U)EFI support ====== BIOS has been used to boot PC operating systems for decades. The problem is, BIOS was designed when PC were 16 bit computers – this doesn't work well for today's 64 bit computers. So, more and more machines are switching to a more modern firmware standard – (U)EFI. E.g. recent IBM xSeries servers run UEFI firmware. They are still able to boot via legacy BIOS mechanisms, but the UEFI booting is recommended and much faster. ===== Booting via EFI ===== Requirements: * (U)EFI platform (e.g. an IBM xSeries server with recent firmware or a relatively modern laptop, like Lenovo B590) * A disk with [[GUID Partition Table]] * EFI bootloader (e.g. GRUB2 built for EFI platform, ELILO or Xen or Linux kernel built as an EFI image) * EFI-compatible kernel ==== EFI platform ==== If your system does not have an EFI firmware, you may ignore this article. ==== GUID Partition Table ==== The boot disk of an EFI system must be partitioned using [[GUID Partition Table]] instead of the regular MBR ('DOS disklabel') used by older PCs. The partition table must contain an EFI System Partition to hold the boot loader(s) and, if needed by the boot loader, the operating system image (Linux kernel and the initramfs image). The recommended EFI System Partition size is about 300MB. ==== EFI boot loader ==== Not every boot loader is capable of booting from EFI firmware and it is not even necessary to use a dedicated boot loader to start Linux kernel. The boot loaders with EFI support are: **ELILO** and **GRUB2**. === No bootloader === Recent Linux kernel (since 3.3) can boot directly from EFI with no extra boot loader. Also Xen hypervisor can be booted this way (in fact Xen may misbehave if booted under EFI other way). See below. === ELILO === ELILO needs the linux kernel and initrd images present on the EFI System Partition. Specific paths and other options can be configured in the 'elilo.conf' file placed in the same directory of the EFI System Partition where ''elilo.efi'' is placed. ''elilo.efi'' is provided by the **elilo** package, and is installed in the ''/lib/efi/x64'' (64-bit) or the ''/lib/efi/ia32'' (32-bit) directory. It must be copied to the EFI System Partition, together with the ''elilo.conf'' file (available in ''/etc/efi-boot''), the Linux kernel and initramfs images. [[#efi-boot-update]] can take care of that. ELILO can also be used for network (PXE) boot from the EFI firmware. === GRUB2 === GRUB2 can load the kernel and initramfs file or any other image to boot from a Linux file system (/boot partition, or even the root partition on LVM). The GRUB core image is installed at the EFI system partition by the ''grub-install'' command and additional GRUB modules are read from the /boot file system when necessary To install GRUB2 bootloader for (U)EFI booting: * install the **grub2** and **grub2-platform-efi** and **efibootmgr** packages. Most probably the x86_64 version of **grub2-platform-efi** package will be needed, as most modern EFI firmwares run 64-bit. * make sure your EFI system partition is mounted at /boot/efi * issue ''%%grub-install --target=x86_64-efi%%'' If the ''Couldn't open either sysfs or procfs directories for accessing EFI variables.'' message is displayed, that means **efibootmgr** was not able to update boot manager configuration. It such case it may be necessary to use the EFI firmware configuration interface (equivalent of 'BIOS setup') to set up booting for ''\grubx64.efi'' or to copy ''/boot/efi/EFI/grub/grubx64.efi'' to ''/boot/efi/EFI/BOOT/BOOTX64.EFI'' file, to make it the default boot loader for the device. GRUB can also be used for network booting, but version 2.00-1 times out on large initramfs images (this makes PLD Rescue boot impossible). === The default bootloader location === Normally the EFI firmware holds a list of configured boot loaders, can present them as a list of boot options or try them automatically in a pre-defined order. This can be managed from Linux using the [[#efibootmgr]] utility. Unfortunately, this interface may not be available. In such case there is another way to boot using a chosen boot loader – the firmware should automatically run the ''\EFI\BOOT\BOOTX64.EFI'' (''/boot/efi/EFI/BOOT/BOOTX64.EFI'' in Linux, or ''BOOTIA32.EFI'', etc., depending on the platform). Any EFI application can be installed under that name to be effectively the default loader for this device. ==== EFI-compatible kernel ==== === Linux kernel === The linux kernel, to be bootable from EFI, needs support for the [[GUID Partition Table]] (CONFIG_EFI_PARTITION=y), for the EFI firmware (CONFIG_EFI=y) and for the EFI framebuffer console (CONFIG_FB, CONFIG_FB_EFI, CONFIG_FRAMEBUFFER_CONSOLE). It is a good idea to enable the 'efivars' module (CONFIG_EFI_VARS=m), so the **efibootmgr** utility will work and it will be possible to edit EFI boot manager settings form Linux. Linux Kernel >= 3.3 can be build in a form, that is also an EFI bootloader (CONFIG_EFI_STUB=y). Such kernel does not need any external boot loader. PLD Linux kernels have all those features enabled. == Configuring standard PLD kernel boot == To set up kernel boot via EFI with no other boot loader: * install your kernel and make sure you have a valid ''/boot/initrd'' for it * install [[#efi-boot-update]] * update /etc/efi-boot/update.d/kernel.conf so it contains proper 'root=' directive in $ARGS (required for Dracut-generated initrd) * run [[#efi-boot-update]] (note, this will only work if already running via EFI) === Xen === [[Xen]] hypervisor acts as a kernel on its own and will load Linux kernel for the dom0 virtual machine. Xen 4.2.0 includes support for EFI boot. In PLD, the xen-efi package provides Xen hypervisor binary for EFI platforms – it acts as an EFI boot loader, so can be booted directly from the firmware or via chain-loading from other EFI boot loader. See the [[Xen]] page for more information. ===== efibootmgr ===== **efibootmgr** utility allows to configure EFI boot manager (the part of EFI firmware selecting and starting the boot loaders) configuration variables from within a Linux system. It requires the 'efivars' kernel module loaded to provide the required interface to the EFI firmware. The utility can be used to add or remove boot menu entries, to change boot order, or to select specific boot loader for the next boot only. See its manual page for details. ===== efi-boot-update ===== **efi-boot-update** is a PLD own utility to simplify management of EFI boot loaders. The boot loaders need to be copied to the EFI partition (often together with configuration files, the Linux kernel and the initramfs image) to operate and it is inconvenient to do this manually every time any of these changes. **efi-boot-update** automates it using the rules defined in files stored in its ''/etc/efi-boot/update.d'' directory. When enabled in ''/etc/efi-boot/update.conf'', **efi-boot-update** will be called on each boot loader or kernel upgrade and update the files on the EFI partition. More information in the [[http://git.pld-linux.org/gitweb.cgi?p=packages/efi-boot-update.git;a=blob_plain;f=README;h=19d147dad2c3b711608203a297672e5533764c42;hb=HEAD|efi-boot-update README file]] ===== efi-shell ===== Instead of loading a boot loader and starting the operating system one may wish to enter the EFI shell. The EFI shell is often not included in the system firmware and must be installed separately. For convenience, PLD Linux provides the **efi-shell-{ia32,x64}** packages with pre-compiled EFI shell executables. These can be installed like a regular boot-loader – manually or with [[#efi-boot-update]]