Seal /etc: read-only root with /etc and /usr, state on /var

The root filesystem (/etc and /usr) is now one read-only erofs partition behind dm-verity,
updated A/B as a whole, so /etc can no longer drift from the image (stale CA certificates,
frozen Fedora defaults). All state lives on a new /var partition, mounted by /etc/fstab.

What used to be written to /etc at runtime:
- machine ID: from the VM's firmware UUID (systemd.machine_id=firmware); /etc/machine-id is
  empty, so no boot counts as the first.
- root password: gitea-runner-setup writes a shadow file to /var/lib/shadow, which
  etc-shadow.mount puts over /etc/shadow.
- hostname and runner.env: runner.env moves to /var/lib/gitea-runner and holds the runner's
  name; gitea-runner.service sets it as the (transient) hostname, and DHCP no longer does.

Hosts installed before this change must be reinstalled: updates can't change the partition
layout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V27snrGfdvwU7pMNBiDpHv
This commit is contained in:
Job79andClaude Opus 5.5 committed 2026-11-14 12:12:10 +01:00
1 parent c2ec9ddb29
commit b0a49de3e6
25 files changed
+96 -63

No files matched your search

+9 -4
View File
@@ -1,5 +1,7 @@
#!/bin/bash
# First boot: ask for the root password and the runner's registration.
# First boot: asks for the root password and the runner's registration on the console (tty1).
# /etc is read-only, so the answers go to /var: the password to /var/lib/shadow (etc-shadow.mount
# puts it over /etc/shadow), the rest to the runner's runner.env.
set -euo pipefail
echo "== Gitea runner setup =="
@@ -9,15 +11,18 @@ while :; do
[[ -n $pw && $pw == "$pw2" ]] && break
echo "Passwords do not match, try again."
done
echo "root:$pw" | chpasswd
install -d -m 0700 /var/lib/shadow/etc
cp /etc/passwd /etc/shadow /var/lib/shadow/etc/
echo "root:$pw" | chpasswd --prefix /var/lib/shadow
systemctl start etc-shadow.mount
read -rp "Hostname (also the runner name): " name
read -rp "Gitea URL (e.g. https://gitea.example.com): " url
read -rp "Runner registration token: " token
read -rp "Parallel jobs [1]: " capacity
[[ $capacity =~ ^[1-9][0-9]*$ ]] || capacity=1
hostnamectl hostname "$name"
install -D -m 0640 -g gitea-runner /dev/stdin /etc/gitea-runner/runner.env <<ENV
install -D -m 0640 -g gitea-runner /dev/stdin /var/lib/gitea-runner/runner.env <<ENV
GITEA_RUNNER_NAME=$name
GITEA_INSTANCE_URL=$url
GITEA_RUNNER_REGISTRATION_TOKEN=$token
GITEA_RUNNER_CAPACITY=$capacity