
OS X-KVM: Running Mac OS X El Capitan on KVM and QEMU - tambourine_man
https://github.com/kholia/OSX-KVM
======
ShinyCyril
I tried doing this the other day, hoping that I would finally be able to get a
working OSX setup on my desktop (have made several attempts with no success at
getting it working bare-metal on my Z600). Sadly it just ended with more
kernel panics, something I was hoping would be avoided as I got the impression
from some sources that QEMU was a more straightforward solution than trying to
run it on bare-metal.

Having said that, I've been getting more and more frustrated with OSX (had a
great experience with Leopard on a PowerBook G4, and my 2013 MacBook Air is
easily the best laptop I've owned, however personally I don't care for the
direction that they are taking OSX these days), and ended up using it as an
excuse to update to the latest version of elementary OS, which certainly isn't
without its teething problems.

~~~
valarauca1

       Z600
    

That's a bit old. Modern Hackentoshes are actually pretty solid on consumer
hardware. Z79/Z79, Z170 are pretty much fully supported. Some forum posters
claim they've gotten dual 4th Xeon boards to work.

I set one up on my Z79+i7-4790k. It was a breeze. Took about 90minutes
following tutorials. My biggest problems were:

-I set up the wrong sound driver

-Nvidia won't detect/modify hot plugging displays you have to manually edit OSX's version of xorg.conf

-Apple's Nvidia driver didn't support GSync or 144Hz. So I had to dealing with image tearing :\

-Non Apple keyboards had weird character mismatching. Had to purchase an Apple USB keyboard.

I ended up reverting because I like my IBM Model M, and losing hardware level
vsync was a no-go.

~~~
izacus
-Non Apple keyboards had weird character mismatching. Had to purchase an Apple USB keyboard.

Karabiner is useful for this - for pretty much every keyboard layout you have
a tick that remaps it to PC keyboard.

~~~
rgoodwintx
Unfortunately Karabiner is broken on Sierra; they are working on workarounds
though. \-- macOS Sierra support status

Karabiner does not work on macOS Sierra at the moment.

