Posted on :: Source Code ::

If you are multi-booting OSes on your computer and would like to speed up the boot by hotkeying your OSes rather than waiting for a bootloader, there might be a way even without direct manufacturer support.

The UEFI specification describes a system to allow hotkey boot entries. The system is optional but since most if not all UEFI systems are based on the open-source edk2 which implements it, I expect that most systems have it even if it is not exposed.

The UEFI variable BootOptionSupport is a bitwise OR of multiple capabilities of the UEFI BIOS. The one we are interested in is defined as

#define EFI_BOOT_OPTION_SUPPORT_KEY         0x00000001

So we need to check if our BIOS does support it:

$ if test $(($(od -An -tu8 /sys/firmware/efi/efivars/BootOptionSupport-*) & 1)); then echo "Hotkey supported !"; else echo "Hotkey unavailable"; fi
Hotkey supported !

Great! Now we need to actually hotkey our OSes.

Like most aspects of UEFI, the boot process is controlled through UEFI variables. For example, all of the OSes your firmware knows and can boot are contained in the BootXXXX variables. The issue is that the content of those variables is a C struct that is rather difficult to manipulate with shell tools.

$ cat /sys/firmware/efi/efivars/Boot0001-8be4df61-93ca-11d2-aa0d-00e098032b8c    
tLinux Boot Manager*"����^��Z�A���▒yP�qF\EFI\systemd\systemd-bootx64.efi�****

Now we want to create a Key#### variable which has its own C-struct to refer both to the Boot Entry and to the key you want to associate.

I do not want to go too deep in the specific process here but you have a few ways to do it. The easiest would be to use a graphical tool like efibooteditor. We could alternatively try to edit the UEFI variables in /sys/firmware/efi/efivars/ ourselves but that seems like too much work to do it safely. I personally went with the UEFI shell and bcfg command route.

But in the end, even if the capability is not exposed in the BIOS menu, you might still be able to use it!