The default Alpine kernel is compiled with EFI_STUB=y
, this allows booting the kernel directly from EFI firmware.
This approach works on:
- Google Cloud
- Scaleway
- Oracle Cloud
* Other cloud providers are untested
In order to prepare for EFI booting, install the following packages:
apk install efibootmgr kernel-hooks
On GPT installations, Alpine mounts the ESP under /boot/efi by default. So we can define the deploy the attached kernel hook script and configuration.
Deploy the kernel to the ESP partition by executing:
# apk fix kernel-hooks
Executing kernel-hooks-0.2-r0.trigger
kernel-hooks: executing hook 10-efi-kernel.hook (virt, 6.6.7-0, )
==> efi-kernel: creating UEFI Unified Kernel Image with /boot/vmlinuz-virt
'/boot/vmlinuz-virt' -> '/boot/efi/vmlinuz-virt'
'/boot/initramfs-virt' -> '/boot/efi/initramfs-virt'
Finally the EFI firmware needs to be configured to boot the newly deployed EFI kernel:
sudo efibootmgr --create --disk /dev/sda --part 1 --label 'Alpine Linux' --loader '\vmlinuz-virt' --unicode 'root=UUID=2ee1ab97-12dd-4545-8755-f622a1cf2ded ro quiet rootfstype=ext4 console=ttyS0,38400n8d initrd=\initramfs-virt'
Replace root UUID and console settings as necessary.
Validate that the boot option is successfully configured:
# efibootmgr -u
BootCurrent: 0007
Timeout: 0 seconds
BootOrder: 0007,0000,0001,0002,0003,0004,0005,0006
.
.
Boot0007* Alpine Linux HD(1,GPT,5cc32e8c-b098-476d-9da1-89ba89f68aed,0x800,0x31800)/File(\vmlinuz-virt)root=UUID=2ee1ab97-12dd-4545-8755-f622a1cf2ded ro quiet rootfstype=ext4 console=ttyS0,38400n8d initrd=\initramfs-virt
The virtual machine can now boot directly into the EFI kernel, skipping any bootloader such as GRUB