# mkosi.conf builds a Fedora VM image that runs Claude Code in the background. # /usr is read-only and replaced whole by updates. The root filesystem holds # the state. # # 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.finalize keeps /etc in /usr, and links it into /etc at boot. # - mkosi.sandbox/ adds the Claude Code package repository. # - mkosi.version gives each build its version. [Distribution] Distribution=fedora Release=45 [Build] # ToolsTree builds with mkosi's own Fedora tools, the same on every host, # so the host needs only mkosi and git (for mkosi.version). The tools land in # mkosi.tools/. ToolsTree=yes ToolsTreeRelease=%r Incremental=yes CacheDirectory=mkosi.cache [Output] Format=disk ImageId=agent OutputDirectory=mkosi.output SplitArtifacts=uki,partitions ManifestFormat=json [Content] Packages= kernel-core # It has no drivers or firmware VMs don't need. systemd # It is the init and service manager. dbus-broker # It is D-Bus, for the user manager and podman. systemd-udev # It has udev, sysupdate, repart and cryptsetup. systemd-networkd # It runs DHCP on every network card. systemd-resolved # It resolves DNS names. systemd-container # It has systemd-pull and gnupg2 for sysupdate. systemd-boot-unsigned # It is the boot loader, which mkosi signs. util-linux # It has login, for the console login. shadow-utils # It has newuidmap for rootless podman. systemd-pam # It gives logins a session and user manager. openssh-server # It lets you log in once there is a key. zram-generator-defaults # It sets up compressed swap in RAM. podman # It runs Claude's tools in containers. claude-code # It comes from mkosi.sandbox/etc/yum.repos.d. git-core # It brings openssh-clients to push over ssh. # The rest are basic command-line tools Claude uses on the host. curl tar gzip xz zstd diffutils findutils procps-ng iproute WithDocs=no Locale=C.UTF-8 # Hostname is agent- and four hex digits of the machine ID. Hostname=agent-???? # UnifiedKernelImageFormat names the UKI in the ESP agent_.efi, which # matches the MatchPattern= of mkosi.extra/usr/lib/sysupdate.d/20-uki.transfer. UnifiedKernelImageFormat=%i_%v KernelCommandLine= # The console shows on the serial port and the screen. The screen # comes last, so systemd-firstboot asks for the root password there. console=ttyS0,115200n8 console=tty0 quiet # The initrd finds the root filesystem by its partition type # (mkosi.extra/usr/lib/repart.d/50-root.conf) and mounts it writable. rw # 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. systemd.image_policy=root=encrypted+absent:usr=verity:esp=unprotected # The mount rate limit is raised from 5, which holds back mounts at # boot and delays / and /usr by up to a second each. SYSTEMD_DEFAULT_MOUNT_RATE_LIMIT_BURST=50 # KernelInitrdModules are the modules 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. KernelInitrdModules= virtio_scsi nvme dm-verity dm-crypt erofs # KernelModules keeps all modules but the hardware drivers, then the drivers a # VM needs (disks, network, screen) and those of rootless podman's networks # (pasta). The last matching line wins. Keyboard, USB and a basic screen are # built into the kernel. KernelModules= /* -/drivers/* /drivers/virtio/* /drivers/block/* /drivers/md/* nvme virtio_scsi virtio_net qemu_fw_cfg bochs virtio-gpu veth tun # RemoveFiles drops what the image doesn't use: # - System.map is only for debugging the kernel. # - The udev hwdb holds hardware names and quirks, nothing a VM needs. Without # hwdb.d, systemd-hwdb-update can't build it again at boot. RemoveFiles= /usr/lib/modules/*/System.map /usr/lib/udev/hwdb.bin /usr/lib/udev/hwdb.d [Validation] # SecureBoot signs systemd-boot and the UKI, and puts our keys on the ESP. # systemd-boot enrolls them at first boot if the firmware is in setup mode (no # keys enrolled). SecureBoot=yes # SignExpectedPcr signs the PCR 11 values that each UKI will measure, with # mkosi.key. The TPM then unlocks the root filesystem only for UKIs we signed, # also after updates (mkosi.extra/usr/lib/repart.d/50-root.conf). SignExpectedPcr=yes [Runtime] # Runtime sets up the test VM of mkosi vm. Ephemeral=yes CPUs=4 RAM=4G RuntimeSize=40G QemuArgs=-serial chardev:console Credentials=passwd.plaintext-password.root=root KernelCommandLineExtra=systemd.firstboot=no