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

+23 -17
View File
@@ -5,24 +5,30 @@ It is a minimal Fedora image built with
[mkosi](https://github.com/systemd/mkosi). You control Claude from
claude.ai/code or the Claude app (Remote Control), or log in with ssh.
- **Resets at reboot:** the homes of Claude and root, `/tmp` and all containers
are wiped at every boot. Only the setup answers, the ssh keys and Claude's
login survive (`/var/lib/agent`).
- **Read-only OS:** the root filesystem is read-only, so Claude can't change
the OS. All state lives on `/var`.
- **Tools in containers:** Claude runs as the user `claude`, without root, and
runs its toolchains in containers with podman. The host has only git, ssh and
basic command-line tools.
- **Self-updating:** the `os` rebuilds weekly and updates with
systemd-sysupdate.
- **Read-only OS:** `/usr` is read-only, so Claude can't change the OS. Secure
Boot verifies the UKI (kernel, initrd and command line), which holds the
dm-verity hash that verifies `/usr`.
- **Encrypted with a TPM:** everything that isn't read-only, such as `/etc`,
`/var` and `/home`, is encrypted. The TPM unlocks it only for those signed
UKIs.
- **Tools in containers:** Claude runs as the user `agent`, without root, and
runs its toolchains in containers with podman.
- **Self-updating:** the image rebuilds weekly. A bad update rolls back by
itself.
## Install
Download [the disk image](https://git.plabble.org/api/packages/Job79/generic/agent/latest/agent.qcow2),
resize it to the disk size you want and boot it with UEFI. At first boot, the
console asks for a root password and a hostname. Then log in as root, add an
ssh key for the user `claude` and run Claude once to sign in. The VM then shows
up in claude.ai/code and the Claude app under its hostname.
resize it to the disk size you want and boot it with UEFI and a TPM. At first
boot, the screen offers a recovery key for the encrypted disk and asks for a
root password. Then log in as root and put your ssh key in
`/home/agent/.ssh/authorized_keys` (for root: `~/.ssh/authorized_keys`), which
starts sshd. Run `claude` once as `agent` to sign in. The VM then shows up in
claude.ai/code and the Claude app under its hostname: `agent-` and four hex
digits.
To start over, run `systemctl start factory-reset.target` as root. It reboots
and wipes `/etc` and `/var`, and the VM sets itself up as at first boot.
## Development
@@ -32,10 +38,10 @@ mkosi build
```
`mkosi.output/` then holds the disk image (`agent_<version>.raw`) and the UKI
and root partitions that make up an update.
and /usr partitions that make up an update.
To build and boot a test VM (needs `qemu-kvm-core edk2-ovmf openssh-clients
socat`):
To build and boot a test VM (needs `qemu-kvm-core edk2-ovmf swtpm
openssh-clients socat`):
```sh
mkosi -f vm # opens its console: log in as root, password root