Linux users on Arch or Manjaro attempting to install macOS/OSX in VMWARE, or QEMU/KVM, will greatly benefit from this tutorial.
UPDATED 25 May 2020.
Currently there is an OpenCore boot solution, which is far superior for Arch users. I have added it to the tutorial.
UPCOMING: Dockerfile full auto macOS installer. Will be released May 28th 2020.
This tutorial now covers:
MacOS VM on Arch, Ubuntu, Debian, CentOS, RHEL or Fedora.
Check if your CPU has virtualization. This out of the following command must be greater than 0.
It tells you how many cores can be used in virtualization. You might see 8, 12, 64.
# ALL DISTROS egrep -c '(svm|vmx)' /proc/cpuinfo
If you see 0 when you ran the above command, then boot into your BIOS and turn on “Hardware Virtualization.”
If you see 1, 2, 3 … any number greater than 0 then you can ready!
This tutorial is great for Linux users who want to use XCode 10 or 11 on Linux without Dual Booting!
How to Install macOS VM on Linux
Linux System Requirements:
- about 20-40gb of free space
- Intel VT-x / AMD SVM: in your BIOS turn on “hardware virtualization” or similar
- highly recommend using an SSD
- where you download and run the scripts will determine which drive the OSX image will be created on
ARCH ONLY: an aur package manager, such as yay.
If you don’t have yay (Arch User Repository package manager):
# ARCH LINUX USERS ONLY pacman -S git make automake gcc python go autoconf cmake pkgconf alsa-utils fakeroot --noconfirm git clone https://aur.archlinux.org/yay.git cd yay makepkg -si
Next, we will need git & python as we will need to clone some repositories.
# ARCH LINUX sudo pacman -S git python # UBUNTU DEBIAN sudo apt install git python # CENTOS RHEL FEDORA sudo yum update -y sudo yum install epel-release sudo yum install git python -y
We are going to download the official the MAC iso/dmg file, which is around 6GB downloaded.
Make sure you download the iso in the disk or device that you are going to run the VM from.
A great way to download OSX ISO files is using gibMacOS:
git clone https://github.com/corpnewt/gibMacOS.git cd gibMacOS chmod +x gibMacOS.command ./gibMacOS.command # if this doesn't work python gibMacOS.command python2.7 gibMacOS.command python2 gibMacOS.command
This will run a small Python script that will allow you to download the official Mac iso files from *.apple.com
The version that I run is Mojave 10.14.6.
macOS Mojave 10.14.6 (18G103)
Next, you will need qemu & libvirt for virtualisation and emulation.
Also required during qemu installation:
– dnsmasq for networking
– virt-manager but not required
– bridge-utils for additional networking Requirements
# ARCH LINUX ONLY sudo pacman -S qemu libvirt dnsmasq virt-manager bridge-utils flex bison ebtables edk2-ovmf # UBUNTU DEBIAN sudo apt install qemu qemu-kvm libvirt-clients libvirt-daemon-system bridge-utils virt-manager sudo apt install qemu virt-manager dnsmasq bridge-utils # CENTOS RHEL FEDORA sudo yum install libvirt qemu-kvm -y
Now, enable libvirt and virtlogd
- libvirt is libraries required for virtualisation
- virtlogd is logging of the qemu virtual instances
sudo systemctl enable libvirtd.service sudo systemctl enable virtlogd.service
Additionally, you will require the following packages which are found only in the Arch User Repository.
Most of them are on Github if you want to compile them yourselves.
Installing these will take some time, so one-by-one install these:
# ARCH LINUX ONLY # you may need the following yay uml_utilities # read below if doesn't install yay libguestfs # libguestfs is in arch/comminuty-testing now too yay ebtables yay firewalld sudo firewalld
Update May 2020: ARCH uml_utilities may need to be installed in the following way:
# ARCH ONLY # the current version of uml_utilities may need to be installed in the following way # because the pkgbuild has a tiny error, if it gets fixed, this snippet will still work fine with r yay --getpkgbuild uml_utilities cd uml_utilities perl -i -p -e "s/provides=\(\'\'\)/provides=\(\)/g" PKGBUILD perl -i -p -e "s/conflicts=\(\'\'\)/conflicts=\(\)/g" PKGBUILD makepkg -si
If you are on Debian or Ubuntu
# DEBIAN UBUNTU sudo apt install qemu qemu-kvm libvirt-clients libvirt-daemon-system bridge-utils virt-manager uml-utilities dmg2img wget libguestfs-tools
The following program qt-virt-manager is huge and takes a long time to compile but you might need it:
# yay qt-virt-manager
You should reboot now to apply kernel changes for qemu.
sudo modprobe kvm reboot
After reboot, download the OSX-KVM Repository:
This folder will be referred to as the OSX-KVM folder.
Your macOS disk will be created in the folder we are about to download into.
Make sure you choose a disk with enough space.
git clone https://github.com/kholia/OSX-KVM.git cd OSX-KVM # if you didnt use gibMacOS to download the OSX ISO you can use: # ./fetch-macOS.py
Converting macOS BaseSystem.dmg into Disk Image
In the gibMacOS folder that you downloaded earlier, navigate into:
macOS Downloads > publicrelease, and then the folder of the OSX Version that you downloaded.
Inside the macOS version folder that you downloaded from gibMacOS, we will turn the .dmg into .img
Make sure you have enough disk space here!
Find BaseSystem.dmg inside the gibMacOS downloaded folder. It should be around 500mb.
Convert it to .img:
# do this inside gibMacOS/macOS Downloads/publicrelease/061-26589 - 10.14.6 macOS Mojave/ qemu-img convert BaseSystem.dmg -O raw BaseSystem.img # or do it inside any version auto qemu-img convert gibMacOS/macOS\ Downloads/publicrelease/*/BaseSystem.dmg -O raw BaseSystem.img
Now move the BaseSystem.img that you just created FROM the gibMacOS folder -> TO THE OSX-KVM FOLDER
Decide now how big you want the macOS disk size to be.
I want an 80GB macOS disk size so I run the command below.
Note: do not change “mac_hdd_ng.img” or it will break the scripts later.
qemu-img create -f qcow2 mac_hdd_ng.img 80G
The 80GB empty disk has been created.
The macOS image is ready.
Now, create the network for the OSX VM
If you have successfully installed all the AUR packages above, you should be able to run this:
Run these commands one-by-one:
sudo ip tuntap add dev tap0 mode tap sudo ip link set tap0 up promisc on sleep 1 sudo virsh net-start default sudo virsh net-autostart default sudo ip link set dev virbr0 up sleep 1 sudo ip link set dev tap0 master virbr0
Mac is now ready to boot.
Inside the OSX-KVM folder, run the shell script run-diagnostics.sh
If everything looks okay, you are ready to boot macOS on Arch Linux.
If everything is not okay, leave a comment, I usualy reply within 24 hours. use imgur.com to link to image if you want to post a screenshot
# new shell boot script version! As of May 2020 ./OpenCore-Boot.sh
# old tutorial, may fail ./boot-macOS-NG.sh
Boot and Installation Process
Hint: in QEMU, press Ctrl + Alt + G to gain control of your mouse again.
At the CLOVER Boot Manager screen, select:
Boot macOS Install from macOS Base System
After about a minute, the macOS recovery GUI will appear and you can select your language.
When you reach the macOS Utilities screen, seleck “Disk Utility”
In the top left, select “Show All Devices”. Not required to see the disk we are using, but helpful to visualize what is happening
Select the disk which has 80GB and is “Uninitialized”.
Click on “Erase” and erase the 90GB disk.
Do not change the Format or Scheme.
Erasing the disk here does nothing to your real computer. This is a virtual drive.
Create a new partition for macOS on your QEMU Drive
NOTE: YOU MUST REDUCE THE DISK SIZE BY A SMALL AMOUNT TO BE ABLE TO PRESS APPLY
After you have erased the disk, click “Partition”.
Change 85.6 to 85.5 and you will be able to press apply.
Note: this will NOT steal 80GB straight away from your hard drive: it’s just virtually allocating it from your host machine’s disk.
When that has finished, you can close the “Disk Utility”
Select Reinstall macOS.
Have fun using macOS on Linux with QEMU!
Finsihed installing OSX on Linux in a VM!
BONUS DESKTOP SHORTCUT SCRIPT!
# boot macosx vm sudo systemctl enable libvirtd.service sudo systemctl enable virtlogd.service sudo ip tuntap add dev tap0 mode tap sudo ip link set tap0 up promisc on sleep 1 sudo virsh net-start default sudo virsh net-autostart default sudo ip link set dev virbr0 up sleep 1 sudo ip link set dev tap0 master virbr0 cd /home/user/OSX/OSX-KVM/ && bash ./OpenCore-Boot.sh
Update May 2020 fixes for existing Mac OSX Virtual Machines:
virsh is now included in libvirtd.
Something happened to my tun setup but I documented the fix in this article about TUN/TAP OSX-KVM
You may need to remove the git version of virsh that we are using and use the one from libvirtd:
# remove the existing networks created by the old package # dont worry, these will get created again when you reinstall qemu and libvirt # sudo pacman -R virsh sudo ip link delete virbr0 sudo ip link delete virbr0-nic sudo pacman -S libvirt qemu reboot
It seems we don’t need this command any more because the libvirt package includes virsh.
Remove any virsh commands from your boot scripts (the bonus one above).
# I removed these # sudo virsh net-create default # sudo virsh net-autostart default
qemu-system-x86_64: could not configure /dev/net/tun (tap0): Operation not permitted
command “sudo virsh net-start default” hangs
This error happened when I updated the kernel.
Solved by reinstalling qemu and libvirt:
sudo pacman -R virsh sudo ip link delete virbr0 sudo ip link delete virbr0-nic sudo pacman -S libvirt qemu reboot
Then change the networking mode to Usermode. You can do that by importing the whole thing into virt-manager by using the file named macOS-libvirt-Catalina.xml. Happy to help with any questions you might have!
Increase Screen Resolution on MacOS Virtual Machine QEMU!
– Automatically fixed in the new OpenCore-Boot.sh version
– Try the new OpenCore-Boot version.