Skip to content

22. An immutable VM OS under Lima

The Mac runner's VM is Debian 13 provisioned at first boot by install.sh --vm, from an image that Lima's template fetches unpinned. Gavin (2026-11-24): make the VM an image we build, a digest-pinned Fedora bootc base plus our bits, read-only root, with /var on its own disk that the runner can throw away after an unclean stop. This asks whether that works under Lima. The stack inside (containerd, gVisor, SELinux enforcing, a composefs root) is #15's, so the questions are Lima's side.

Predictions

Written before running. Lima 2.3.0, vmType: vz, arm64, 4 CPUs, 8 GiB. The image: quay.io/fedora/fedora-bootc:45 by digest, plus cloud-init, containerd, gVisor, deploy/linux's units and egress files and the allmyram binaries, built in a throwaway Fedora VM by osbuild's image-builder as a raw disk. Lima boots that file only; /var is a second Lima disk the image formats when blank.

Question Expected
1. Boots under Lima vz: guest agent, warden socket forwarded, share mounted and writable, SELinux enforcing yes, after one or two fixes: cloud-init's user home and the guest agent's install prefix on a fresh /var, and an SELinux label on the blank disk's root
2. A gVisor job with forced egress (spike/lima_egress_check.py's probe) passes as in #18; the image's own allmyram proxy replaces the spike's proxy
3. Blank /var disk: services come up; first-boot time yes; first boot 15–25 s (mkfs, cloud-init's per-instance work, tmpfiles)
4. Hard-kill mid-job, recreate the /var disk, boot root intact (read-only, nothing written to it); the next job works after pulling its image again
5a. Warm start until a gVisor pod has exited (#17: 5.8–7.1 s) similar, 6–9 s
5b. Start with a blank /var until the pod has exited (image pulled again) 20–30 s
5c. Fresh instance (create, then start) until the pod has exited 25–40 s (Lima copies the raw image, then 5b)
5d. Idle footprint at 8 GiB (#18: about 700 MB) about the same, 650–750 MB
5e. Image size raw about 10 GiB apparent, 2–3 GiB used; zstd about 1 GiB
6a. Build time 5–10 min the first time (base pull, dnf, image-builder), 2–4 min cached
6b. Reproducible from the pinned base no: dnf install takes the day's packages, so the same Containerfile gives a different image later; byte-identical even on the same day is unlikely

Setup (2026-11-24)

  • The MacBook and Lima 2.3.0 as in #17. Every VM in its own scratch LIMA_HOME under /private/tmp/claude-501/ (v22b for the build VM, v22 for the spike VM); nothing in ~/.lima or the runner's state.
  • Base: quay.io/fedora/fedora-bootc:45, pinned by its manifest list sha256:d440aea898005f376bbf0bbe06c216abdba68dcdb6dfa5cb0fa246cd03fa8d8a (linux/arm64 manifest sha256:44a2bbcd559f277e7580e25c2b056b5406d3ed6d9f265d5044b30b9286d38251), the 45 tag on 2026-11-24. Kernel 7.3.4-300.fc45, systemd 262.1, bootc 1.17.1, ostree 2026.4; composefs root, read-only sysroot.
  • Image (spike/vmimage/Containerfile): dnf adds cloud-init 26.2, containerd 2.4.2, containernetworking-plugins 1.10.0, cri-tools 1.29.0 and rsync (openssh-server and nftables are in the base). gVisor release-20261116.0 aarch64 (install.sh's sha512) and the allmyram binaries (linux/arm64, -trimpath) go to /usr/local/bin, which in this base is a plain directory of the read-only /usr, not Bazzite's link to /var/usrlocal. Users from sysusers.d with fixed ids (allmyram-warden 880, allmyram-proxy 881, allmyram-job 882, group allmyram-share 883), so warden.json (allowed_uid 0, runner 882) and containerd's config (socket gid 880) are baked in whole. containerd's config is containerd-cri-1.7.toml in config version 3 with Fedora's /usr/libexec/cni. deploy/linux's units, egress.nft and CNI conflist unchanged, plus install.sh's warden drop-in and @SHARE@. tmpfiles.d makes /var/lib/allmyram and the warden's directories and removes stale CNI results at every boot. bootc container lint passes.
  • Build (spike/vmimage/build.sh): a Fedora 45 Lima VM (spike/vmimage/build-vm.yaml, 4 CPUs, 8 GiB) with podman 6.1.3 and image-builder 89.0.0 (osbuild 193), sudo podman build, then sudo image-builder build raw --bootc-ref localhost/allmyram-vm:latest --bootc-default-fs xfs (the base names no default filesystem), zstd -10, copied out over virtiofs and unpacked on the Mac.
  • Lima (spike/lima_bootc.yaml): images: the local raw only, no base:; 4 CPUs, 8 GiB, disk: 20GiB; the share, socket forward and ports rule of internal/limavm/template.yaml; additionalDisks: [{name: x22-var, format: false, mount: false}], a 20 GiB raw disk from limactl disk create.
  • Scripts: spike/lima_bootc_var.py (check, warm, blank-var, fresh, kill; its job is a real warden run through the forwarded socket on the Mac: a workspace staged on the share, alpine 3.20 in gVisor as allmyram-job, the CRI log read on the Mac); spike/lima_egress_check.py --image (#18's probe, against the image's own egress units and the real allmyram proxy); spike/lima_start_stop.py --instance x22 (#17's method, now picking the instance's own Virtualization.framework process when several VMs run).

Raw results

What it took to boot. The first image booted and SSH worked, but Lima reported DEGRADED: four fixes, each now in the image or template.

Problem Evidence Fix
Guest agent not installed install: cannot create regular file '/usr/local/bin/lima-guestagent': Read-only file system guestInstallPrefix: /var/usrlocal
Lima's boot script installs rsync dnf install ... rsync: this bootc system is configured to be read-only rsync in the image
/var stayed on the root disk the image's /etc/fstab was gone: bootc's install writes its own (/boot only), and ostree-system-generator then bind-mounts the deployment's var a var.mount unit in /etc/systemd/system (outranks the generator's) on /dev/vdb, after a oneshot running systemd-makefs xfs /dev/vdb, which formats only a disk with no filesystem
Guest agent dead after a new /var Lima's unit in /etc survives, its binary on /var doesn't: it fails at boot, hits start-limit-hit, and the boot script's systemctl start is refused drop-in ConditionPathExists=/var/usrlocal/bin/lima-guestagent: skipped at boot, started by the boot script

A blank filesystem's root has no SELinux label; the mount's rootcontext=system_u:object_r:var_t:s0 gives it var_t. vz attaches the root disk at PCI slot 6 (vda), the additional disk at 7 (vdb), cidata at 8 (vdc); the disks carry no serial. Lima's boot script runs growpart and fsck on /dev/vdb1 of an unformatted disk (format: false); with the filesystem on the whole disk there is no vdb1 and it touches nothing.

1. Boot, share, socket, SELinux (lima_bootc_var.py check):

  • SELinux Enforcing. / is composefs ro; touch /usr/bin/x: read-only file system. /var is /dev/vdb xfs. bootc status: booted localhost/allmyram-vm:latest.
  • Lima mounts the share with context=system_u:object_r:nfs_t:s0 (its boot script adds that under SELinux). VM root wrote a file there; the Mac read it.
  • The warden socket on the Mac: 0600, the Mac user's. A warden job through it: exit 0, Completed; the job read the Mac's file from its workspace and ran as uid 882 inside gVisor; its CRI log on the share was read on the Mac.
  • containerd, allmyram-egress, allmyram-warden, allmyram-proxy active. AVC denials in a normal boot: 0 (no auditd in the image; counted in the journal).
  • allmyram-proxy fails once at every boot and starts 5 s later on Restart=: Failed to set up mount namespacing: /run/containerd: No such file or directory (its InaccessiblePaths=/run/containerd before containerd has made it; the unit has no ordering against containerd).

2. Forced egress (lima_egress_check.py --image): as #18.

Probe from a gVisor pod Outcome
https://example.com through 10.78.0.1:3128 200; the real proxy logged "decision":"allow","rule":"public"
Direct TCP 1.1.1.1:443, [2606:4700:4700::1111]:443 network unreachable
Direct TCP to the canary at the gateway (192.168.5.2), the VM (192.168.5.15), the Mac's two LAN and its tailnet addresses, the VM's sshd network unreachable
Direct TCP 10.78.0.1:22 and :53 timed out; nft's iifname "allmyram-e0" drop counted 44 packets
Canary connections on the Mac none

3. Blank /var. Every fresh and blank-/var boot came up with all four units active and the job passing. systemd-makefs took 13 ms; the guest reached cloud-final 2.7 s into userspace; systemd-analyze: kernel 0.2 s, initrd 1.4 s, userspace 2.8–8.1 s (the 8.1 s includes the proxy's 5 s restart). cloud-init treats a blank /var as a new instance (its state is in /var/lib/cloud) and rewrites the user's home and keys.

4. Hard kill, new /var (lima_bootc_var.py kill: a warden job sleep 600 running, kill -9 of the VM's process, limactl stop --force, limactl disk unlock (nothing to unlock: the stop had), disk delete, disk create, limactl start):

Kill Next boot
60 s after the VM's start fine: same image digest, same machine-id, ostree fsck "84 commits ... no errors", the old /var marker gone, next job exit 0, the killed run unknown to the warden; warden reachable 8.9 s after limactl start
~13 s and ~20 s after the start (two runs) no SSH: Lima's SSH connection step got Permission denied (publickey) until it gave up; Lima never became ready

The second case, from the failed boot's journal: cloud-init's passwd -l <user> failed (/etc/passwd.lock: Permission denied; AVC denied { write } ... comm="passwd" name="passwd.lock" ... tcontext=...:etc_t), so users_groups failed and neither the home directory nor the SSH key was written. A passwd.lock survived the crash on the root disk, labelled etc_t instead of passwd's own type. Every boot writes /etc (cloud-init rewrites /etc/shadow; Lima's boot scripts write units and config), and an /etc file written a second before the kill came back empty or missing. xfs had not yet written that back. Restarting once more (same new /var) booted fine, and the stale lock was gone.

5. Times and footprint.

Case limactl start (s) start → warden job exited (s)
Warm (5) 8.35–9.87 8.61–10.12
Blank /var (3; prepare: stop + disk recreate 1.7 s) 8.56–8.70 12.43–12.86 (alpine pulled again)
Fresh instance (3; limactl create 0.34–0.38 s) 12.49–12.96 16.50–16.88

17's method (lima_start_stop.py --instance x22, a crictl gVisor pod):

stop 1.55–1.59 s, start 8.65–9.04 s, start → pod exited 9.66–10.06 s (#17's Debian: 4.58–6.77 and 5.76–9.87). The guest is up in ~4.3 s; GRUB waits timeout=1 in this image. The rest of the gap to Debian was not traced.

VM running (8 GiB) Host footprint
Idle, 30 / 60 / 90 s after a start 1314 / 1314 / 1314 MB
Idle after #17's cycles 1440 MB
During a job holding 2 GiB, and 60 s after 3506 / 3506 MB
Stock Fedora 45 cloud image (Lima's _images/fedora-45, no containerd), 30 / 60 s after a start 1053 / 1053 MB

The guest itself reported 464 MiB used and 383 MiB cache. The uv image pulled in 4.29 s fresh, 0.50 s cached.

Image: raw 10 GiB apparent (image-builder's default), 2.8 GiB allocated in the build VM; zstd -10 1,258,592,401 bytes. On the Mac, zstd -d --sparse left 7.0 GiB allocated, and Lima's clone of it into the instance shows the same. Partitions: EFI 501 MiB, /boot 1 GiB xfs, root xfs. bootc's bootc-generic-growpart.service grew the root to fill disk: 20GiB (19 GiB, 3.0 GiB used); cloud-init's own resizefs gives up on composefs (Device '/dev/composefs' did not exist), harmlessly.

6. Build.

Build Total Build VM podman build image-builder zstd, copy out, unpack
First (build VM already up, base not pulled) 555 s — 391 s ~100 s ~34 s
Cached, after a Containerfile change near the end 386 s — 276 s 77 s 30 s
Cold: new build VM, --no-cache 840 s 32 s 670 s 105 s 31 s

Creating and provisioning the build VM by hand earlier: 20.5 s create (Fedora cloud image download) and 37.7 s start with dnf install podman image-builder zstd. Most of podman build is podman committing each layer of a 2.7 GB image and the final bootc container lint. A cached build still rebuilt from COPY allmyram ... on: Go embeds the VCS revision, so every commit changes the binaries.

Same day, same Containerfile, cached build vs cold --no-cache build: the same 567 packages (rpms.txt identical), different image IDs (c5e7cd26… vs d155a233…), different raw images (sha256 d77073d6… vs 3d00b46d…).

What we learned

  • The gate passes: Fedora bootc boots under Lima vz arm64 with everything Plan 2's VM needs, SELinux enforcing, no denials in a normal boot. Four small fixes, all predictable once seen: the guest agent's install prefix, rsync, /var as a mount unit rather than an fstab line, and a condition on Lima's guest agent unit.
  • Forced egress holds unchanged, with the real proxy and the units from deploy/linux. Nothing about gVisor, containerd 2.4 or the CNI network needed changing beyond #15's config layout.
  • A blank /var works and costs nothing at boot: mkfs takes 13 ms, tmpfiles and cloud-init rebuild the rest; the only cost is pulling images again.
  • The root is not only the read-only image. /usr is immutable and survived every kill (ostree fsck clean), but /etc lives on the root disk and is written at every boot, by cloud-init and by Lima. A hard kill within ~20 s of a start left a stale, mislabelled /etc/passwd.lock; the next boot couldn't set up the Lima user, so Lima never got SSH. Two kills out of two at 13–20 s did this; one at 60 s was fine. Throwing away /var alone does not undo it.
  • A fresh instance is cheap: limactl create from the local raw is 0.35 s (Lima clones the file), and start to a finished job is 16.5–16.9 s, against 12.4–12.9 s for a blank /var on the old root.
  • Slower and bigger than Debian. Warm start 8.4–9.9 s against #17's 4.6–6.8 s; idle footprint 1314 MB against #18's 700 MB. Most of the memory is Fedora's: a stock Fedora 45 cloud VM idles at 1053 MB. GRUB's timeout=1 accounts for at most 1 s of the start; the rest was not traced.
  • The build is repeatable, not reproducible. The pinned base fixes what we start from, but dnf takes the day's packages; the same day gave the same package set and different bytes. 14 min cold, 6.5 min cached.
  • The image is 1.26 GB compressed (zstd -10), 10 GiB apparent.

What it changes

  • An unclean stop recreates the whole instance (delete, then create from the cached raw), not just the /var disk: it costs ~4 s more and also resets /etc. With that, a separate /var disk buys nothing the runner uses, so Tasks 11+ can drop additionalDisks, var.mount and the guest agent condition, and keep /var on the root disk. (If a separate disk comes back for another reason, /etc needs its own answer, such as ostree's transient /etc, untried here.)
  • Tasks 11+ build from this Containerfile: /usr/local/bin for binaries, units unchanged, users from sysusers.d with fixed ids, warden.json baked in (only registries is per-VM), guestInstallPrefix: /var/usrlocal, rsync. The Mac runner must create staging/, logs/ and pods/ in the share itself; install.sh --vm did that in the VM.
  • deploy/linux/allmyram-proxy.service should order itself after containerd (After=containerd.service): its InaccessiblePaths=/run/containerd fails the first start at every boot of the image. Debian's VM has the same unit; whether it hits this at boot there was not checked.
  • containerd 2.4 warns that config version 3 is migrated (its default is version 4); the version 3 layout works.
  • Publishing: 1.26 GB per image. Each build differs in bytes, so the runner pins the sha512 of the published file, not of a rebuild.
  • Gavin to weigh before Tasks 11+: about 600 MB more memory per running VM and ~3 s more per start than Debian, the trade for a pinned, read-only OS. The plan's fallback (a baked Debian raw, reset by recreating the instance) should keep #17's numbers (not measured here), and this experiment's recreate-the-instance answer fits it equally.