How to Run OSX on Gnome Boxes (KVM)

Install:

First, create an empty hard drive image:

qemu-img create -f qcow2 OSX.img 64G

Copy the BIOS enoch_rev2848_boot on the same folder where you created the HD.

Change QEMU parameters adding the OSK key on “-device isa-applesmc,osk=”add your osk1 and osk2” (The AppleSMC device needs a valid OSK key to function).
Change also the path of MacHDD and MacDVD.

Install OSX running QEMU:

qemu-system-x86_64 -enable-kvm -m 8192 -cpu Penryn,vendor=GenuineIntel \
-machine pc-q35-2.4 \
-smp 4,cores=2 \
-usb -device usb-kbd -device usb-mouse \
-device isa-applesmc,osk="add your osk1 and osk2" \
-kernel ./enoch_rev2848_boot \
-smbios type=2 \
-device ide-drive,bus=ide.2,drive=MacHDD \
-drive id=MacHDD,if=none,file=./OSX.img \
-monitor stdio \
-device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,vgamem_mb=16 \
-spice port=5930,disable-ticketing
-device ide-drive,bus=ide.0,drive=MacDVD \
-drive id=MacDVD,if=none,snapshot=on,file=./'MacOSX_Mavericks.iso'

Warning: Mouse is not working fine. Be patient, we will install the driver at the end!

When you have the OSX installed and running, create the libvirt xml file called OSX.xml. Remember again to change path and OSK string.

<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
  <name>OSX</name>
  <title>OSX</title>
  <description># echo 1 &gt; /sys/module/kvm/parameters/ignore_msrs</description>
  <memory unit='KiB'>4194304</memory>
  <currentMemory unit='KiB'>4194304</currentMemory>
  <vcpu placement='static'>2</vcpu>
  <os>
    <type arch='x86_64' machine='pc-q35-2.4'>hvm</type>
    <kernel>/home/public/VMs/OSX/enoch_rev2848_boot</kernel>
  </os>
  <features>
    <acpi/>
    <kvm>
      <hidden state='on'/>
    </kvm>
  </features>
  <cpu mode='custom' match='exact'>
    <model fallback='allow'>Penryn</model>
  </cpu>
  <devices>
    <emulator>/usr/bin/qemu-system-x86_64</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='home/public/VMs/OSX/OSX.img'/>
      <target dev='sda' bus='sata'/>
      <boot order='1'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
    <interface type='bridge'>
      <source bridge='virbr0'/>
      <target dev='tap0'/>
      <model type='e1000-82545em'/>
<address type='pci' domain='0x0000' bus='0x02' slot='0x02' function='0x0'/>
    </interface>
    <input type='mouse' bus='usb'/>
    <input type='keyboard' bus='usb'/>
    <graphics type='spice' autoport='yes' listen='127.0.0.1'>
      		<listen type='address' address='127.0.0.1'/>
      <clipboard copypaste='yes'/>
    </graphics>
    <sound model='ich6'>
<address type='pci' domain='0x0000' bus='0x02' slot='0x03' function='0x0'/>
    </sound>
    <video>
      <model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='1'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>
    <memballoon model='none'/>
  </devices>
  <qemu:commandline>
    <qemu:arg value='-device'/>
    <qemu:arg value='isa-applesmc,osk=add your OSK1 and OSK2'/>
    <qemu:arg value='-smbios'/>
    <qemu:arg value='type=2'/>
    <qemu:arg value='-k'/>
    <qemu:arg value='en-us'/>
    <qemu:arg value='-cpu'/>
    <qemu:arg value='Penryn,vendor=GenuineIntel'/>
  </qemu:commandline>
</domain>

Import VM to Gnome Boxes:

virsh create OSX.xml

Configure:

You can now run your OSX from Gnome Boxes and install QemuUSBTablet for mouse and VoodooHDA for audio.

After installed QemuUSBTablet, change VM setting like this:

    <input type='tablet' bus='usb'/>

 

Inside the VM create a file named org.chameleon.boot.plist with the chameleon conf.:

sudo pico /Extra/org.chameleon.boot.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Timeout</key>
<string>5</string>
<key>Graphics Mode</key>
<string>1280x1024x32</string>
<key>EthernetBuiltIn</key>
<string>Yes</string>
<key>PCIRootUID</key>
<string>1</string>
</dict>

If APP store is not working and you are able to browse on internet, probably the reason is that your ethernet device is not called “en0”.

Delete all network devices you have:

OSX_NetworkPanel

then delete these files:

cd /Library/Preferences/SystemConfiguration/
sudo rm preferences.plist
sudo rm NetworkInterfaces.plist

reboot and check if your ethernet device is now “en0”:

OSX_ifconfig

Via: https://github.com/kholia/OSX-KVM
https://www.contrib.andrew.cmu.edu/~somlo/OSXKVM/
https://blog.ostanin.org/2014/02/11/playing-with-mac-os-x-on-kvm/

Advertisements

2 thoughts on “How to Run OSX on Gnome Boxes (KVM)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s