FreeBSD on Apple Silicon
-
Install qemu and curl with homebrew:
brew install qemu curl -
Write a script to download and install FreeBSD:
#!/bin/sh - # # dependencies: curl VER="15.0" TMPF=$(mktemp) || exit 1 trap "rm -f $TMPF" EXIT curl -C - -O https://download.freebsd.org/releases/arm64/aarch64/ISO-IMAGES/$VER/FreeBSD-$VER-RELEASE-arm64-aarch64-mini-memstick.img curl -o $TMPF https://download.freebsd.org/releases/arm64/aarch64/ISO-IMAGES/$VER/CHECKSUM.SHA512-FreeBSD-$VER-RELEASE-arm64-aarch64 pass=`shasum -c --ignore-missing $TMPF | awk '{ print $2 }'` if [[ $pass == "OK" ]]; then qemu-img create -f qcow2 fbsd_aarch64.qcow2 16G fi qemu-system-aarch64 \ -M virt \ -cpu host \ -accel hvf \ -smp 4 \ -m 4G \ -nographic \ -serial mon:stdio \ -bios /opt/homebrew/share/qemu/edk2-aarch64-code.fd \ -drive file=FreeBSD-$VER-RELEASE-arm64-aarch64-mini-memstick.img,format=raw,if=virtio,cache=writethrough \ -drive file=fbsd_aarch64.qcow2,format=qcow2,if=virtio \ -netdev user,id=mynet0,hostfwd=tcp::9022-:22 -device virtio-net,netdev=mynet0 \ rm $TMPF FreeBSD-$VER-RELEASE-arm64-aarch64-mini-memstick.img -
Execute the script and when the installation is done, shutdown the Virtual Machine.
-
Create a script to start the VM:
#!/bin/sh - # # ssh connection via port 7922 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=fbsd_aarch64.qcow2,format=qcow2,if=virtio \ -netdev user,id=mynet0,hostfwd=tcp::7922-:22 -device virtio-net,netdev=mynet0 -
Once started, connect with ssh:
ssh -p 7922 username@127.0.0.1
Write a comment