macOS on AMD EPYC
I think I should start out with a few disclaimers:
- I work for MacStadium. My salary comes from customers paying for Mac hardware in order to build iOS apps and submitting them to the App Store. I don’t add this because I like my salary, even though I do, but rather because this pretty much violates everything hardware wise in the macOS EULA that one could violate.
- You shouldn’t ever use this for production builds. Apple could add checks to the binaries that you submit and one day they reject your builds.
- There is no support for any of this. If you screw up, you’re on your own so be aware of this.
- “If you don’t endorse this why do it in the first place?” - Well given Apple’s recent stance on hardware I hope for the best but expect absolutely nothing anymore. Especially not a replacement for the Xserve which we badly need. That said I think it’s reasonable for me to checkout what the enemy is capable of. How easy is this? Could this be commercially supported? To what degree? Getting an understanding of what could be gives you perspective about your current offerings.
Great, so now that we have this out of the way I can to tell you that Packet currently has a cool promo going for their partnership with AMD. You can apply for a 250$ credit and test the c2.medium featuring 24 cores (48 threads) of AMDs latest EPYC CPUs. I saw the announcement a while back in Packets newsletter and after not being able to think of something to do with 250$ of free compute I decided to try to run macOS on these machines.
Thanks to KVM and QEMU being incredible pieces of software this endeavour was not hard at all. Having never required a VNC connection from a headless server I wasted most of my time fighting the VNC connection on the server in order to kick off the installation process.
I would say that it is reasonable to say that you could do this at home, pretty much for free in a couple of hours start to finish so I tried to outline it as best as I could for you.
Things you’ll need:
- A Packet account
- Basic understanding of SSH & the Linux command line
- A VNC client (I had many issues and finally ended up using Screens)
- A macOS .iso file to install the OS
If you want to take advantage of the 250$ promo you’ll need to fill out this form for Packet & AMD. The peeps at Packet are all super nice & hard working so there is a chance that you’ll be granted the credit quickly. Once granted, login into your account & create a new server in one of the available locations. As of writing those are AMS1, SJC1, EWR1 & NRT1.
The important bit when selecting the setup is which Linux distribution to use. I highly recommend using Ubuntu 18.04 LTS since it already comes with all the right versions so you wont have to compile QEMU from source or something. I’m not good enough with KVM or QEMU to explain why exactly, but having tried older LTS versions of Ubuntu and other distributions I can tell you that it’s an absolute pain in the ass.
Waiting for your machine to finish being deployed may seem like an eternity compared to deploying a VPS’, but working for a company that offeres dedicated Macs which allow for basically no automation at all I can tell you that waiting 5-8 minutes for dedicated hardware is blazing fast. Have a quick walk, show your dog a little love or go and drink some water. It’s good for you!
Once your machine is up do the usual dance of grabbing your dependencies and updating whatever needs to be updated. You know the deal.
After that’s done run
$ apt install qemu uml-utilities libguestfs-tools git
to install QEMU itself, a few dependencies and git since we need to clone a Github repo. The repo is maintained by Dhiru Kholia but there is no support in any way. Not even an issue tracker. It features a bunch of useful scripts, a ready to go Clover image and lots of very useful information. I recommend starting in the README for High Sierra. It features plenty of information and this post is mostly a rehash of said README.
You can grab the repo with
$ git clone https://github.com/kholia/OSX-KVM.git
cd into the repo and create a new virtual HDD for macOS
$ cd OSX-KVM
$ qemu-img create -f qcow2 mac_hdd.img 120G
Don’t be afraid to change any of the names, you just simply have to keep track of them and change the boot script and the end.
The image file that was created is the recommended file format for KVM
qcow2, though it can handle a lot of different formats, and is 120 GB big which should hold plenty of things like Xcode, your source code and any dependencies necessary to build your app.
As I said before the repo comes with a pre-built Clover bootloader image, also in the
qcow2 file format. It’s resolution is 1024x768 which is absolutely fine for a CI setup. I recommend using the pre-built Clover image and moving on for now.
Once you finished all of the tasks on your AMD EPYC machine you will have to build your macOS .iso on your Mac.
First download the macOS installer .app from the Mac App Store that you’d like to run, in my case High Sierra. The .iso can easily be created by running the
create_install_iso.sh script in the repo.
The output of that shell script should be an .iso file in the range of 5GB which needs to be copied to your AMD EPYC machine with Packet, for example (the colon at the end is required)
$ rsync -P /path/to/install_macOS_High_Sierra_10.13.5.iso email@example.com:OSX-KVM/
After the transfer finished we could boot straight into macOS without any issues, though we need to sightly modify the
boot-macOS-HS.sh script to add the slowest, but easiest to setup networking & remove a few audio devices that give you nothing but trouble, even on a real Mac.
I also set the virtual CPU to
-smp 8, cores=4 & the virtual RAM to
-m 8192 which equals 8GB. The virtual CPU configuration is still a mystery to me but this setup gives you plenty of speed and should allow you to run 5-8 VMs on this AMD EPYC machine (probably more if you’d like to overprovision your machine a little).
Please find the line with
file=./'HighSierra.iso' at the end and replace the HighSierra.iso string with the name to the .iso file that you generated and copied over.
Once that’s done you should be able to boot the VM
I was not able to directly connect to the VM via VNC so I forwarded the port 5900 that I specified in the
boot-macOS-HS.sh script with the trailing
:0 via SSH
$ ssh -L 5900:localhost:5900 firstname.lastname@example.org
After that I only disabled password authentication in Screens and was able to connect to the VM right away.
Below are a few screenshots of the boot & installation process.