Booting BSD

FreeBSD and OpenBSD boot their stock arm64 images through U-Boot and EFI, as on hardware.

FreeBSD and OpenBSD boot the way they do on a real Arm board: U-Boot in flash starts the EFI loader on the disk, which starts the kernel. Both need U-Boot for QEMU's virt board; see U-Boot.

FreeBSD

FreeBSD publishes raw arm64 disk images.

curl -LO https://download.freebsd.org/releases/VM-IMAGES/15.1-RELEASE/aarch64/Latest/FreeBSD-15.1-RELEASE-arm64-aarch64-ufs.raw.xz
unxz FreeBSD-15.1-RELEASE-arm64-aarch64-ufs.raw.xz

wemu-system-aarch64 -m 1G -bios u-boot.bin \
  -drive file=FreeBSD-15.1-RELEASE-arm64-aarch64-ufs.raw,if=virtio,format=raw -nographic

loader.efi runs, the kernel boots, fsck and the rc scripts run, and a login prompt appears: log in as root.

FreeBSD boots at EL2, using the Virtualization Host Extensions. To boot it at EL1 instead, use -M virt,virtualization=off.

OpenBSD

OpenBSD's miniroot79.img is its installer on a small disk image. It boots to the installer's prompt, from which you can install to a second disk or open a shell.

curl -LO https://cdn.openbsd.org/pub/OpenBSD/7.9/arm64/miniroot79.img

wemu-system-aarch64 -m 1G -bios u-boot.bin -drive file=miniroot79.img,if=virtio,format=raw -nographic
Welcome to the OpenBSD/arm64 7.9 installation program.
(I)nstall, (U)pgrade, (A)utoinstall or (S)hell?

To install, create an empty disk for it and add it as a second drive:

wemu-img create -f raw openbsd.img 8G
wemu-system-aarch64 -m 1G -bios u-boot.bin \
  -drive file=miniroot79.img,if=virtio,format=raw \
  -drive file=openbsd.img,if=virtio,format=raw -nographic

Notes

  • Both systems see a Cortex-A76 and QEMU's virt board, described by a device tree.
  • The images are opened in place, so what the guest writes reaches the file. Add -snapshot to leave an image unchanged.
  • A system that expects to find its disk on PCI, rather than virtio-mmio, needs -device virtio-blk-pci. See Disks and images.

See also