We are developing Karabiner-Elements which provides simple key modification
for macOS Sierra at first. (Karabiner-Elements works on macOS Sierra except
prefernces GUI.) \---
[https://pqrs.org/osx/karabiner/](https://pqrs.org/osx/karabiner/)

------
CyberShadow
This little line, copyrighted by Apple, is what I understand to be the legal
protection they have against people running OS X on non-Apple hardware:

[https://github.com/kholia/OSX-
KVM/blob/476ae8b082088049f2f8c...](https://github.com/kholia/OSX-
KVM/blob/476ae8b082088049f2f8c547518f35b1cf5d0647/macOS-libvirt.xml#L55)

I would not be surprised if a DMCA takedown will be filed against this
repository soon.

More information here:
[http://www.contrib.andrew.cmu.edu/~somlo/OSXKVM/#sec_3_2_1](http://www.contrib.andrew.cmu.edu/~somlo/OSXKVM/#sec_3_2_1)

~~~
kristofferR
I doubt that line ("ourhardworkbythesewordsguardedpleasedontsteal") is
creative enough to meet the threshold of originality required for something to
be protected by copyright.

Even if it actually were copyrightable/trademarked it wouldn't be a valid
legal strategy to prevent fair-use:

[https://en.wikipedia.org/wiki/Sega_v._Accolade](https://en.wikipedia.org/wiki/Sega_v._Accolade)

~~~
CyberShadow
I wouldn't be so sure. That case predates the DMCA - see also the AACS
encryption key controversy.

------
ethanpil
The OSX license agreement severely limits the practicality of this:
[http://images.apple.com/legal/sla/docs/macOS1012.pdf](http://images.apple.com/legal/sla/docs/macOS1012.pdf)

It only allows you:

Section 2B(iii): "to install, use and run up to two (2) additional copies or
instances of the Apple Software within virtual operating system environments
on each Mac Computer you own or control that is already running the Apple
Software, for purposes of: (a) software development; (b) testing during
software development; (c) using macOS Server; or (d) personal, non-commercial
use.

The grant set forth in Section 2B(iii) above does not permit you to use the
virtualized copies or instances of the Apple Software in connection with
service bureau, time-sharing, terminal sharing or other similar types of
services."

~~~
Stratoscope
The part of that EULA section that really gives me trouble is "...that is
already running the Apple Software...".

I want to run OSX in a VM _on my MacBook Pro_ with Windows as the host OS. I
used to do it the other way around, boot into OSX and run Windows in a
Parallels VM. These days most of my work is in Windows, especially VR work, so
it's more practical to boot into Windows. (And I like Windows better than OSX
anyway.)

But I still do need to test on OSX occasionally. In an ideal world, since I
have VMware installed on Windows, I could just boot up an OSX VM.

But because of that one EULA phrase, OSX will never be supported by a
commercial vendor like VMware or a large open source product like VirtualBox -
even on Mac hardware!

This leaves booting back to OSX as the only way to run it, and rebooting back
and forth is a real pain.

All I want to do is run my legally licensed Windows and legally licensed OSX,
and have it be my own choice which one to run as the host OS.

~~~
kristofferR
It's pretty easy to solve that issue by applying a community made fix:
[http://www.insanelymac.com/forum/files/file/339-unlocker/](http://www.insanelymac.com/forum/files/file/339-unlocker/)

~~~
y4mi
he'll still be in violation of the EULA though...

~~~
Stratoscope
I'm not too worried about that. I doubt if Apple will get on my case for
running OSX on my MacBook Pro!

------
sgt
That is pretty impressive. I spent hours upon hours getting OS X to run on a
Linux host in KVM and QEMU. Eventually I did get it to work, but things like
Messages.app had no chance of working. That was actually my goal - to create
my own little Messages API so that I could send automated messages to myself.
I ended up just scripting Messages.app on a real Mac and that works really
well, even 2 years after. I remote control my house that way.

~~~
mattwg
> I ended up just scripting Messages.app on a real Mac and that works really
> well, even 2 years after. I remote control my house that way.

That sounds pretty neat, do you have more details written down anywhere?

~~~
sgt
I've installed an AppleScript handler from within Messages.app. The script
below is called ReceiveMessage.script and is located in ~/Library/Application
Scripts/com.apple.iChat and basically accepts messages. That's how I handle
inbound messages, and for outbound I basically also have a separate script for
sending out messages. I do the actual work in separate python scripts called
by the shell scripts though.

\-- snip snip --

using terms from application "Messages" on message received theText from
theBuddy for theChat set quoted_message to quoted form of theText set
quoted_id to quoted form of (id of theBuddy as text) do shell script "echo " &
quoted_message & " | ~/bin/MessageReceive.sh " & quoted_id & " > /dev/null
2>&1 &"

    
    
            # make messages happy
            return true
        end message received
    
        on message sent theMessage for theChat
    
        end message sent
    
        on active chat message received
    
        end active chat message received
    
        on chat room message received theMessage from theBuddy for theChat
    
        end chat room message received
    
        on addressed chat room message received theMessage from theBuddy for theChat
    
        end addressed chat room message received
    
        on addressed message received theMessage from theBuddy for theChat
    
        end addressed message received
    
        on av chat started
    
        end av chat started
    
        on av chat ended
    
        end av chat ended
    
        on login finished for theService
    
        end login finished
    
        on logout finished for theService
    
        end logout finished
    
        on buddy became available theBuddy
    
        end buddy became available
    
        on buddy became unavailable theBuddy
    
        end buddy became unavailable
    
        on completed file transfer
    
        end completed file transfer

end using terms from

~~~
DigitalJack
I like the project, but I really don't like applescript. In programming
languages, it seems there is a tension between easy-to-write and easy-to-read.
And I suppose a fork in the continuum with easy-to-read-for-novices and easy-
to-read-for-programmers.

applescript went overboard on the easy-to-read-for-novices at severe cost to
easy-to-write.

~~~
pmarreck
What's hard to read about it? Obviously (to me), those are all event handlers.
Not sure why (or if?) you have to define the ones that don't actually do
anything, though.

~~~
saghm
I'm pretty sure he's saying that they made it _too_ easy to read, at the
expense of being easy to write (with the premise that these are opposite ends
of a spectrum stated above)

------
davb
Keep in mind that if you're using the boot.sh method, the NIC's MAC seems to
be hardcoded in the script [1]. You might want to change that.

[1] [https://github.com/kholia/OSX-
KVM/blob/476ae8b082088049f2f8c...](https://github.com/kholia/OSX-
KVM/blob/476ae8b082088049f2f8c547518f35b1cf5d0647/boot.sh#L29)

------
conradev
I compiled a document the other day with a lot of links on the subject of
macOS virtualization, for anyone interested:

[https://docs.google.com/document/d/1VwLJqgc2VkD-
EZnMzSFmZRq0...](https://docs.google.com/document/d/1VwLJqgc2VkD-
EZnMzSFmZRq0YjZPCS18uPr94KsOByY/edit)

------
thrillgore
This is really cool. Someone fork this locally before Apple sends their
takedown notice.

~~~
Kadin
You don't really need to do anything besides a normal `git clone`; any clone
is as good as any other, really.

If the project disappears from Github someone would need to find a different
place to host collaborative development, though. Maybe there needs to be some
sort of Github-alternative in a friendly jurisdiction for projects that are
too controversial to host on a mainstream provider in the US? E.g. for DMCA-
violating projects, video codecs, DRM removal tools, etc.? I'm not that
familiar with the alternatives but it wouldn't surprise me if there are better
options in terms of resistance to US court orders.

------
g0atbutt
Does this support 3D hardware acceleration? That seems to be a common problem
for these types of setups.

~~~
ShinyCyril
Hardware acceleration can be done using PCI passthrough to pass your graphics
card on to the guest OS. IOMMU and VFIO are two terms I commonly see
associated with this, but having never done it myself I am not sure what the
difference between them is - perhaps someone can chime in?

~~~
virtuallynathan
VT-d = Virtualization Technology for Directed I/O which basically means the
CPU has an IOMMU, the IOMMU is a piece of hardware for doing PCIe DMA re-
mapping to provide VM isolation. VFIO is the linux driver for passing through
IOMMU devices.

------
Keyframe
Is it possible to run several OS' on a single machine with fast switching
between them, access to all hardware, and at full or almost full speed?

~~~
stuaxo
Using Vmware, and passthrough for the videocard you can achieve this with
Linux as the host and Windows as the guest.

Not sure if it's possible with OSX.

What we really need are video drivers for OSX, for virtualbox and/or other
virtualisation solutons, so OSX as a guest can work really well.

~~~
aruggirello
VGA passthrough is also possible with KVM. I wonder if Oracle has any plans to
add it to VirtualBox? It seems they have made room for KVM support, so in
theory they could.

I have seen all OSX versions from Leopard to El Capitan successfully running
as a VB guest, but the graphics support has always been bad, since there are
no Guest Additions for OSX (BTW this also means no bidirectional clipboard,
drag & drop of files, etc..)

~~~
mastax
There's some support:

[https://www.virtualbox.org/manual/ch09.html#pcipassthrough](https://www.virtualbox.org/manual/ch09.html#pcipassthrough)

------
hobarrera
Does anyone know how to get the ISO image, or the installer via the recovery
boot (cmd+r)?

I'm having a really hard time running the Apple App Store _BEFORE_ I install
the OS. There's kind of a circular dependency there.

------
dbm5
Very cool; currently the bash script assumes the old "OS X" naming convention
of the installation app. To make it work with "macOS" Sierra, some simple
changes are required.

------
jameshclrk
This will probably be taken down soom, mainly because of the link to the El
Capitan ISO

