EFI Stub
this articles is about booting your linux system without a bootload (grub, lilo...), traditionally we use bootloaders to load the kernel and initramfs, but if you have an uefi system, you could skip bootloaders entirely, and use uefi to load the kernel.
1. Verify
to check if you have a uefi run:
ls /sys/firmware/efi/efivarsthe directory should exist and contains some entries.
2. Setup ESP
to make use of uefi, you need to create a separate partition, to hold efi files, it should be at least 100MiB, use fdisk(or any tool you like) to create it:
doas fdisk /dev/sdahere replace /dev/sda, with the disk you want to use.
then format the partition you just created:
doas mkfs.fat -F32 /dev/sda1I assume it is /dev/sda1, replace it w/ whatever you have.
then mount it:
doas mkdir -p /boot/efi
doas mount /dev/sda1 /boot/efinow your partition is ready, if you like you can add it to /etc/fstab, but it is not mandatory:
# /dev/sda1
UUID=YOUR-UUID /boot/efi vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro 0 23. Install EFI Entry
first you need to install efibootmgr
doas pacman -S efibootmgrthen copy your kernel, and initramfs to ESP partition.
doas mkdir -p /boot/efi/EFI/arch
doas cp -v /boot/{vmlinuz-linux, initramfs-linux.img} /boot/efi/EFI/archfinally add an entry to the uefi:
doas efibootmgr --verbose --create --disk /dev/sda --part 1 --loader "\EFI\arch\vmlinuz-linux" --unicode "initrd=\EFI\arch\initramfs-linux.img root=/dev/sda2 rw"finally reboot to make sure it works:
doas reboot nowand that's it. if you booted directly with your kernel, without going through the bootloader menu, you successfully did it.
4. Notes
if you don't use an initramfs as I have explained here, you don't need to pass initrd argument to the kernel.
5. Common Problems
some times this method efibootmgr doesn't work, because it is not compatible with your machine uefi implementations.
in that case you can try uefi shell that comes with archlinux iso, boot it, and run the following commands:
bcfg boot add N FS0:\EFI\arch\vmlinuz-linuxwhere N is boot entry number, to see the next available boot number run:
bcfg boot dump -vand FS0 is the ESP partition you can use cd, ls utilities to find it. now we will add arguments to our kernel, by creating file that contains them.
edit FS0:\boot.configadd the same arguments we use before, then save and quit the file.
finally read args and add them to the entry
bcfg boot -opt N FS0:\boot.configthen exit
exitnow the entry should appear in uefi firmware menu, and you could boot properly.