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:
39 files changed
+229
-342
No files matched your search
@@ -7,8 +7,8 @@ every change.
|
||||
|
||||
- Keep it simple. Prefer fewer files, fewer lines and the defaults. Delete what
|
||||
isn't needed.
|
||||
- Divide code and config into parts (files, directories, config sections) that
|
||||
each stand on their own: reading one alone tells you what it does and why.
|
||||
- Divide code and config into parts (files, directories, sections) that each
|
||||
stand on their own: reading one part alone tells you what it does and why.
|
||||
- Each fact lives in one place. Elsewhere, refer to it by path instead of
|
||||
repeating it.
|
||||
- Write plain English in short sentences.
|
||||
@@ -40,8 +40,8 @@ the file that uses them.
|
||||
write clean code instead of many comments.
|
||||
- Put a comment right above the line or block it is about.
|
||||
- Write full sentences that start with the name of what they describe:
|
||||
`# PackageCacheDirectory keeps downloaded packages between builds.` or
|
||||
`# cred prints the credential agent.<name>, and fails if it isn't passed.`
|
||||
`# ManifestFormat lists the packages and versions in the image.` or
|
||||
`# link prints the tmpfiles line for /etc/$1.`
|
||||
- Wrap comments at 80 columns.
|
||||
|
||||
## Testing
|
||||
@@ -52,22 +52,24 @@ run mkosi in a privileged podman container that boots systemd:
|
||||
```sh
|
||||
podman build -t mkosi-vm - <<'END'
|
||||
FROM registry.fedoraproject.org/fedora:45
|
||||
RUN dnf install -y mkosi qemu-kvm-core edk2-ovmf systemd-repart \
|
||||
RUN dnf install -y mkosi qemu-kvm-core edk2-ovmf systemd-repart swtpm \
|
||||
openssh-clients socat && \
|
||||
dnf install -y $(mkosi dependencies)
|
||||
CMD ["/sbin/init"]
|
||||
END
|
||||
podman run -d --name mkosi --privileged --systemd=always -v <repo>:/repo \
|
||||
-w /repo mkosi-vm
|
||||
-v mkosi-cache:/root/.cache/mkosi -w /repo mkosi-vm
|
||||
podman exec mkosi mkosi genkey # once, if there is no mkosi.key
|
||||
podman exec -d -t mkosi sh -c 'mkosi -f vm > mkosi.output/vm.log 2>&1'
|
||||
podman exec mkosi mkosi ssh -- systemctl --failed
|
||||
```
|
||||
|
||||
podman resolves paths on the host, so `<repo>` is the repository's path there.
|
||||
The volume `mkosi-cache` keeps mkosi's package cache when the container is
|
||||
made again, so builds don't download every package anew.
|
||||
`mkosi vm` needs a terminal, hence `-d -t`; its console goes to the log.
|
||||
`mkosi ssh` runs a command as root, once the VM has booted. For the user
|
||||
`claude`, run `su - claude -c '<command>'`.
|
||||
`agent`, run `su - agent -c '<command>'`.
|
||||
|
||||
`mkosi.version` gives every run a new version, so `mkosi vm` without `-f` fails
|
||||
with "has not been built yet". To boot an existing build without a rebuild, pin
|
||||
|
||||
Reference in new issue
Block a user