linux
From 12.11.2017

Booting EFI Stub

With (U)EFI you no longer need a bootmanager to get your Linux running. I use it as it

  • increases boot speed
  • don’t asks me about what to boot (unless I hit F11)

I love it as I often boot to my default desktop and only rarely something different (recovery or Windows).

Booting from ESP

The following chapters are directly from https://wiki.debian.org/EFIStub (in case it vanishes). However this is not Debian specific.

Copy the files

The UEFI firmware is only able to load files from the EFI partition (usually FAT). If you use a standard UEFI installation of Debian or Ubuntu, you should copy the kernel and the initrd to /boot/efi. The best way to keep it up to date is to place a script in /etc/kernel/postinst.d/zz-update-efistub:

#!/bin/sh
cp /vmlinuz /boot/efi/EFI/debian/

Make it executable and launch it manually:

chmod +x /etc/kernel/postinst.d/zz-update-efistub
/etc/kernel/postinst.d/zz-update-efistub

Place another in /etc/initramfs/post-update.d/zz-update-efistub (create the directory if it does not exist):

#!/bin/sh
cp /initrd.img /boot/efi/EFI/debian/

Make it executable and launch it manually:

chmod +x /etc/initramfs/post-update.d/zz-update-efistub
/etc/initramfs/post-update.d/zz-update-efistub

Add the boot entry

Replace /dev/sda3 with the device of your / partition, see the efibootmgr manpage if you EFI partition is not /dev/sda1:

export UUID=$(blkid -s UUID -o value /dev/sda3)
efibootmgr -c -g -L "Debian (EFI stub)" -l '\EFI\debian\vmlinuz' -u "root=UUID=$UUID ro quiet rootfstype=ext4 add_efi_memmap initrd=\\EFI\\debian\\initrd.img"

It might be a good idea to add a recovery entry as well. Just run the command above with a different name and swap quiet with recovery nomodeset.

Windows Dual Boot

One note on windows. It “repairs” the boot entries if it is not Boot0000. Just give it it’s biscit and change the bootorder.

drak@Ubu:~$ efibootmgr -o 000B,0007,0000,0003,0001,0002
BootCurrent: 000B
Timeout: 0 seconds
BootOrder: 000B,0007,0000,0003,0001,0002
Boot0000* Win10 (aka Witcher 3)
Boot0001  Hard Drive 
Boot0002  CD/DVD Drive 
Boot0003* USB 
Boot0007* Ubuntu (Recovery)
Boot000B* Ubuntu (Linux)

Booting from / (in my case ext4)

In theorie, it is possible to use an EFI Driver to enable it to read something different than FAT. This would be nice as there would be no more copying the kernel and initramfs. So no need for the scripting above. But most impotantly it would save the ~64M on the ESP, as only a driver <1M would be needed.

I tried this using EFI Drivers from https://github.com/pbatard/efifs, but my mainboard did not load the driver (got an instant blackscreen). rEFInds EXT4 driver did behave the same way. I suspect my mainboard (H77 Pro4/MVP) to be the issue. (It also messes up the boot entry listing in its Setup - but not on startup)

Resources