
Osx-kvm: Run macOS on QEMU/KVM - axiomdata316
https://github.com/kholia/OSX-KVM
======
matthew-wegner
I've been running my macOS desktop in an ESXi VM for over a year now. I came
from a hackintosh, but got tired of the fragility of some upgrades. Some notes
on this setup:

\- Apple supports macOS running inside of ESXi. Officially, only on Apple host
hardware (i.e. a Mac Pro, which is on the ESXi compatibility list). Apple even
ships a VMXNet3 network driver in macOS.

\- For ESXi specifically, you have to patch the host to boot macOS on non-
Apple hardware. There's an explicit "am I running on Apple hardware?" check in
there. DrDonk's unlocker on GitHub is what you need.

\- You can specify board-id, ROM/MLB, etc values via your .vmx file. iMessage
and everything work for me, but I'm also using identifiers from a real Mac
Mini I retired a few years ago. I expect this will still work okay with
generated data if you follow hackintosh guides.

\- I pass through a GPU and a USB controller card for input/output. For USB,
find an FL1100 chipset card, like the Inateck models, which works out of box
on macOS, Windows, etc. Recently I moved my boot drive to a passed-through
NVMe for extra speed. My other drives are ESXi virtual drives backed by
storage elsewhere on my network.

\- Most NVIDIA GPUs will need the NVIDIA Web Drivers to work. Kepler
generation cards are the last to work out of box, and the only to currently
work out of box on Mojave. If you don't need hefty performance, a GeForce GT
730 is a cheap card. Apple and NVIDIA are still not getting along, so I expect
this will only get worse.

\- However, I've never been able to get an AMD card to initialize via
passthrough. The PCI device is seen, but the EFI strings or whatever else
Apple is using to determine initialization paths are wrong. I recently spent
awhile trying to figure this out, going so far as to write my own SSDT tables
for the device, but finally gave up.

\- This particular guide is using Chameleon, which is considered an outdated
bootloader. Clover is far more flexible, and will work in VM setups that don't
natively implement SMC like ESXi. (For the longest time Clover would crash an
ESXi VM, but this now works as of a month or two ago).

And finally, on the context of this whole thing--I switched from a real Mac
Pro to a hackintosh years and years ago, when it became clear Apple didn't
care about upgrading the hardware. They still don't. The last Mac Pro release
was 2013 (the 2013 iPhone was a 5S!). They've been promising things will
improve "soon". They're the world's most valuable company; if they actually
cared, at the organizational DNA level, it would have happened by now.

~~~
supernes
Can you please elaborate on your GPU passthrough setup? I was under the
impression that NVIDIA have explicit checks to see if you're trying to
virtualize a consumer brand GPU and throw an error in that case.

I have a PC with a GTX 970 that I wanted to try a similar install on,
unfortunately the i5-3570K in there doesn't support VT-d from what I can tell.

~~~
dperfect
From my experience with a GTX 950 and a GTX 1060, the macOS Web Driver from
NVIDIA doesn't seem to care about virtualization, and it works fine (assuming
the drivers and passthrough are configured correctly).

Windows is a different story, and I had to use a patched vBIOS[1] to get my
1060 working without Windows 10 throwing the dreaded "Code 43" error (when it
detects virtualization and refuses to work). In my case, the CPUID workaround
mentioned in another comment didn't help.

As for VT-d, I believe the unlocked "K" processors from Intel all have VT-d
disabled for some reason.

[1] [https://github.com/Matoking/NVIDIA-vBIOS-VFIO-
Patcher](https://github.com/Matoking/NVIDIA-vBIOS-VFIO-Patcher)

~~~
SXX
> As for VT-d, I believe the unlocked "K" processors from Intel all have VT-d
> disabled for some reason.

This was only the case up to Haswell CPUs. They stopped crippling IOMMU
capabilities since Haswell Refresh (i7-4790K).

------
bodhibyte
More discussion on Hackintosh VMs at
[https://www.reddit.com/r/hackintosh/](https://www.reddit.com/r/hackintosh/),
just search for KVM, ESX, or Proxmox.

For any one interested in using the Ryzen Threadripper for a Hackintosh VM,
see
[https://www.reddit.com/r/hackintosh/comments/8knz91/threadri...](https://www.reddit.com/r/hackintosh/comments/8knz91/threadripper_1950x_vega_64_kvm_success_one_issue/)

------
miduil
OSX-KVM has been super helpful for recovering old sparseimage-backups I've
created back when I was still using a mac. This is because sparsebundlefs-fuse
Linux driver doesn't work with this file-format (yet) and I don't have any
access to a Mac. (Especially since recovering takes at least a dozen hours).

[https://github.com/torarnv/sparsebundlefs/issues/7#issuecomm...](https://github.com/torarnv/sparsebundlefs/issues/7#issuecomment-326625187)

------
x3sphere
I've been running a macOS VM on my Threadripper 1950X for awhile now. Passing
through 8 cores with a GTX 1060 attached and it runs great. In the latest
Ubuntu 18.04 LTS, no need to compile qemu from source either, the version from
apt get works just fine.

------
arendtio
Previous post from 2016 with 89 comments:

[https://news.ycombinator.com/item?id=12556609](https://news.ycombinator.com/item?id=12556609)

~~~
loxias
Yeah, one has been able to do this for some time now.

A few years ago I had a setup where (and I admit much of this was for the
aesthetic purity of it, not practical reasons), I used a legally purchased
copy of macos, copied it unmodified to my VM server, and, with a decent amount
of effort, and a patched qemu (for the SMC thingie -- i donno if by now the
patch is in mainline), was enjoying a non pirated, non modified macos on a
linux host.

I even got USB and BLE passthrough working, so I could use the mac VM for iOS
app development.

It was quite effective.

A more challenging project I did later (which I probably deserve some derision
for not documenting and sharing) is "How to develop, sign, and upload iOS apps
entirely from debian linux, entirely with F/OSS, no VM, no Xcode, just good
ol' emacs and cmake". IIRC, there were very little Big Contributions I did,
but plenty of assembling a large variety of other projects, bug fixing them,
and making an integrated environment.

~~~
mseidl
I really want this. I'm a hardcore linux guy(23+ years), but I have to run a
windows vm for some instruments I have that wont run under wine. I hate
windows. It sucks so much. Even just using it not that often with my
instruments reminds me why I stopped using it.

~~~
titanix2
I really want this. I'm a hardcore windows guy(23+ years), but I have to run a
linux vm for some programs I have that wont run under WSL. I hate linux. It
sucks so much. Even just using it not that often with my programs reminds me
why I stopped using it.

~~~
loxias
I.... think I get the jokes guys, but you do know that I have no idea what
part you're referring to.... >.<

And if you'd tell me... maybe I'd help.... :P :)

------
whyagaindavid
for Virtualbox please see [https://github.com/geerlingguy/macos-virtualbox-
vm](https://github.com/geerlingguy/macos-virtualbox-vm)

~~~
geerlingguy
(Note that I'll hopefully have the High Sierra support PR merged in soon.)

------
the_grue
How does it compare to running a Hackintosh? Is it much easier to set up? Do
you still need to have compatible hardware and to mess with drivers and system
configuration? How easy are OS upgrades? How is the performance, including
graphics? Any issues?

~~~
rograndom
Someone posted a few months ago a story where they were using something
similar to this (couldn't find the actual comment, sorry) where they had a HD
with a very bare linux install on it that had enough drivers on it to boot on
most any modern machine, load up qemu and boot a OSX image.

It was basically a "portable" hackintosh that could be moved between most any
desktop machine.

I thought it was a cool idea, and tried to get it working with this repo, but
didn't have much luck even with a full load distro (Ubuntu) on a Dell i5 with
a nVidia GPU I had sitting around.

~~~
kstenerud
Might have been my setup: [https://github.com/kstenerud/virtual-
builders/tree/master/ma...](https://github.com/kstenerud/virtual-
builders/tree/master/machine-builders/macos)

I haven't integrated GPU passthrough yet, though.

------
lathiat
I had various success with this repository, unfortunately the various XMLs for
libvirt and the "sh" boot scripts all reference different paths and
capitalizations of files (e.g. even for the firmware committed to the
repository etc).

However I did get it to work successfully with High Sierra at one point.

~~~
loxias
Yeah, when I got mine working I decided to just go from scratch.... you might
even be able to use upstream qemu by now.

------
fredch
Will someone please update this with experiences with Ryzen?

~~~
johnt15
It works fine on OSX 10.12.6. You need the following customizations (not sure
what's in OSX-KVM already):

\- tell explicitly it's a "Penryl" CPU (<model
fallback='allow'>Penryl</model>)

\- force AES instructions in order to use encryption effectively (<feature
policy='require' name='aes'/>)

\- explicitly define topology (<topology sockets='1' cores='8' threads='2'/>)

\- use usb-tablet (<input type='tablet' bus='usb'/>) for much more convenient
mouse input that does not lock to window. Initial setup may need to be done
with usb mouse (<input type='mouse' bus='usb'/>)

All of the above need to be reflected in QEMU command line.

I've been using this setup for last half year without issues (mostly heavy
compiling).

I'm looking forward porting this setup to 32-core Threadripper. Would be a
hell of a beast that outperforms Apple HW that costs several times more.

------
omnimus
So is there any compatible laptop that will allow QEMU/KVM particulary witwith
gpu passthrough? Is someone running something like that?

~~~
equalunique
Theoretically you could run Linux headless on a Dell Latitude laptop,
configure it to use the Dock's serial output for the main console, and then
have it automatically boot the OS X VM with GPU pass through to the main
screen. When you close the lid, Linux goes to sleep instead of OS X. You could
disconnect it from the dock and just carry it around with you like a normal OS
X machine. Open it up and OS X is there waiting for you. Connect it back to
the dock and debug with another computer over serial and/or SSH whenever you
need to troubleshoot.

~~~
SXX
> and then have it automatically boot the OS X VM with GPU pass through to the
> main screen

What GPU would that be? If it's integrated Intel there is very good chance
it's wouldn't work. Last time I tried to get my Intel HD working in macOS VM
attempt failed completely. As guys from Intel explained somewhere on mail list
their Mac driver stack is quite different from what is there on Linux and
Windows. This is why they for instance don't support their graphics
virtualization (GVT-g) for macOS.

And for mobile GPU like Nvidia / AMD there own set of problems why they don't
work at all in VM.

------
twodayslate
Since everyone seems to be able to run macOS virtualized how come there aren't
any cheap VPS that run macOS available?

~~~
gnahckire
There are, just not cheap compared to running something else.

~~~
twodayslate
Do you have some examples? I am not aware of any.

~~~
bdcravens
[https://www.hostmyapple.com/macvps.html](https://www.hostmyapple.com/macvps.html)

I just Googled "mac os vps"

------
busterarm
The last time I virtualized macOS, I had to find and use some arcane compiler
flags to get homebrew or any builds to work.

------
thcleaner
I have a i5 6500 running with this setup, but memory operations seems to be
very limited in bandwidth and latency

------
thcleaner
I have a setup running OSX via QEMU/KVM using this guide. But memory
operations seems to be very limited.

~~~
aasasd
Limited as in slow?

~~~
thcleaner
yes

------
tambourine_man
How is graphic acceleration support these days? Does PCI passthrough work?

~~~
ubercow13
Yes, it is working for me with a nVidia card

~~~
tambourine_man
Have you tried Adobe's Suite? Any glitches in Photoshop, specifically?

~~~
pizza234
On systems with a good support, it works great - it's transparent to the
guest. I've been using it for around a couple of years, both with videogames
and Lightroom.

~~~
tambourine_man
Thanks. That's enticing

------
ianmunoz
Isn't this illegal? Aren't you only allowed to run OSX on Apple hardware?

~~~
bdcravens
It violates the EULA, but that's not necessarily the same as being illegal.

~~~
loxias
THIS. ^^

------
fenollp
Soooo any way this can help run OS X in docker?

~~~
loxias
I googled <<osx docker>> and this was the 5th entry:

[https://github.com/Cleafy/sxkdvm](https://github.com/Cleafy/sxkdvm)

Though maybe you can enlighten me -- why the heck would you want to? It's in a
VM -- you already have fantastic isolation. Why clutter it with an extra layer
of packaging that to my naive eyes adds no more value?

Like, a _cool_ hack might be running macos...._slowly_.... on a SBC like a
raspi :D But when you have real virtualization, what's the use of docker?
(honest question)

~~~
peterkelly
Docker uses a single Linux kernel for all containers. Docker containers are
much lighter weight than VMs, since each VM must run a full kernel instance.

~~~
loxias
Yes, that's what I said. (although in a comment below this one. ;))

A container is much lighter weight than a VM, yes. (and so is a chroot)

But the MacOS userspace isn't running on the linux kernel, it's running on
darwin. So, macos-in-docker would be an entire qemu installation in docker,
with a macos image inside that.

EDIT: Ahhh, because it doesn't make sense to run a full operating system in a
container, only a single program, I'm guessing that what OP really wants is
some way to dockerize a specific (or several) macos apps. To do so, you'd need
a way to wrap the linux kernel do it can provide a darwin like api, as well as
the same for any required libraries.

OP: You may find this project interesting: [https://www.darlinghq.org/project-
status/](https://www.darlinghq.org/project-status/)

They made a MacOS to Linux translation (not virtualization) layer of
sufficient quality that you an run a decent amount of (text only) native
binaries.

------
NamPNQ
Where I find the ISO file?

~~~
loxias
If you wanna be above board, I think you purchase a mac, and then on that mac
run the apple app store, and then in that store buy a copy of macos.

To my great surprise I found this on Amazon, and I'm curious about what others
think is how apple hasn't demanded its removal:
[https://www.amazon.com/10-13-High-Sierra-Full-
Install/dp/B07...](https://www.amazon.com/10-13-High-Sierra-Full-
Install/dp/B07D3CYGW9/)

------
exabrial
Le sigh, continuous integration of osx and iOS apps is near impossible using
standard cloud providers. I would gladly take an osx geared towards the data
center.

~~~
meddlepal
In theory this should be possible on Google Cloud using nested virtualization
or EC2 bare metal...

~~~
loxias
If you find me funding, I could give you CI for mobile app development, a
decent MVP, in 3 months (which is me taking how long i think it takes and
multiplying by 3) :P

But, like a previous poster said, it _WOULD_ be in violation of Apple's ToS.
So a legal budget would be required.

~~~
meddlepal
We actually need something like this internally for non mobile app reasons. We
build telepresence.io at Datawire and macOS dev and testing is a huge pain.
Interested in a job :) ?

~~~
loxias
uhhh... actually, yes, can you email me (it's on my profile) or tell me your
email? please?

~~~
meddlepal
Sure I'll send you an email in the morning :)

