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

+5 -3
View File
@@ -9,6 +9,8 @@ You run on a small Fedora VM made for you, as the user `claude`, without root.
`podman run -d --name dev -v ~:/w -w /w quay.io/fedora/fedora:45 sleep infinity`, then
`podman exec dev dnf install -y gcc` and `podman exec dev make`.
- On the host: git, ssh, curl, tar/gzip/xz/zstd, find, diff, ps, ip.
- **Everything resets at reboot**: your home (/var/home/claude), /tmp and all containers and
images. Only your Claude login survives. Keep results somewhere else (push them to git, for
example). The VM may reboot at about 04:10 to update.
- **Your files survive reboots**: your home (/home/claude), containers and images stay.
/tmp is wiped at every boot. The VM may reboot at about 04:10 to update.
- **To start over**, push what you want to keep, then remove all containers and images with
`podman system reset --force` and delete everything in your home but `~/.claude` and
`~/.claude.json`, which hold your Claude login.
-5
View File
@@ -1,5 +0,0 @@
# Environment
#
# Claude's config, with its login, lives on /var/lib/agent instead of in the
# home, because the home is wiped at every boot.
CLAUDE_CONFIG_DIR=/var/lib/agent/claude
-11
View File
@@ -1,11 +0,0 @@
# Mounts
#
# /var is the only partition on disk that is written (mkosi.repart/30-var.conf).
# x-systemd.growfs grows its filesystem to fill the partition at boot. noatime
# skips the write that the default (relatime) makes at the first read of a file
# each day. Images that podman unpacks are full of such files; nothing here uses
# access times.
PARTLABEL=var /var ext4 noatime,x-systemd.growfs 0 2
# /root is in memory, so root has a writable home that is wiped at every boot.
# Root's ssh key lives on /var (mkosi.extra/etc/ssh/sshd_config.d).
tmpfs /root tmpfs mode=0700 0 0
View File
Whitespace-only changes.
@@ -1,22 +0,0 @@
# ssh login
#
# Login is with keys only, for root and the user claude. Neither has a key
# until root adds one (README.md). The first value wins, and this file sorts
# before Fedora's 50-redhat.conf.
# HostKey lives on /var (agent-boot makes it), so it stays the same across
# reboots.
HostKey /var/lib/agent/ssh_host_ed25519_key
PasswordAuthentication no
KbdInteractiveAuthentication no
# AuthorizedKeysFile of the user claude is owned by root, so Claude can't add
# keys.
Match User claude
AuthorizedKeysFile /var/lib/agent/authorized_keys
# AuthorizedKeysFile of root is on /var, because its home is wiped at every
# boot (/etc/fstab). It also reads the default file, which the
# ssh.authorized_keys.root credential fills, such as for mkosi ssh.
Match User root
AuthorizedKeysFile /var/lib/agent/root_authorized_keys .ssh/authorized_keys
+1 -1
View File
@@ -1 +1 @@
claude:524288:65536
agent:524288:65536
+1 -1
View File
@@ -1 +1 @@
claude:524288:65536
agent:524288:65536