Now that NixOS is ready for Secure Boot, we will setup the
firmware. At the end of this section, Secure Boot will be enabled on
your system and your firmware will only boot binaries that are signed
with your keys.
At least on some ASUS boards and others, you may also need to set the OS Type to “Windows UEFI Mode” in the Secure Boot settings, so that Secure Boot does get enabled.
These instructions are specific to ThinkPads and may need to be
adapted on other systems.
On Framework laptops (13th generation or newer) you can enter the setup mode like this:
Select “Administer Secure Boot”
Select “Erase all Secure Boot Settings”
WARNING
Don’t select “Erase all Secure Boot Settings” in the Framework 13 Core Ultra Series 1 firmware.
This firmware is bugged, instead delete all keys from the “PK”, “KEK” and “DB” sections manually.
See this thread on the Framework forum.
On Microsoft Surface devices (tested on Surface Book 3 and Surface Go 3), keep Secure Boot disabled in UEFI settings.
On Surface Devices, having Secure Boot disabled defaults to “setup mode”, and there is no need to re-enable it in this interface.
After following these instructions, Lanzaboote should enable Secure Boot for you.
On certain systems (e.g. ASUS desktop motherboards), there is no explicit option to enter Setup Mode.
Instead, choose the option to erase the existing Platform Key.
Once you’ve booted your system into NixOS again, you have to enroll
your keys to activate Secure Boot. We include Microsoft keys here to
avoid boot issues.
Terminal window
1
sudo sbctl enroll-keys --microsoft
2
Enrolling keys to EFI variables...
3
With vendor keys from microsoft...✓
4
Enrolled keys to the EFI variables!
⚠️ During boot, some hardware might include OptionROMs signed with
Microsoft keys.
By using the --microsoft, we enroll the Microsoft OEM certificates.
Another more experimental option would be to enroll OptionROMs checksum seen
at last boot using --tpm-eventlog, but these checksums might change later.
You can now reboot your system. After you’ve booted, Secure Boot is
activated and in user mode:
Terminal window
1
bootctl status
2
System:
3
Firmware: UEFI 2.70 (Lenovo 0.4720)
4
Firmware Arch: x64
5
Secure Boot: enabled (user)
6
TPM2 Support: yes
7
Boot into FW: supported
⚠️ If you used --microsoft while enrolling the keys, you might want
to check that the Secure Boot Forbidden Signature Database (dbx) is not
empty.
A quick and dirty way is by checking the file size of
/sys/firmware/efi/efivars/dbx-*.
Keeping an up to date dbx reduces Secure Boot bypasses, see for example:
https://uefi.org/sites/default/files/resources/dbx_release_info.pdf.
When you want to permanently get back to a system without the Secure
Boot stack, first disable Secure Boot in your firmware
settings. Then you can disable the Lanzaboote related settings in the
NixOS configuration and rebuild.
You may need to clean up the EFI/Linux directory in the ESP manually
to get rid of stale boot entries. Please backup your ESP, before you
delete any files in case something goes wrong.