Mkosi for Arch Boxes

Questions

  • how do we make profiles?

    • profile for basic
    • profile for cloud-init
    • profile for vagrant and vagrant-libvirt
  • how do we make btrfs partition of 40GB for basic

  • how do I add a user with sudo? => https://github.com/DaanDeMeyer/mkosi/blob/main/mkosi/resources/mkosi.md#frequently-asked-questions-faq

  • how do I cache the package manager step

  • how do I create a qcow2 after the final step? => mkosi.postoutput

  • do we need to remove /etc/machine-id?

  • How do we apply sed -i 's/^GRUB_CMDLINE_LINUX_DEFAULT=.*/GRUB_CMDLINE_LINUX_DEFAULT=\"rootflags=compress-force=zstd\"/' "${MOUNT}/etc/default/grub"

  • Can we boot test in CI? Check if swap is enabled etc.? Systemd units run? systemctl --failed is green?

Resources

  • https://btrfs.readthedocs.io/en/latest/Swapfile.html
  • https://swsnr.de/archlinux-rescue-image-with-mkosi/
  • https://noise.getoto.net/2024/01/10/a-re-introduction-to-mkosi-a-tool-for-generating-os-images/

Requirements

  • mkosi
  • systemd-ukify
  • grub
  • btrfs-progs

Creation

cd projects/arch-boxes/cloud-init-image
mkdir mkosi.{cache,output}
mkosi build

Issues

Traceback (most recent call last):
  File "/home/jelle/projects/mkosi/mkosi/run.py", line 60, in uncaught_exception_handler
    yield
  File "/home/jelle/projects/mkosi/mkosi/run.py", line 101, in fork_and_wait
    target(*args, **kwargs)
  File "/home/jelle/projects/mkosi/mkosi/__init__.py", line 4637, in run_build
    build_image(Context(args, config, workspace=workspace, resources=resources))
  File "/home/jelle/projects/mkosi/mkosi/__init__.py", line 3833, in build_image
    install_grub(context)
  File "/home/jelle/projects/mkosi/mkosi/__init__.py", line 1460, in install_grub
    grub_mkimage(context, target="i386-pc", modules=("biosdisk",))
  File "/home/jelle/projects/mkosi/mkosi/__init__.py", line 1371, in grub_mkimage
    assert mkimage
           ^^^^^^^
AssertionError
  • Lack of grub on my system, but assert could tell me that :)

Should mkosi qemu read BiosBootLoader options and then use mkosi --qemu-firmware bios qemu

How to exit QEMU? Maybe add ctrl+] support like nspawn?

modifications in mkosi qemu stay, seems somewhat unexpected