A new macOS release is nearing release, and it's a big one. So big that this time it's really, completely and definitely not OS X any longer. With the death of Kexts looming and the transition away from Intel CPUs spelling disaster for Hackintoshers and multi-OS users alike, it's certainly an interesting time.

Oh, and rounded edges. So many rounded edges. Good golly.

Today I'd like to walk you through how to get Big Sur installed and up and running in a virtual machine on your Ubuntu or similar host machine. In this article I'll focus on steps and commands that are tailored towards Ubuntu 20.04, but I'm sure you'll be able to tweak things a bit to tailor towards whatever flavor you're running to get things to work similarly.

Let's get to it.

As of this writing, Big Sur Beta 3 is the recent-most beta release. While the guide should remain useful for all subsequent releases as-well as the eventual full release, the fetch-macOS script currently has a hard-coded ID set for Big Sur betas. This will need to be updated whenever a new beta release is out. I'll try to keep the script updated with the correct ID as best I can (if the main repo doesn't have it already, of course), but do keep this in mind.

Prerequisites

In this guide I'll assume you have already set up your host machine, including having set up QEMU, virt-manager, etc. As mentioned before, I'm focussing this guide on running Ubuntu 20.04 as the host OS.

No physical Mac needed

You do not need a physical Mac to download anything necessary to create this VM. We'll be using a few tools to fetch and extract the installer files needed right from your host machine.

Python

Be sure to have Python installed. In my case I already had Python installed but I needed to install an extra package called python-is-python2 to get certain tools to work, but you might also want to make sure python2 is actually installed.

Build tools

We'll be building a few tools from source, so we'll need build tools installed for that. To be honest I already had most of these installed, so I am probably going to miss one or two in this list. If one of the build steps later on this guide fails, it'll tell you what's missing so you can install it at that point. Please let me know if I did actually miss anything here.

sudo apt install cmake clang libfuse-dev libbz2-dev libudev-dev linux-headers-generic pkg-config zlib1g-dev libicu-dev openssl

Other utilities

Also be sure to install these tools if you don't have them already:

sudo apt install dmg2img p7zip
What's happening: We'll need dmg2img to convert an image file, and while 7zip is optional, it's a great compression and decompression tool that I highly recommend you keep around as it's super convenient.

Check out the OSX-KVM repo

Both literally and figuratively. Most of the work has been done by the amazing people who have created and keep this repository up-to-date. There's a few minor tweaks we'll make to get Beta 3 to work, which at the time of this writing isn't yet working out of the box when relying on the original repo (I have submitted a PR for this). Hopefully this'll get added soon, but for now you can head over to my fork where I've already applied the fix needed to get Beta 3 to download.

Go ahead and download the repo to your local machine.

Download the Big Sur installer file

Open up a Terminal and from the OSX-KVM repo you have just downloaded, and run:

./fetch-macOS.py --big-sur

If you've downloaded from my fork (or if my pull request has been merged in the main repo) you should see a bunch of things fly by and the tool will start downloading a relatively humongous InstallAssistant.pkg file, clocking in at 12GB.

While this is downloading, let's set up a few additional things we'll need once the download is done.

Download & build XAR

Download the XAR repository here, and open another Terminal window/tab and head over to where you have downloaded this repository. Inside, run the following:

cd xar && ./autogen.sh && make
What's happening: We head into the xar sub-directory, run autogen.sh to generate the configure script, and then build the project with make. We're not installing the tool, so the results stay contained within this folder.

Download & build darling-dmg

Download the darling-dmg repository from here, and head on over to this directory in a Terminal window. Darling-dmg is a part of Darling, a sort of WINE for macOS software, which I didn't even know was a thing that existed until I was going through this process. Regardless, we don't need the entire Darling project, so that's why we're just pulling in darling-dmg.

If you already have Darling installed on your system, you can skip this step as you should already have darling-dmg available.

From the darling-dmg repository folder, run the following:

cmake . && make
What's happening: We're just configuring and building darling-dmg here. We're not installing it, so the results stay contained within this folder. If the build fails, please check the results as this is probably due to a missing library. Simply look through the messages to find the library you're missing, apt install it, and try again.

Extract & prepare the installer image

By this point the download has hopefully finished, and you should have InstallAssistant.pkg sitting right there in your OSX-KVM folder. We'll have to take a few steps now to get to the actual installer image file, so let's do that now.

Make note where the XAR and darling-dmg folders are relative to your OSX-KVM folder, as we'll have to use these now.

Step 1: Extract InstallAssistant.pkg

In a Terminal window opened to your OSX-KVM folder, let's now extract the PKG file:

../path/to/xar-repo-dir/xar/src/xar -xf InstallAssistant.pkg
What's happening: We're using the xar tool we build just before to extract the file by pointing to it relative to your OSX-KVM folder. The built tool should be at xar/src/xar within the folder where you have extracted the repository. -x tells the tool you want to extract, and with -f filename you specify which file you want to extract from.

After a bit, a few new files should have shown up inside your OSX-KVM folder, including SharedSupport.dmg.

Step 2: Mount SharedSupport.dmg

Now we'll use darwin-dmg to mount SharedSupport.dmg. In Terminal, run:

