EFI stub

Introduction

EFI stub allows you to boot Linux kernel directly from UEFI. It is simple and fast alternative to using separate boot loader.

Configure kernel

Configure kernel to use UEFI stub.

Under Processor type and features:

[*] EFI runtime service support
[*]   EFI stub support

[*] Built-in kernel command line
(root=/dev/sda3 rootfstype=ext4 net.ifnames=0) Built-in kernel command string

Make UEFI boot partition

Create a 500MB partition on /dev/sda1 using gdisk.

# gdisk /dev/sda
Command: n ↵
Partition Number: 1 ↵
First sector: 
Last sector: +500M ↵
Hex Code: EF00

Format the partition to FAT32.

# mkfs.vfat -F 32 /dev/sda1

Copy kernel to boot partition

Kernel filename has to end with .efi for UEFI to detect it.

# cp arch/x86/boot/bzImage /boot/linux.efi

Make UEFI boot entry

UEFI boot entry can be made with sys-boot/efibootmgr

# emerge -av efibootmgr
# efibootmgr -c -d /dev/sda -p 1 -L "Funtoo Linux" -l "\linux.efi"