If you’re running a Linux distro as your daily driver, you can still other distros and OS’. You can even enjoy macOS. You can run Catalina using the clover bootloader and you can even install macOS in a Docker container.
Today we’re going to take a look at how set up a simple macOS Big Sur VM in QEMU, accelerated by KVM.
THERE’S AN UPDATED TUTORIAL NOW THAT macOS Big Sur is out of beta UPDATED HOW TO: Install macOS Big Sur With OpenCore on Linux
- A modern Linux distribution
- QEMU > 2.11.1
- A CPU with Intel VT-x / AMD SVM support is required
- A CPU with SSE4.1 support is required for >= macOS Sierra
- A CPU with AVX2 support is required for >= macOS Mojave
- Internet access for the installation process
INSTALL QEMU & OTHER REQUIRED PACKAGES
Open the terminal and run:
sudo apt install qemu uml-utilities virt-manager dmg2img git wget libguestfs-tools p7zip
NOTE: Adjust install command and, possibly, packages names according to your distro.
We will need a more packages but they will be installed later, when needed.
INSTALL macOS Big Sur
1. Open terminal and run
git clone https://github.com/kholia/OSX-KVM.git macOS-Big-Sur. When you’re done cloning the git, cd into path with
2. Download macOS Big Sur installer from Apple with
2.1 If you want to download and install macOS High Sierra, Mojave or Catalina, just run
./fetch-macOS.py and choose which installer you want to download.
NOTE: This tutorial was written during macOS Big Sur’s developer beta stages. When Apple will release macOS Big Sur to the public, you’ll more than likely only have to run step 2.1 and skip steps 3-5 . If there will be any major change, this tutorial will be updated.
In the terminal, while in the macOS-Big-Sur folder, run:
/path/to/xar-dir/xar/src/xar -xf InstallAssistant.pkg.
If you’ve installed
xar from AUR, run:
xar -xf InstallAssistant.pkg
To do this run:
mkdir temp && /path/to/darling-dmg-repo/darling-dmg SharedSupport.dmg temp
If you’ve installed the package from the AUR, run:
5. Now that
SharedSupport.dmg is mounted we need to extract
BaseSystem.dmg from it. The file we need is located inside a .zip file, so we’ll use 7zip to extract it. To do that, run:
7z e ./temp/com_apple_MobileAsset_MacSoftwareUpdate/*.zip AssetData/Restore/BaseSystem.dmg
6. Next step will be to convert BaseSystem.dmg to BaseSystem.img, an image that QEMU can work with. To convert the image, run:
dmg2img BaseSystem.dmg BaseSystem.img
7. Create a virtual HDD image where macOS will be installed. Run
qemu-img create -f qcow2 mac_hdd_ng.img 128G
NOTE: You can change the size of the virtual drive. 128 GB is just an example. Also if, for any reason, you want to change the name of the disk image from
mac_hdd.img to something else, you’ll also have to update
OpenCore-BS.sh to point to the new image name.
8. Lets set up and configure a bridge network connection which can be used by the VM can use to connect to the internet. Required for the installation process. To do this, run:
sudo ip tuntap add dev tap0 mode tap sudo ip link set tap0 up promisc on sudo ip link set dev virbr0 up sudo ip link set dev tap0 master virbr0
NOTE: If virbr0 network interface is not present on your system, it may have been deactivated. Try enabling it by using the following commands:
virsh net-start default virsh net-autostart default
9. Now you’re ready to install macOS Big Sur. In theory. Because the script you need to run in order to install macOS comes preconfigured. So, for a basic install and run of macOS Big Sur, you won’t need to edit anything.
However, it comes preconfigured to use only 3GB or RAM. Let’s take care of that. Edit
vim and set it to asign at least 8GB of RAM. More if you can spare it.
Now you can start the installation process. Run
./OpenCore-BS.sh . You’ll be greeted by this screen. Choose
macOS Base System
10. First thing you’ll need to do is run Disk Utility and format your virtual drive.
11. Exit Disk Utility, choose Reinstall macOS and go through the usual installation steps.
12. During the installation process, your virtual machine will restart and will boot back up. When it does, choose macOS Installer to continue the installation.
13. After a loong time of installing, you will eventually be greeted with the welcome screen where you can set up your account and settings.
Don’t expect this to run just like a Mac. It’s a VM afterall. And it will feel sluggish mainly because there’s a lack of hardware acceleration. And this can only be fixed by passing through a graphics card to the VM. To learn how to do that and other tips, check out the official project on Github.