mkdir tmp && ../path/to/darling-dmg-repo-dir/darling-dmg SharedSupport.dmg tmp
What's happening: We're creating a folder called tmp, which we'll use to mount the disk image to. We then use darling-dmg by referencing it within the folder where you extracted the repo to, and specify we want to mount SharedSupport.dmg to the just-created tmp folder.

If this went well, you should see a few messages in your Terminal, and a newly mounted drive show up in your file manager.

Step 3: Extract BaseSystem.dmg

With SharedSupport.dmg mounted, we need to extract BaseSystem.dmg, which is located inside a ZIP file. Using 7zip, run this from your OSX-KVM directory:

7z e ./tmp/com_apple_MobileAsset_MacSoftwareUpdate/*.zip AssetData/Restore/BaseSystem.dmg
What's happening: We're extracting BaseSystem.dmg from a ZIP file found inside the SharedSupport.dmg image we have just before mounted to ./tmp. The ZIP file is located inside the  com_apple_MobileAsset_MacSoftwareUpdate sub-directory, and BaseSystem.dmg is located in AssetData/Restore within that ZIP file. If you like, you can use your favorite file manager and archive tool to extract this directly too.

Step 4: Convert BaseSystem.dmg

We'll now use the dmg2img tool to, as the name implies, convert the image to the img format, something that QEMU can actually work with. Simply run:

dmg2img BaseSystem.dmg BaseSystem.img

A moment or two later you should have the macOS Big Sur installation disk image ready to go. Exciting!

Starting up the VM

The OSX-KVM repository comes with a convenient shell script that you can use to easily launch the VM directly. This file has everything you need pre-configured, though the defaults are probably not ideal if you're planning to use this VM for anything more than just gazing upon it once or so. For example, only 3GB RAM is allocated to it, yikes.

If you're just curious, or if you want to use this script to sort of jump-start the installation of macOS after which you'll move the disk image with Big Sur installed on it over to a more permanent VM configuration, this might be a handy starting point. Otherwise, you might want to skip ahead to the section on using virt-manager.

Method 1: For quick testing, momentary curiosity, or for use as a starting point

The script is called OpenCore-BS.sh and assumes you're launching it from within the repo's directory, have BaseSystem.img ready to go, have a hard drive disk image created, and have the "default" network adapter all set up and ready to go. We're two for four here, so let's go ahead and tackle those last two bits. First, let's create a disk image we'll install Big Sur onto:

qemu-img create -f qcow2 mac_hdd_ng.img 128G
What's happening: We're using the qemu-img tool to create a new disk image called mac_hdd_ng.img that's 128GB in size. Be sure to customize the size to your liking, in case you need more (or less) space.
Note: If you get a message saying you don't have qemu-img installed, you probably didn't install qemu-utils.

Next, let's set up some basic networking stuff so this VM can actually boot up:

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

virsh net-start default
virsh net-autostart default
What's happening: We're basically setting up and configuring a bridge network connection which VMs can use to connect to the internet. For anything beyond quick testing you'll probably want to set up a more robust configuration or pass through an actual network adapter if you have multiple, but for now this should at least get you going.

Now you should be able to boot up the VM for the first time! To start it, just run OpenCore-BS.sh from a Terminal window, and a QEMU remote viewer screen should show up soon thereafter.

After a brief moment, a familiar screen will show up with a few options. Simply hit enter to boot the first option (called macOS Base System), which is the installation disk image.

Note: The OpenCore configuration included with this repository has verbose mode enabled, so you'll be seeing a lot of messages run by as the system (and the installer) boot up. This is normal and intented. You'll be able to modify the OpenCore configuration file should you want to, but that's outside the scope of this already rather lengthy article :).

From here you can proceed as you normally would. Before you start with the installation, be sure to launch into Disk Utility the first time so you can format the disk image.

After selecting and launching Disk Utility from the main menu, select Show All Devices from the sidebar options menu. Then, with the correct disk image selected (you can double check the capacity to make sure you're looking at the right drive), click Erase, name your drive and select your preferred options (Encrypted or not, Case-sensitive or not), and click Erase.

When you're done with that, click Done, close Disk Utility, and select Reinstall macOS from the main menu. From there you can follow the steps as you normally would.

Note: As you probably know, at one point during installation the VM will reboot. To let it continue with the installation, at the boot selection screen be sure to select the macOS Install option, as that's the as-of-yet incomplete installation of macOS on the hard drive.

After about an hour or so of you should be greated with the welcome stuff, where you can set up your user account and whatnot. And after that, well, get ready for border radii to dazzle you with their roundiness.

Well hello there, Big Sur. And yes, Kepler-based NVidia GPUs are still supported. Pretty cool.

Closing thoughts

At this point you should have a working macOS Big Sur VM, Congrats! But it might not be the most elegant of setups. You'll have to use OpenCore-BS.sh to launch the VM every time, and you'll probably notice that macOS itself feels rather sluggish too. The latter is due to the lack of any form of hardware acceleration, something you can only really fix by passing through a graphics card. That topic and several more might be interesting as a follow-up articles, so if you'd like to see that, please let me know.

I hope this was useful for you and that this guide has helped you get to a working virtual machine. Enjoy, and happy coding!

Thank you.