Feature: _trustedboot
Description
A feature that establishes a fully trusted boot chain: UEFI Secure Boot verifies the bootloader and Unified Kernel Image (UKI) and the root filesystem (embedded as EROFS in the UKI) is covered by the same signature. At runtime, the system halts if Secure Boot is not active, closing all emergency escape paths. For the full trust model and security guarantees, see Secure Boot and Trusted Boot.
What it does
_trustedboot composes several layers of boot-chain integrity:
- Includes
_usi— switches the image to UKI boot mode, embedding the EROFS root filesystem in a single signed EFI binary. - Includes
_ephemeral— sets the default/varstorage to a per-boot randomly-keyed encrypted partition (no state persists across reboots). Replace with_tpm2if persistent/varis needed. - Signs the UKI —
usi.configruns at build time to sign the systemd-boot EFI binary and the UKI withsbsign, using either a local key or an AWS KMS PKCS#11 key. Secure Boot auth files (PK, KEK, db) are copied to the ESP andloader.confis configured for automatic key enrollment. - Verifies Secure Boot at runtime —
check-secureboot.servicereads theSecureBootEFI variable in the initrd and halts the system if Secure Boot is not active, before any local filesystem is mounted. - Removes all emergency escape paths —
emergency.serviceis overridden to callhalt -fimmediately, and99-no-rd-shell.cfgstripsrd.shellandrd.emergencyfrom the kernel command line, appendingrd.shell=0 rd.emergency=poweroff. - Enforces Secure Boot capability —
requirements.moddeclaresrequirements["secureboot"]=true, so the build system rejects targets that do not support Secure Boot.
For a detailed breakdown of security guarantees, the feature dependency table, and mutable data mode comparison, see Secure Boot and Trusted Boot.
How it works
Boot-time verification (initrd)
All verification steps run inside the initrd, before any local filesystem is mounted:
Secure Boot check (
check-secureboot.service, ordered beforelocal-fs.targetvialocal-fs.target.requires/):check-securebootreads/sys/firmware/efi/efivars/SecureBoot-8be4df61-93ca-11d2-aa0d-00e098032b8cand checks whether the last byte is1.- If Secure Boot is not active, it logs an error to the kernel log and exits non-zero, triggering
emergency.target.
Emergency halt override (
emergency.service):- The standard
emergency.service(which drops to a root shell) is replaced with a one-shot unit that callshalt -fimmediately. Combined with the kernel command line changes, there is no way to reach a shell on boot failure.
- The standard
Kernel command line hardening (
99-no-rd-shell.cfg):- Strips any existing
rd.shellandrd.emergencyparameters usingsed, then appendsrd.shell=0 rd.emergency=poweroff systemd.gpt_auto=0. This prevents the kernel or dracut from offering an emergency shell regardless of how the system was invoked.
- Strips any existing
Image signing (usi.config, build-time)
usi.config is called by the _usi image builder with the UKI path, ESP directory, and rootfs path as arguments:
- Signs the systemd-boot EFI binary (
EFI/BOOT/BOOT{X64,AA64}.EFI) withsbsignusing either a local PEM key (cert/secureboot.db.key) or an AWS KMS PKCS#11 engine key identified by ARN (cert/secureboot.db.arn). - Writes
loader/loader.confwithsecure-boot-enroll forceso that systemd-boot auto-enrolls the Garden Linux Secure Boot certificates on first boot. - Copies the Garden Linux Secure Boot auth files (PK, KEK, db) from
/etc/gardenlinux/in the rootfs toEFI/loader/keys/auto/in the ESP. - Signs the UKI with
sbsignand places the signed binary atEFI/Linux/$BUILDER_CNAME.efiin the ESP.
For certificate generation and build instructions, see Building Images: Secureboot / Trustedboot / TPM2.
Testing on macOS
- Generate the Secure Boot certificate chain:bash
./cert/build - Build an image with the
_trustedbootflag, optionally combined with_tpm2:bash./build kvm_dev_trustedboot_tpm2 - Obtain an edk2 build with Secure Boot support:bash
mkdir edk2 podman run --rm -v "$PWD/edk2:/mnt" debian:testing bash -c \ 'apt update && apt install -y qemu-efi-aarch64 && \ cp /usr/share/AAVMF/AAVMF_CODE.secboot.fd /usr/share/AAVMF/AAVMF_VARS.fd /mnt/' - Boot the image with
start-vm(the,qcow=4Gsuffix is required to make the disk large enough forsystemd-repartto create the/varpartition):bash./bin/start-vm \ --ueficode edk2/AAVMF_CODE.secboot.fd \ --uefivars edk2/AAVMF_VARS.fd \ --tpm2 disk.qcow2,qcow=4G
Files
Files present in this feature and their purpose. See the feature file reference for the semantics of each file type.
| File | Purpose |
|---|---|
file.include.markers.yaml (ref) | Maps file.include files to test-coverage marker IDs. |
info.yaml (ref) | Declares type: flag; includes _usi and _ephemeral; excludes _nocrypt and _unsigned. |
initrd.include.markers.yaml (ref) | Maps initrd files to test-coverage marker IDs. |
requirements.mod | Declares requirements["secureboot"]=true, enforcing that the build target supports Secure Boot. |
usi.config | Build-time signing script called by the _usi image builder: signs the systemd-boot EFI binary and the UKI with sbsign (local PEM key or AWS KMS PKCS#11); configures auto-enrollment; copies Garden Linux Secure Boot auth files to the ESP. |
file.include/etc/kernel/cmdline.d/99-no-rd-shell.cfg (file.include) | Strips rd.shell and rd.emergency kernel parameters and appends rd.shell=0 rd.emergency=poweroff systemd.gpt_auto=0, closing all emergency escape hatches in the initrd. |
initrd.include/etc/systemd/system/check-secureboot.service (initrd.include) | Initrd service ordered before local-fs.target (via local-fs.target.requires/) that runs check-secureboot and triggers emergency.target (immediate halt) if Secure Boot is not active. |
initrd.include/etc/systemd/system/emergency.service (initrd.include) | Overrides the standard emergency shell: replaces ExecStart with halt -f, preventing any interactive access if the system enters emergency mode. |
initrd.include/etc/systemd/system/local-fs.target.requires/check-secureboot.service (initrd.include) | Symlink ordering check-secureboot.service as a requirement of local-fs.target, ensuring the Secure Boot check runs before any local filesystem is mounted. |
initrd.include/usr/bin/check-secureboot (initrd.include) | Script invoked by check-secureboot.service: reads the SecureBoot EFI variable from /sys/firmware/efi/efivars/; logs an error and exits non-zero if Secure Boot is not active (1). |
Related features
Includes:
_usi— provides the UKI boot mode (embedded EROFS root in a signed EFI binary) that Trusted Boot depends on. Signing the UKI implicitly signs the root filesystem._ephemeral— the default/varstorage mode for Trusted Boot: a fresh randomly-keyed encrypted partition on every boot. No data persists across reboots, providing the strongest protection against offline attacks.
Excludes (incompatible with):
_nocrypt— a plaintext/varpartition is incompatible with the integrity guarantees of Trusted Boot._unsigned— unsigned EFI binaries bypass Secure Boot entirely; incompatible with a signed and verified boot chain.
Closely pairs with:
_tpm2— optional replacement for_ephemeralwhen persistent/varstate is needed. Seals the/varencryption key to TPM 2.0 PCR 7, so the key is only released when the Secure Boot state is unchanged. Use_tpm2instead of (not in addition to)_ephemeral.
Further reading
- Secure Boot and Trusted Boot — trust model, security guarantees, feature dependency table, mutable data modes, build and deploy instructions
- Boot Modes — USI vs. Legacy comparison, mutable data mode overview
- Building Images: Secureboot / Trustedboot / TPM2 — certificate generation and build steps
- Deploying Secure Boot Images — cloud-provider enrollment steps
- Unified Kernel Image specification
- Lennart Poettering: Fitting Everything Together — design background for UKI-based OS images