EFI stub

The (U)EFI firmware present in many computers can function as bootloader, allowing systems to boot without needing the addition of a secondary bootloader. This article installing unsigned kernels in the EFI System Partition (ESP) of a computer running in EFI mode.]] This requires secure boot to be disabled.

Kernel configuration
In order to boot directly from UEFI, the kernel needs to know where to find the root partition of the system to be booted. Enable EFI runtime service support ( CONFIG_EFI ), EFI stub support ( CONFIG_EFI_STUB ) and Built-in kernel command line ( CONFIG_CMDLINE_BOOL ) and add the root partition path (example: ) or its PARTUUID to ( CONFIG_CMDLINE ).

Using  might be preferable. To find out use :

Installation
If an ESP does not exist, one needs to be created. See EFI System Partition. Still in the kernel directory, build the kernel and install the modules:

Have the ESP (in this example ) mounted at :

Copy or move the kernel image to the right place adding version number and the suffix:

In the ESP it should then be listed like:

Alternatively the fallback directory could be used additionally to or instead of.

Next, update the NVRAM creating a new boot entry using e.g. efibootmgr.

For example:

Optional: Initramfs
If for some reason an initramfs is needed, it can either be embedded into the kernel or be used as a separate file.

In case it's desired as a separate file, it should also be copied or moved into the ESP and the NVRAM be updated accordingly.

Some UEFI implementations however seem to not support passing parameters from the NVRAM to the EFI stub kernel.

For embedding the initramfs directly into the kernel image, the Initramfs source file(s) ( CONFIG_INITRAMFS_SOURCE ) must be coded in the kernel (directly under the Initial RAM filesystem and RAM disk (initramfs/initrd) support ( CONFIG_BLK_DEV_INITRD ) option) as shown here for a custom initramfs created in :

Embedding takes place on compilation, so the kernel must then be recompiled and be moved (or copied) again into the ESP.

Optional: Secure boot
There is a forums post and another wiki article explaining in detail how to sign the kernel and enable secure boot.

Troubleshooting

 * Forums topic - BIOS losing the names of the EFI ESPs
 * Older kernels compiled with gcc:10 crashed at boot.

External resources

 * EFI Stub - booting without a bootloader Blog posting which this article is partially based on.
 * EFI bootloaders listing alternative ways to boot an (U)EFI system.
 * EFISTUB on wiki.archlinux.org
 * Gentoo Forums: Suspend and Hibernate with UEFI