feat: ParticleOS-like layout: /usr image, encrypted btrfs root

The image now holds only the ESP and a verity-protected /usr (A/B). At
first boot, systemd-repart in the initrd makes the root filesystem: btrfs,
encrypted with a TPM key sealed to the signed PCR 11 policy, with /var as
its own subvolume. A TPM is required. systemd.image_policy= accepts only
an encrypted root and a verity-checked /usr, and FactoryReset=yes lets
factory-reset.target wipe it.

/etc is writable but nearly empty: mkosi.finalize keeps the build's /etc
in /usr/share/factory/etc and systemd-tmpfiles links it in at boot. That
removes etc-shadow.mount, the host key on /var, fstab and /var/lib/agent.
/var now survives reboots.

systemd-firstboot replaces agent-setup: it asks for the root password on
the screen and offers a recovery key. Machines are named agent-???? from
the kernel command line. The user is now agent, with its home in
/home/agent and ssh keys in the default places. sshd.path starts sshd
only once root or agent has a key.

The test VM needs swtpm. The package cache moves to a podman volume
(AGENTS.md). No existing VMs can update to this layout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Job79andClaude Opus 5.5 committed 2026-11-19 21:09:31 +01:00
1 parent db8fb0d5a4
commit c80e843cb5
39 files changed
+229 -342

No files matched your search

+7 -15
View File
@@ -1,16 +1,8 @@
# Agent directories
# Agent home
#
# What survives a reboot and what doesn't. Claude can only write to the wiped
# directories, /tmp and its own config.
# /var/lib/agent keeps the setup answers, the ssh keys and Claude's login.
# agent-boot wipes the rest of Claude's config.
d /var/lib/agent 0755 root root -
d /var/lib/agent/claude 0700 claude claude -
# D wipes Claude's home, with its podman storage, and temporary files at every
# boot.
D /var/home/claude 0700 claude claude -
D /var/tmp 1777 root root -
# linger starts Claude's user manager at boot, for rootless podman and its own
# services.
f /var/lib/systemd/linger/claude
# The home of the user agent (mkosi.extra/usr/lib/sysusers.d/agent.conf), with
# Claude's login and podman storage.
d /home/agent 0700 agent agent -
# linger starts the user manager of agent at boot, for rootless podman and
# Claude's own services.
f /var/lib/systemd/linger/agent