Skip to content

add persistent TPM2-bound LUKS partitions for credentials and keylime#34

Merged
phaer merged 9 commits intomainfrom
persistent-tpm-storage
Mar 19, 2026
Merged

add persistent TPM2-bound LUKS partitions for credentials and keylime#34
phaer merged 9 commits intomainfrom
persistent-tpm-storage

Conversation

@phaer
Copy link
Copy Markdown
Owner

@phaer phaer commented Mar 19, 2026

Move all mutable partitions out of the build-time image. It now contains only immutable partitions (ESP, store-verity, store). systemd-repart creates mutable partitions on first boot.

  • 31-var-lib-credentials (64M, LUKS+TPM2)
  • 32-var-lib-keylime (64M, LUKS+TPM2)
  • 40-var-lib-build (250G, LUKS+random key; ephemeral, factory-reset each boot)

Also: the link-volatile-root service now resolves the boot disk by following the dm-verity usr device through sysfs, which is cryptographically bound to the UKI's usrhash. This correctly identifies the boot disk even when other disks with identical partition labels are present (e.g. the installer).

Integration tests verify that /var/lib/build is wiped on reboot while /var/lib/keylime and /var/lib/credentials survive.

phaer added 9 commits March 19, 2026 10:58
Move the ephemeral build partition last in the partition table,
leaving room for persistent partitions before it.
Remove the build-time placeholder for var-lib-build. systemd-repart
only formats and LUKS-encrypts during partition creation, so
placeholders would be left unformatted. Let repart create all mutable
partitions from scratch on first boot instead.

Point link-volatile-root at the ESP (always present in the image)
so repart can discover the disk.

Remove dead mkfsOptions.ext4 (no ext4 partitions in image anymore).
Add 31-var-lib-credentials and 32-var-lib-keylime (64M each,
Encrypt=tpm2). Created by systemd-repart on first boot, persistent
across reboots (no FactoryReset).

Add LUKS device entries with tpm2-device=auto and filesystem mounts.
Ensure systemd-repart runs before all cryptsetup units.
Move credentials from /var/lib/artifacts/credentials to
/var/lib/credentials, backed by the new TPM2-bound LUKS partition.

Remove dependency on artifactStorage.enable and the bind-mount
ordering on the artifacts mount.
/var/lib/keylime is now a persistent LUKS partition, so the agent's
AK survives reboots natively. Remove persistAgent script,
keylime-persist-agent service, and restore-from-boot logic in
configureAgent.
The installed system needs a TPM to create TPM2-encrypted partitions
at first boot.
Write sentinels to /var/lib/{build,keylime,credentials}, reboot,
verify build is wiped while keylime and credentials survive.
Reflect the new disk layout: build-time image contains only immutable
partitions, mutable partitions are created at boot. Update credential
path from /var/lib/artifacts/credentials to /var/lib/credentials.
Update keylime AK persistence description.
Instead of symlinking a partition label to volatile-root (which could
match the wrong disk if e.g. the installer is still attached), follow
the dm-verity 'usr' device to its backing store partition via sysfs,
then walk up to the parent disk. The verity device is cryptographically
bound to this UKI's usrhash, so it uniquely identifies the correct disk.
@phaer phaer merged commit 296991b into main Mar 19, 2026
2 checks passed
@phaer phaer deleted the persistent-tpm-storage branch March 19, 2026 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant