Rewrite on the layout of agentos
os / os (push) Failing after 29s

Start again from agentos: a read-only, verity-checked /usr with A/B
updates, and a TPM-encrypted btrfs root made at first boot that holds
/etc and /var. On top of that the runner: gitea-runner from gitea.com,
a path unit that starts it once registered, and a drain before update
reboots. Jobs run in plain Fedora on root's podman.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Job79andClaude Opus 5.5 committed 2026-11-22 15:59:36 +00:00
1 parent 0569bce676
commit 0733ff55f3
49 files changed
+492 -509

No files matched your search

+79 -81
View File
@@ -1,88 +1,87 @@
# git-runner: a Fedora VM image that runs the Gitea Actions runner, built with mkosi.
# mkosi.extra/ is copied to /, mkosi.repart/ defines the disk, mkosi.prepare adds the runner,
# mkosi.images/job/ is the job image.
# The root filesystem, /etc included, is read-only and replaced whole by updates; all state
# lives on /var.
[Config]
Dependencies=job
# mkosi.conf builds runneros, a Fedora VM image that runs a Gitea Actions
# runner. The image holds a read-only /usr. The root filesystem, which holds
# the state, is made at first boot.
#
# The other parts of the build:
# - mkosi.extra/ is copied to /.
# - mkosi.repart/ defines the disk image: the ESP and the /usr partitions.
# - mkosi.extra/usr/lib/repart.d/ makes the root partition at first boot.
# - mkosi.prepare installs the runner, which Fedora doesn't package.
# - mkosi.finalize keeps /etc in /usr/share/factory/etc.
# - mkosi.version gives each build its version.
[Distribution]
Distribution=fedora
Release=45
[Output]
Format=disk
ImageId=git-runner
# Output writes runneros_<version>.* to mkosi.output/. The UKI and /usr
# partitions are split into the files of an update.
ImageId=runneros
OutputDirectory=mkosi.output
# The UKI and root partitions are published as updates (systemd-sysupdate).
SplitArtifacts=uki,partitions
ManifestFormat=json
[Content]
Bootable=yes
# The job image (mkosi.images/job/); gitea-runner-images.service loads it at boot.
ExtraTrees=%O/job:/usr/lib/gitea-runner/job-image
Bootloader=systemd-boot
# - kernel-core no drivers or firmware beyond what VMs need
# - systemd-container, gnupg2 systemd-pull, which systemd-sysupdate downloads with, and gpg,
# which it checks their signature with
# - systemd-boot-unsigned the bootloader
# - util-linux, shadow-utils console login and the first-boot setup
# - podman, git-core the runner's jobs; git fetches actions
# - nftables-services the firewall
# - zram-generator-defaults compressed swap in RAM
Packages=
kernel-core
systemd
dbus-broker
systemd-udev
systemd-networkd
systemd-resolved
systemd-container
gnupg2
systemd-boot-unsigned
util-linux
shadow-utils
podman
git-core
nftables-services
zram-generator-defaults
# Content sets what goes into the image:
# - Hostname is runneros- and four hex digits of the machine ID. It is also
# the name the runner registers with.
# - WithDocs leaves out man pages. The image has no man to read them.
# - Packages lists the packages installed into the image.
# - UnifiedKernelImageFormat names the UKI runneros_<version>.efi, which
# matches the MatchPattern= of mkosi.extra/usr/lib/sysupdate.d/20-uki.transfer.
# - KernelCommandLine:
# - rw has the initrd mount the root filesystem writable. It finds it by its
# partition type (mkosi.extra/usr/lib/repart.d/50-root.conf).
# - The image policy only accepts an encrypted root filesystem (or none, at
# first boot) and a verity-checked /usr. Otherwise someone with the disk
# could swap in a plain root filesystem. Our UKI would boot it, and their
# code could unseal the key of the real one.
# - The root btrfs keeps one copy of its metadata instead of two (DUP,
# mkfs.btrfs's default). On a VM disk a second copy adds little.
# - The mount rate limit is raised from 5, which holds back mounts at boot
# and delays / and /usr by up to a second each.
# - KernelInitrdModules are what the initrd needs to find the disks of a VM,
# mount /usr and unlock the root filesystem. The kernel has virtio_blk,
# sd_mod, the TPM drivers and btrfs built in.
# - KernelModules keeps all modules but the hardware drivers, then adds back
# the drivers a VM needs (disks, network, screen) and those of podman's
# networks (veth, tun). The last matching line wins. Keyboard, USB and a
# basic screen are built into the kernel.
# - RemoveFiles drops System.map, which is only for debugging the kernel, and
# the udev hwdb, which holds hardware names and quirks a VM doesn't need.
# Without hwdb.d, systemd-hwdb-update can't build it again at boot.
Hostname=runneros-????
WithDocs=no
Locale=C.UTF-8
# The UKI's file name in the ESP, as systemd-sysupdate names the ones it installs.
Packages=
kernel-core # Unlike kernel, this has no extra drivers.
systemd # The init and service manager is PID 1.
dbus-broker # D-Bus serves systemd and podman.
systemd-udev # Udev, sysupdate, repart, cryptsetup are here.
systemd-networkd # DHCP runs on every network card.
systemd-resolved # DNS names are resolved here.
systemd-container # Sysupdate needs its systemd-pull and gnupg2.
systemd-boot-unsigned # mkosi signs this boot loader.
util-linux # The console login needs its login.
systemd-pam # Logins get a session.
zram-generator-defaults # Swap is compressed in RAM.
podman # The runner runs its jobs in containers.
curl
procps-ng
iproute
UnifiedKernelImageFormat=%i_%v
# The console on screen and serial port, the machine ID from the VM's firmware (/etc is read-only;
# mkosi.extra/etc/machine-id is empty, so no boot counts as the first), no systemd-firstboot
# questions (gitea-runner-setup asks its own), freeing memory unused for an hour (damon_reclaim, in
# µs; the watermarks make it run whatever memory is free), so the host can take it back
# (virtio-balloon free page reporting), and KSPP hardening (the last four).
KernelCommandLine=
console=tty0
console=ttyS0,115200n8
quiet
systemd.machine_id=firmware
systemd.firstboot=no
damon_reclaim.enabled=Y
damon_reclaim.min_age=3600000000
damon_reclaim.wmarks_high=1000
damon_reclaim.wmarks_mid=999
damon_reclaim.wmarks_low=0
slab_nomerge
init_on_alloc=1
randomize_kstack_offset=on
page_alloc.shuffle=1
# Kernel modules in the initrd: only what finds and mounts the disks of a VM.
rw
systemd.image_policy=root=encrypted+absent:usr=verity:esp=unprotected
systemd.setenv=SYSTEMD_REPART_MKFS_OPTIONS_BTRFS=--metadata=single
SYSTEMD_DEFAULT_MOUNT_RATE_LIMIT_BURST=50
KernelInitrdModules=
virtio_blk
virtio_scsi
sd_mod
nvme
dm-verity
dm-crypt
erofs
xfs
# Kernel modules in the image: all but the hardware drivers, then the drivers of a VM (disks,
# network, screen) and of podman's networks. The last matching line wins. Keyboard, USB and a
# basic screen are built into the kernel.
KernelModules=
/*
-/drivers/*
@@ -91,31 +90,30 @@ KernelModules=
/drivers/md/*
nvme
virtio_scsi
sd_mod
virtio_net
qemu_fw_cfg
bochs
virtio-gpu
veth
tun
macvlan
ipvlan
# - System.map only for debugging the kernel
# - udev hwdb hardware names and quirks, nothing a VM needs
# - homed, userdbd, nsresourced unused services
RemoveFiles=
/usr/lib/modules/*/System.map
/usr/lib/udev/hwdb.bin
/usr/lib/udev/hwdb.d
/usr/lib/systemd/system/systemd-homed*
/usr/lib/systemd/system/systemd-userdbd.*
/usr/lib/systemd/system/systemd-nsresourced.*
[Validation]
# Signs systemd-boot and the UKI for Secure Boot, and puts our keys on the ESP, where systemd-boot
# enrolls them at first boot if the firmware is in setup mode (no keys enrolled; in Proxmox, an EFI
# disk without pre-enrolled keys). mkosi.crt is the certificate; mkosi.key, its private key, is the
# SECUREBOOT_KEY secret of this repository, which the os workflow writes to mkosi.key.
# Validation signs the boot chain with mkosi.key, so the TPM unlocks the root
# filesystem only for our UKIs.
SecureBoot=yes
SecureBootKey=mkosi.key
SecureBootCertificate=mkosi.crt
SignExpectedPcr=yes
[Runtime]
# Runtime sets up the test VM of mkosi vm. Each run boots a fresh copy, with
# root password root and no first boot questions. It has enough memory and
# disk to build this image in a job.
Ephemeral=yes
CPUs=4
RAM=6G
RuntimeSize=40G
Credentials=passwd.plaintext-password.root=root
KernelCommandLineExtra=systemd.firstboot=no