This guide was adapted from https://gist.github.com/niw/e4313b9c14e968764a52375da41b4278#running-ubuntu-server-for-arm64
-
Install Xcode from App Store or install Command Line Tools on your Mac running on Apple Silicon.
xcode-select --install
-
Install Homebrew and QEMU dependencies.
brew install ninja pkgconfig glib pixman libusb libssh zstd usbredir
-
Clone QEMU source code with patches applied by patchew.
mkdir -p ~/src/ cd ~/src/ git clone https://github.com/patchew-project/qemu.git
-
Checkout tag that has Hypervisor.framework patches
cd qemu git checkout patchew/[email protected]
See https://patchew.org/QEMU/[email protected]/ for details.
-
Build QEMU
mkdir build/ cd build/ ../configure --target-list=aarch64-softmmu --enable-cocoa make -j
-
Download pre-build EDK II OVMF EFI image for QEMU.
This EFI image is built from
stable202011
tag with additional resolutions inQemuRamfb.c
.To build it from the source code for adding more resolutions, see the following section.
-
Prepare pflash for non-volatile variable store, such as screen resolution.
mkdir ~/qemu-vm/ cd ~/qemu-vm/ tar xvf ~/Downloads/QEMU_EFI-cb438b9-edk2-stable202011-with-extra-resolutions.tar.gz dd if=/dev/zero of=pflash0.img bs=1m count=64 dd if=/dev/zero of=pflash1.img bs=1m count=64 dd if=QEMU_EFI.fd of=pflash0.img conv=notrunc dd if=QEMU_VARS.fd of=pflash1.img conv=notrunc
- This step is optional, you can use
-bios QEMU_EFI.fd
instead of-drive ...if=pflash
lines in the next step, but in that case, any changes in EFI will not be persistent.
- This step is optional, you can use
-
Download FreeBSD 13.0-BETA1 for ARM64 raw VM image xz-compressed file
-
Decompress xz-compressed file, keeping a copy of the original compressed file
Keeping a copy of the original file is convenient because then you can use it if you want to create additional VMs later. Just be careful not to overwrite the image of your first VM when you want to make a second VM though :P
mv ~/Downloads/FreeBSD-13.0-BETA1-arm64-aarch64.raw.xz . unxz -k ~/Downloads/FreeBSD-13.0-BETA1-arm64-aarch64.raw.xz
-
Run your FreeBSD 13.0-BETA1 for ARM64 VM
~/src/qemu/build/qemu-system-aarch64 \ -M virt,highmem=off \ -accel hvf \ -cpu cortex-a72 \ -smp 4 \ -m 4096 \ -drive file=pflash0.img,format=raw,if=pflash,readonly=on \ -drive file=pflash1.img,format=raw,if=pflash \ -device virtio-gpu-pci \ -display default,show-cursor=on \ -device qemu-xhci \ -device usb-kbd \ -device usb-tablet \ -device intel-hda \ -device hda-duplex \ -drive file=FreeBSD-13.0-BETA1-arm64-aarch64.raw,if=virtio,cache=writethrough \ -nographic \ -serial mon:stdio