Minimalist installation of OpenBSD on the Apple M2 using QEMU
- Apple M2 running macOS Sonoma 14.4.1
- QEMU version 8.2.1
- OpenBSD 7.5 arm64
- install QEMU with Homebrew
brew install qemu
, also possible with MacPorts - Write a script with execute permissions
chmod +x qemu_aarch64_install_openbsd.sh
for installing the image.- Download the OpenBSD installation image
- Create an image of the OpenBSD drive
- Getting the edk2-aarch64-code
- Installing
#!/bin/sh -
curl https://ftp.eu.openbsd.org/pub/OpenBSD/7.5/arm64/miniroot75.img -o miniroot75.img
curl https://ftp.openbsd.org/pub/OpenBSD/7.5/arm64/SHA256 -o SHA256
shasum -c --ignore-missing SHA256
qemu-img create -f qcow2 obsd_aarch64.qcow2 32G
qemu-system-aarch64 \
-M virt \
-cpu host \
-accel hvf \
-smp 4 \
-m 4096 \
-nographic \
-serial mon:stdio \
-bios /opt/homebrew/share/qemu/edk2-aarch64-code.fd \
-drive file=miniroot75.img,format=raw,if=virtio \
-drive file=obsd_aarch64.qcow2,format=qcow2,if=virtio \
-netdev user,id=mynet0,hostfwd=tcp::7922-:22 -device virtio-net,netdev=mynet0
rm miniroot75.img SHA256
-
Follow the OpenBSD installation program, please notice the remarks at the end of this document:
-
When the installation is done,
pkill qemu-system-aarch64
like this:
qemu-system-aarch64 \
-M virt \
-cpu host \
-accel hvf \
-smp 4 \
-m 4096 \
-nographic \
-bios /opt/homebrew/share/qemu/edk2-aarch64-code.fd \
-drive file=obsd_aarch64.qcow2,format=qcow2,if=virtio \
-netdev user,id=mynet0,hostfwd=tcp::7922-:22 -device virtio-net,netdev=mynet0
-
there is a problem with the DNS if the network interface (vio0) is on
autoconf
so is better configure it manually, have a look at QEMU's User Networking, for instance IPv4 would work on10.0.2.15/24
and10.0.2.2
gateway. -
alternatively a full image
installXX.img
instead ofminirootXX.img
would work. -
for the lazy asses, like me, it is possible to do autoinstall(8) with an
install.conf
on your localhost like this one:System hostname = myHost IPv4 address for vio0 = 10.0.2.15 Default IPv4 route = 10.0.2.2 DNS nameservers = 1.1.1.1 8.8.8.8 Password for root = RootsPassword Setup a user = myName Password for user = myPassword Public ssh key for user = ssh-ed25519 AAA...318C [email protected] What timezone are you in = YOUR/TIMEZONE Which disk is the root disk = sd1 Location of sets = http HTTP Server = ftp.eu.openbsd.org URL to autopartitioning template for disklabel = http://10.0.2.2/openbsd-pgdb.disklabel
also possible to define the disk partition adding
openbsd-pgdb.disklabel
on your localhost like this one:/ 0.3G swap 2M 10% /altroot 0.3G /tmp 120M-4G 8% /var 3G 13% /usr 0.9G-3G 5% /usr/local 3G-7.5G 10% /home 9G-* 45%
Hello @ast3k!
Could you please take a look at possible workarounds, I did somehow manage to launch installer several times, but it ended up being unable to complete installation due to insufficient virtual disk size. Now it just throws these kind of errors