Virtual Mac/OSX using QEMU

I wanted to experiment with creating a virtual Mac, running OSX, on my Debian system running on AMD hardware.

Note: this violates the OSX licence conditions. The best solution is to buy a second-hand Mac instead. However, here are some notes from my experimentation.


Vagrant includes several pre-built Mac OSX boxes. However, they are designed to run on VMs running on Mac hardware under OSX. None of them seemed to work for me on a non-Mac system.


I don't believe that Virtualbox can be used (with or without Vagrant).

It, apparently, does work on (some?) Intel systems (with some OSX versions) but does not work on systems which do not support all the necessary instructions (such as SSE3). It is not clear that it works on AMD even if they do have the necessary instructions.

So, I started to look for QEMU/KVM solutions.

Vagrant with libvirt

vagrant-libvirt is a useful tool for running Vagrant boxes under QEMU/kvm. However, it does not seem to expose enough QEMU options to get this working.


In the end, the option which worked for me to create an OSX VM running El Capitan was to combine several things:

  1. waschbenzin's post on InsanelyMac on how to combine OVMF (BIOS) and Clover (boot manager) in QEMU.
  2. The disk image from the Vagrant carbon/osx-elcapitan-10.11 box, converted to a format usable with QEMU.
  3. Many other articles, particularly on how to get this to work with AMD hardware.

Many thanks to everyone who has helped.

The end result is a short shell script which starts up QEMU to run the Mac VM:

echo 1 > /sys/module/kvm/parameters/ignore_msrs

if [ "$1" != "" ] ; then disk="$1" ; fi
if [ "$2" != "" ] ; then format="$2" ; fi

qemu-system-x86_64 \
-m 2048 \
-enable-kvm \
-cpu core2duo,vendor=GenuineIntel \
-M q35 \
-smp 2 \
-bios OVMF-pure-efi.fd \
-device ahci,id=hdbus,bus=pcie.0 \
-device ide-drive,bus=hdbus.0,drive=Clover \
-drive id=Clover,if=none,file=clover-debug-test.dd,format=raw  \
-device ide-drive,bus=hdbus.1,drive=MacOSX \
-drive id=MacOSX,if=none,file=$disk,format=$format  \
-device isa-applesmc,osk="theAppleSMCstring" \
-usb -device usb-kbd -device usb-mouse \
-netdev user,id=usr0,smb=$PWD,hostfwd=::2222-:22 \
-device e1000-82545em,netdev=usr0,id=vnet0,bus=pcie.0,addr=5 \
-serial stdio
Graham Cobb