This guide will show you how to install macOS on Ubuntu Linux using a QEMU-KVM Virtual Machine. With that, you will be able to use native macOS software that is not otherwise available in Linux.

What Is QEMU?

QEMU is a virtual machine emulator and virtualizer which is quite similar to VMware and VirtualBox on Windows. Users often use QEMU alongside KVM as it provides a natively implemented virtual machine on the Linux kernel.

The major advantage of QEMU is that it is very easy to set up and manage. Also, creating virtual machines from the command line has never been simpler with QEMU. You can also use a GUI interface with QEMU/KVM, and the preferred GUI manager of choice is virt-manager. Running virtual machines will provide you so with many other benefits as well.

After you have finished testing a QEMU/KVM virtual machine and no longer need it, you can easily delete the virtual disk file associated with the virtual machine.

Installing QEMU/KVM

You can install QEMU/KVM from the command line using the apt utility; apt is also used to uninstall applications on Debian-based Linux distros. Besides, you should install Python utilities alongside the QEMU packages.

Install all the required dependencies to proceed further.

Downloading macOS and the Installation Tools

This guide uses the foxlet project on GitHub to ease out the installation process of macOS and management of the virtual machine with QEMU/KVM.

First, you’ll have to download the macOS base image and installation tools from foxlets’ official GitHub repository.

Switch to the /Downloads folder to make it the current working directory.

Then download the project using the wget utility:

The downloaded packages will be saved as master.zip in the /Downloads folder. Use the unzip command-line utility to extract the contents of the package.

The unzip tool will save the extracted command folder as macOS-Simple-KVM-master.

Creating a KVM Folder for Your Virtual Machines

To easily manage your virtual machines, you can create a folder named KVM that will contain the macOS virtual machine. You can use this directory to host other virtual machines on your system.

Once you have created the folder, you can move the unzipped folder containing your macOS installation tools and scripts to the KVM folder. Also, in order to simplify things, you can rename the folder to macOS. You can do all of this using the following command.

Creating a Virtual Disk

You will now create a virtual hard disk inside the macOS folder that you have recently renamed.

Run the following script from within the macOS folder that will host your virtual machine. The below-given command downloads the macOS Catalina installation image automatically.

With the base image in place, you can now create the virtual disk image in which you will install macOS.

Use the qemu-img utility to create the virtual hard disk that will be used for installing the operating system.

The command above creates a virtual disk name mac_os.qcow2 in the qcow2 format with an estimated size of 64GB. QEMU will create a larger image than the one you specify as you can see in the output below where it creates a disk of about 68GB.

Configuring the Virtual Machine

Another important file in the macOS folder is the basic.sh file, used for configuring the runtime environment of the virtual machine.

Add the following two lines at the bottom of the basic.sh file and save it.

The final content of the basic.sh should look like the one in the image below.

Another configuration that you can change is the amount of RAM the virtual machine will use. The line starting with -m specifies the RAM size in GB. You can specify the number of CPU cores used by the virtual machine in the line that begins with -smp, i.e cores=x.

Installing macOS on Ubuntu

To start the installation, run the basic.sh script file that we have just edited above.

After you run the command above, you will see the initial installation screen of the macOS operating system. Press Enter to continue.

Note: Your mouse may not work properly at the moment. Instead, you will have to use the arrow keys for navigation.

Use the keyboard keys Ctrl + Alt + G to exit mouse and keyboard controls from the virtual machine window.

Make sure to read the license terms and proceed with the installation by selecting the Agree button.

Remember to format the virtual disk using Disk Utility before proceeding with the installation.

Select the corresponding disk size from the left panel and click the Erase button. Then, rename the disk to MainDisk in the disk utility. Use the Apple File System format (APFS) to format the disk, and the GUID partition map scheme as shown below.

After everything is set, close the disk utility window with the red button on the upper left corner. The system will then direct you to the previous screen.

With the virtual hard disk properly formatted, you can now proceed to install macOS by selecting the Reinstall macOS option.

Now select the installation disk that will hold your macOS system.

On the next screen that follows, you can just click Continue to proceed with the installation.

The installation will take some time, as you can see from the initial estimated time below, so grab a cup of coffee or your favorite drink and relax.

During the installation process, you do not need to make other selections until you see the screen below that asks you to configure the operating system.

Configuring Your macOS Installation

If the installation has come this far, it is time to configure your new operating system. Start by selecting your country or region of residence.

Then proceed to select your Written and Spoken language options. You can use the Customize Settings button to add more language support if you wish.

The next screen presents you with how apple handles data and user privacy. Click Continue to proceed.

With macOS, you have the option to transfer data from another PC or storage medium, but we will not do this at this moment to keep things simple.

You can choose to Sign in with your Apple ID later.

On the Terms and Conditions screen, select Agree if you want to proceed with the installation.

You can now move forward and set up the user account. Supply your username and a secure password to continue. You can also provide a hint to help you remember the password in case you forget it.

On the next screen that says Express Set Up, just press Continue.

The analytics screen asks for your consent to share crash and usage data with developers. Check the Share crash and usage data with app developers option and select the Continue button.

The screen time allows you to configure if macOS should record and give you a summary of your screen usage. Select Set Up Later and then press the Continue button.

If you are a fan of voice assistants, you can select whether to enable Siri or not. Select Continue to proceed with the installation.

The final step before you see your new macOS desktop is to set up a theme color. We will be selecting the Dark theme for this tutorial.

Finally, you will be presented with the macOS desktop screen. At this stage, you can start using the system, but some configuration options may appear every now and then. You can also choose to update the system right now or later.

There you have it, macOS running inside a virtual machine on Ubuntu Linux.

Starting and Stopping the Virtual Machine

You can shut down or restart your macOS system if you are done using the virtual machine. To stop the virtual machine, press Ctrl + C in the terminal that has the basic.sh script running.

To power up the virtual machine again, simply start the basic.sh script inside the macOS folder that hosts your virtual hard disk.

You will be presented with the following boot screen. Select the option that says Boot macOS from MainDisk.

More Configurations With QEMU/KVM

You can further configure your virtual machine settings including screen resolution, but this guide solely focuses on covering the installation aspect. Open the /docs folder inside the macOS directory that contains the virtual hard disk to read more about how to further configure the system.

Your macOS virtual machine will automatically use the internet connection used by the host operating system, so you can easily proceed to install your favorite apps. Similarly, you can install macOS using a virtual machine on a Windows operating system as well.