Skip to content

Instantly share code, notes, and snippets.

@bretton
Last active September 10, 2023 21:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bretton/33a4a32a0485d42cc015bc50b6889f14 to your computer and use it in GitHub Desktop.
Save bretton/33a4a32a0485d42cc015bc50b6889f14 to your computer and use it in GitHub Desktop.
Virtual machines on Apple M2 chips, with Ventura

Virtual machines on Apple M2 chips, with Ventura

Version

This is version 0.1

Requirements

I want to run VMs with custom networking over a bridge.

I want to use ZFS with applicable operating systems like FreeBSD or Linux.

I want more options than UTM can provide.

Solution

We'll be using qemu and virt-manager to run setup and run virtual machines on Apple M2 devices.

If you are a Linux user, virt-manager may be familiar. It can be used to connect to multiple KVM hosts over qemu+ssh and is essential in environments with Linux servers running VMs with qemu, libvirt and kvm.

Process

Install Xcode command line tools

xcode-select --install

Install Brew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Install qemu, libvirt and virt-manager and related useful tools.

brew install qemu libvirt virt-manager tmux wget jq jo bash

Start the libvirt service

brew services start libvirt

Download some isos

mkdir -p ~/Downloads/ISO
cd ~/Downloads/ISO
wget -c  https://download.freebsd.org/ftp/releases/arm64/aarch64/ISO-IMAGES/13.2/FreeBSD-13.2-RELEASE-arm64-aarch64-disc1.iso
wget -c https://cdimage.ubuntu.com/releases/22.04/release/ubuntu-22.04.3-live-server-arm64.iso
wget -c https://cdn.openbsd.org/pub/OpenBSD/7.3/amd64/install73.iso
wget -c https://cdimage.debian.org/debian-cd/current/arm64/iso-cd/debian-12.1.0-arm64-netinst.iso
wget -c https://dl-cdn.alpinelinux.org/alpine/v3.18/releases/aarch64/alpine-standard-3.18.3-aarch64.iso

Open virt-manager by connecting to local qemu session

virt-manager -c "qemu:///session" --no-fork

(you might want to setup an alias in .zshrc or configure a shell script)

Create a new image. When adding the source ISO, browse to the ~/Downloads/ISO directory.

Pending

  • bridge networking
  • automatic installs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment