core/image-efi-verified
Build a signed systemd-boot A/B release with a verified root from an existing root filesystem.
Build a signed systemd-boot A/B release with a verified root from an existing root filesystem.
Inputs
-
kernel -
Kind: file
Required
Target Linux kernel image.
-
initrd -
Kind: file
Required
Initrd implementing the core verified-root boot contract.
-
rootfs -
Kind: directory
Required
Prepared root filesystem implementing the core verified-root boot contract.
-
boot-certificate -
Kind: file
Required
PEM-encoded RSA X.509 certificate for signing EFI boot artifacts.
-
bundle-certificate -
Kind: file
Required
Single PEM-encoded X.509 end-entity signer certificate issued directly by the trusted root. No intermediates. The default signer requires RSA.
-
secure-boot-keys -
Kind: directory
Default:
{"tree":{}}Authenticated variables PK.auth, KEK.auth, and db.auth that systemd-boot enrolls in Setup Mode. Empty by default, disabling enrollment.
Parameters
-
architecture -
Required
Target architecture: amd64 or arm64. Must match the system architecture.
-
cmdline-extra -
Default:
""Additional authenticated kernel arguments.
-
panic-timeout -
Default:
10Kernel panic reboot delay in seconds. Zero leaves the system stopped.
-
boot-timeout -
Default:
0systemd-boot menu timeout in seconds.
-
signing-time -
Default:
""Signing time as Unix seconds in a string. Empty uses the build source epoch.
-
config-size -
Default:
0ESP capacity in bytes. Zero reserves three copies of its current files, uses at least 256 MiB, and rounds up to 64 MiB.
-
root-compression -
Default:
"none"SquashFS compression of the root filesystem, such as zstd or xz, or none.
-
disk-size -
Default:
0Factory disk capacity in bytes. Zero sizes the disk from its partitions.
-
secondary-config -
Default:
falseReserve an empty secondary configuration partition with the same capacity as the ESP.
Outputs
-
image -
Artifact Source:
{"rule":{"node":"release","output":"image"}} -
bundle -
Artifact Source:
{"rule":{"node":"release","output":"bundle"}} -
bundle-hash -
Artifact Source:
{"rule":{"node":"release","output":"bundle-hash"}} -
uki -
Artifact Source:
{"rule":{"node":"verified-uki","output":"image"}} -
bootloader -
Artifact Source:
{"rule":{"node":"verified-bootloader","output":"image"}} -
root-hash -
Artifact Source:
{"rule":{"node":"filesystem","output":"root-hash"}} -
hash-offset -
Artifact Source:
{"rule":{"node":"filesystem","output":"hash-offset"}} -
data-size -
Artifact Source:
{"rule":{"node":"filesystem","output":"data-size"}}
Rule Parameters
Callers can replace these operations through rules bindings. An implementation
receives the listed inputs and parameters and must produce the listed outputs.
See Rule Parameters.
efi-signer
Sign an EFI executable. Bakery verifies each signature against boot-certificate.
Default implementation: core/sign-efi.
-
Input
image -
Kind: file
Unsigned PE executable: the UKI or systemd-boot.
-
Input
certificate -
Kind: file
The boot-certificate input.
-
Parameter
signing-time -
Signing time as Unix seconds in a string. Empty means the build source epoch.
-
Output
image -
Kind: file
PE executable with a UEFI Secure Boot signature.
bundle-signer
Create a CMS signature over the bundle’s signed metadata. Bakery verifies it against bundle-certificate.
Default implementation: core/sign-cms.
-
Input
content -
Kind: file
Signed bundle metadata.
-
Input
certificate -
Kind: file
The bundle-certificate input.
-
Parameter
signing-time -
Signing time as Unix seconds in a string. Empty means the build source epoch.
-
Output
signature -
Kind: file
DER-encoded CMS SignedData with the encapsulated content and signer certificate.
Execution
Composes other rules into a build graph.
Behavior
Build an EFI A/B release with a verified root from an existing root filesystem, kernel, and initrd. The composition builds a SquashFS root filesystem, appends dm-verity authentication data, embeds the root hash and image geometry in a Unified Kernel Image (UKI), signs and verifies the UKI and systemd-boot, and assembles a factory GPT disk and signed Rugix update bundle.
The required architecture is amd64 or arm64 and must match the kernel. The
root filesystem supplies etc/os-release. The initrd must implement the
core verified-root boot contract; custom
distributions can implement the same contract independently.
The factory disk contains the EFI System Partition (ESP) with the initial
rugix-a.efi UKI and the A system partition with the combined root image. The
ESP also carries the bootstrap marker and becomes Rugix Ctrl’s configuration
partition at /run/rugix/mounts/config. On first boot, Rugix Ctrl preserves the
ESP, expands the system capacity, creates an empty B system partition, and
creates data in the remaining drive space according to the root filesystem’s
bootstrap plan. The platform setup recipe defaults both system slots to at least
4 GiB. The EFI layout rule describes the factory and
completed layouts.
Factory sizing requires no size settings:
- Root: SquashFS sized to its contents, followed by verity data.
- ESP: reserve three copies of the current boot files, use at least 256 MiB, and round up to 64 MiB.
- Disk: fit the factory partition layout automatically.
root-compression selects the SquashFS compression of the root filesystem and
defaults to none, which helps delta updates find unchanged data. Select a
compressor such as zstd or xz for smaller images.
config-size and disk-size are optional factory capacity overrides. The
bootstrap plan controls deployed system capacities and data allocation. Once
bootstrapped, future payloads must fit the deployed slots. signing-time is
Unix seconds encoded as a string; empty uses the build source epoch.
The bundle delivers combined system.img and signed boot.efi payloads to
Rugix Ctrl slots named system and boot. The consuming root filesystem must
configure those slots as corresponding A/B boot groups.
| Output | Contents |
|---|---|
image | Factory disk |
bundle | Signed update bundle |
uki | Signed UKI |
bootloader | Signed systemd-boot executable |
root-hash | Root hash embedded in the UKI |
hash-offset | Byte offset of the appended hash area, as decimal text |
data-size | SquashFS length in bytes before padding and hashes, as decimal text |
The firmware must trust boot-certificate and enforce Secure Boot. Configure
the firmware separately, or let the factory image enroll your keys as described
in Enroll Secure Boot Keys.
Supply one PEM-encoded certificate as bundle-certificate; the default bundle
signer requires RSA. The bundle embeds only this signer certificate, without
intermediates. Issue it directly from the root that Rugix Ctrl trusts. The
signer must not be a CA certificate.
Signers
Two rule parameters sign the release:
efi-signersigns the UKI and systemd-boot. It defaults tocore/sign-efi, which uses a private key file.bundle-signersigns the update bundle’s metadata. It defaults tocore/sign-cms, which uses a private key file.
Bind the private keys of the default signers through rules:
rules.efi-signer.secrets.key = { path = "keys/boot.key" }
rules.bundle-signer.secrets.key = { path = "keys/bundle.key" }
To keep private keys in an HSM or a KMS, bind your own rules instead. A replacement receives the same inputs and parameters as the default, listed under Rule Parameters, and may require additional inputs, parameters, and secrets, which its binding supplies. It may run in its own environment.
[rules.efi-signer]
uses = "kms-sign-efi"
parameters.key-uri = "pkcs11:token=release;object=boot"
secrets.credentials = { path = "keys/kms-credentials" }
Bakery verifies every signature independently of the signer:
core/verify-efi checks EFI signatures against
boot-certificate, and
core/attach-bundle-signature checks the bundle
signature against bundle-certificate.
Customize Boot Settings
Set cmdline-extra to supply kernel arguments, such as consoles and log levels.
It defaults to an empty string. The panic-timeout parameter defaults to 10
seconds; zero disables automatic reboot after a panic. Verified-root arguments
remain supplied by the composition.
Set boot-timeout to control the systemd-boot menu timeout in seconds. For
example:
parameters.cmdline-extra = "console=ttyS0,115200n8 loglevel=4"
parameters.panic-timeout = 30
parameters.boot-timeout = 5
Enroll Secure Boot Keys
UEFI firmware without a platform key (PK) runs in Setup Mode. It then starts
unsigned boot software and accepts changes to its key databases without
authorization. A factory image can use this state to enroll your keys on its
first boot. Supply the keys as the secure-boot-keys directory:
inputs.secure-boot-keys = { path = "keys/secure-boot" }
The directory must contain exactly PK.auth, KEK.auth, and db.auth, signed
updates of the UEFI variables holding the platform key, the key exchange keys
(KEK), and the allowed signature database (db). The db must include
boot-certificate, otherwise the firmware rejects the release’s boot software
once it enforces Secure Boot. The files hold only certificates and signatures,
so the PK and KEK private keys stay outside the build.
The composition places the files in the ESP at loader/keys/auto/ and enables
automatic enrollment in systemd-boot’s loader configuration. When the firmware
is in Setup Mode, systemd-boot writes db, KEK, and PK, then restarts the device.
Writing PK ends Setup Mode, so the firmware verifies signatures from the next
boot on. The operating system therefore starts only after enrollment. TPM
policies bound to PCR 7, the register in which the firmware records its Secure
Boot state, see the final keys from the first operating system boot on. Outside
Setup Mode, systemd-boot leaves the keys untouched. Updates do not remove them
from the ESP, so a device enrolls them again whenever its firmware returns to
Setup Mode, for example after a reset of its keys.
In a virtual machine, systemd-boot enrolls the keys immediately. On other machines, it first counts down 15 seconds; pressing a key cancels the enrollment. Once Secure Boot is enforced, the firmware starts only software that your db authorizes. This includes option ROMs, the firmware of expansion cards such as graphics or network cards. Include the certificates of the option ROMs a device needs, or the device can fail to start them.
For example, create the files with OpenSSL and sbsigntool from the certificates
and private keys keys/PK.crt, keys/PK.key, keys/KEK.crt, keys/KEK.key,
and the boot certificate keys/boot.crt. PK signs the updates of PK and KEK,
and KEK signs the update of db:
mkdir keys/secure-boot
owner=$(uuidgen)
attributes=NON_VOLATILE,RUNTIME_ACCESS,BOOTSERVICE_ACCESS,TIME_BASED_AUTHENTICATED_WRITE_ACCESS
for name in PK KEK boot; do
openssl x509 -in "keys/$name.crt" -outform DER -out "keys/$name.cer"
sbsiglist --owner "$owner" --type x509 --output "keys/$name.esl" "keys/$name.cer"
done
sbvarsign --attr "$attributes" --key keys/PK.key --cert keys/PK.crt \
--output keys/secure-boot/PK.auth PK keys/PK.esl
sbvarsign --attr "$attributes" --key keys/PK.key --cert keys/PK.crt \
--output keys/secure-boot/KEK.auth KEK keys/KEK.esl
sbvarsign --attr "$attributes" --key keys/KEK.key --cert keys/KEK.crt \
--output keys/secure-boot/db.auth db keys/boot.esl
The owner GUID records who added each entry. To keep further certificates in db,
such as the vendor certificate of an option ROM, concatenate their lists with
keys/boot.esl before signing.
Example
For example, assemble prepared artifacts:
uses = "core/image-efi-verified"
inputs.rootfs = { path = "prepared-root" }
inputs.kernel = { path = "kernel" }
inputs.initrd = { path = "initrd" }
inputs.boot-certificate = { path = "keys/boot.crt" }
inputs.bundle-certificate = { path = "keys/bundle.crt" }
rules.efi-signer.secrets.key = { path = "keys/boot.key" }
rules.bundle-signer.secrets.key = { path = "keys/bundle.key" }
parameters.architecture = "amd64"
Save the invocation as build-rule.toml and run
./run-bakery bake rule build-rule.toml build/result. For Debian roots,
the Debian wrapper also selects a kernel and
generates its initrd.
Secondary Configuration Partition
To reserve space for a replacement ESP, including systemd-boot, set
parameters.secondary-config = true. This adds an empty config-secondary
partition with the same capacity as config. Both config partitions precede the
system partitions, so system-a, system-b, and data use partition numbers
3, 4, and 5 after bootstrap.
Enable the matching recipe option in the root filesystem’s layer:
[parameters."core/debian-efi-verified-setup"]
secondary_config = true
Use this option when provisioning a matching factory layout. Existing installations need a separate partition-layout migration before receiving the changed root configuration.
Custom roots must provide equivalent system and bootstrap configurations. The EFI layout rule describes the reserved partition. The update bundle continues to update the root and UKI slots; updating and activating a replacement ESP requires a separate operation.