# 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. # - mkosi.images/job/ builds the job image. [Config] # Dependencies builds the job image first, so ExtraTrees= can copy it in. Dependencies=job [Distribution] Distribution=fedora Release=45 [Output] # Output writes runneros_.* to mkosi.output/. The UKI and /usr # partitions are split into the files of an update. ImageId=runneros OutputDirectory=mkosi.output SplitArtifacts=uki,partitions ManifestFormat=json [Content] # Content sets what goes into the image: # - WithDocs leaves out man pages. The image has no man to read them. # - Packages lists the packages installed into the image. # - ExtraTrees copies the job image (mkosi.images/job/) into /usr. # - UnifiedKernelImageFormat names the UKI runneros_.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 hostname is runneros- and four hex digits of the machine ID, also # the name the runner registers with. Unlike /etc/hostname, which only # exists once tmpfiles links it, the command line has it from the first # boot on. # - 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. WithDocs=no 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. git-core # The runner fetches the actions jobs use. curl procps-ng iproute ExtraTrees=%O/job:/usr/lib/runneros/job UnifiedKernelImageFormat=%i_%v KernelCommandLine= quiet rw systemd.hostname=runneros-???? 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_scsi nvme dm-verity dm-crypt erofs KernelModules= /* -/drivers/* /drivers/virtio/* /drivers/block/* /drivers/md/* nvme virtio_scsi virtio_net qemu_fw_cfg bochs virtio-gpu veth tun RemoveFiles= /usr/lib/modules/*/System.map /usr/lib/udev/hwdb.bin /usr/lib/udev/hwdb.d [Validation] # Validation signs the boot chain with mkosi.key, so the TPM unlocks the root # filesystem only for our UKIs. SecureBoot=yes 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