Virtual machines are very important in computer and software development. They primarily allow us to test and use different operating systems without the need for additional hardware. You can also be sure that a virtual machine failure will not harm your existing host operating system.
This guide shows you how to install macOS on Ubuntu Linux with a QEMU KVM virtual machine. This allows you to use native macOS software that is otherwise not available on Linux.
What is QEMU?
QEMU is a virtual machine emulator and virtualizer that is very similar to VMware and VirtualBox on Windows. Users often use QEMU together with KVM because it provides a natively implemented virtual machine on the Linux kernel.
The main advantage of QEMU is that it is very easy to set up and manage. Creating virtual machines from the command line has never been easier with QEMU. You can also use a GUI interface with QEMU / KVM and the preferred GUI manager of choice is virt-manager. There are many other benefits to running virtual machines.
After you have tested a QEMU / KVM virtual machine and you no longer need it, you can easily delete the virtual disk file associated with the virtual machine.
Install 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 distributions. Also, you should install Python utilities alongside the QEMU packages.
Install any required dependencies to continue.
sudo apt-get install qemu-system qemu-utils python3 python3-pip
This guide uses the Foxlet project on GitHub to simplify the macOS installation process and the management of the virtual machine with QEMU / KVM.
First, you need to download the macOS base image and installation tools from Foxlets' official GitHub repository.
Switch to / Downloads Folder to make it the current working directory.
cd ~ / Downloads
Then download the project with the wget Usefulness:
The downloaded packages are saved as master.zip by doing / Downloads Folder. Use the unzip Command line tool to extract the contents of the package.
The unpacking tool saves the extracted command folder as a macOS Simple KVM Master.
Create 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.
mkdir ~ / KVM
After you've created the folder, you can move the unzipped folder to the KVM folder using your macOS installation tools and scripts. You can also rename the folder to for convenience Mac OS. You can do all of this with the command below.
mv ~ / Downloads / macOS-Simple-KVM-Master / ~ / KVM / macOS
Create a virtual hard disk
You will now create a virtual hard drive in the macOS folder that you recently renamed.
cd ~ / KVM / macOS
Run the following script in the macOS folder where your virtual machine is located. The command given below will automatically download the installation image for macOS Catalina.
With the base image, you can now create the image of the virtual hard disk on which you will install macOS.
Use the qemu-img Utility to create the virtual hard disk used to install the operating system.
qemu-img create -f qcow2 mac_os.qcow2 64G
The above command creates a name for the virtual hard disk mac_os.qcow2 by doing qcow2 Format with an estimated size of 64 GB. QEMU creates a larger image than the one you specified, as you can see in the following output, which creates a hard drive of approximately 68GB.
Configure the virtual machine
Another important file in the macOS folder is the basic.sh File used to configure the virtual machine runtime environment.
Add the following two lines to the bottom of the box basic.sh File and save it.
-drive id = SystemDisk, if = none, file = mac_os.qcow2
-device ide-hd, bus = sata.4, drive = SystemDisk
The final content of the basic.sh should look like the picture below.
Another configuration that you can change is the amount of memory that the virtual machine is using. The line begins with -m Specifies the RAM size in GB. You can specify the number of CPU cores used by the virtual machine on the line that starts with -smpi.e. Kernels = x.
Install MacOS on Ubuntu
Run the to start the installation basic.sh Script file that we just edited above.
After executing the above command, you will see the macOS operating system initial installation screen. Press Enter keep going.
Note: Your mouse may not be working properly at this time. Instead, you'll need to use the arrow keys to navigate.
Use the keyboard keys Ctrl + Alt + G. to exit mouse and keyboard controls from the virtual machine window.
Be sure to read the license terms and proceed with the installation by selecting the option Agree Button.
Make sure to format the virtual hard disk using Disk Utility before proceeding with the installation.
Select the appropriate hard drive size in the left pane and click Clear Button. Then rename the hard drive to MainDisk in Disk Utility. Use Apple File System Format (APFS) to format the hard drive and GUID partition mapping scheme as shown below.
After everything is set, close Disk Utility window with the red button in the upper left corner. The system will then redirect you to the previous screen.
If the virtual hard disk is properly formatted, you can now proceed to install macOS by selecting the option Reinstall macOS Possibility.
Now select the installation disk on which your macOS system is located.
On the next screen, you can just click Continue to continue with the installation.
It will take some time to install as you can see from the initial estimated time below. So have a cup of coffee or your favorite drink and relax.
During the installation process, you do not need to make any further selections until you see the following screen asking you to configure the operating system.
Configure your macOS installation
When the installation has come this far, it is time to configure your new operating system. Start by choosing your country or region of residence.
Then select your written and spoken language options. You can use the … Adjust settings Click the button to add more language support if you wish.
The next screen tells you how Apple handles data and user privacy. click Continue Continue.
Under macOS you have the option of transferring data from another PC or storage medium. However, we are not going to do this for now to keep things simple.
You can sign in with your Apple ID later.
On the Terms and Conditions screen, select Agree If you want to continue with the installation.
You can now proceed and set up the user account. Enter your username and a strong 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.
On the analytics screen, you will be asked 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.
Screen time lets you configure whether macOS should record and give you a summary of your screen usage. Choose Set up later and then press the Continue Button.
If you're a fan of voice assistants, you can choose whether or not to enable Siri. Choose Continue to continue with the installation.
The final step before you see your new macOS desktop is to set up a theme color. We'll pick them dark Topic for this tutorial.
Eventually you will be presented with the macOS desktop screen. At this stage, you can use the system, but configuration options may occasionally appear. You can choose to update the system now or later.
There you have it, macOS runs in a virtual machine on Ubuntu Linux.
Starting and stopping the virtual machine
You can shut down or restart your macOS system when you're done with the virtual machine. Press to stop the virtual machine Ctrl + C. in the terminal that has them basic.sh Script is running.
To turn the virtual machine back on, simply start the basic.sh Script in the macOS folder where your virtual hard drive is located.
The following home screen is displayed. Select the option that says Start macOS from the MainDisk.
Further configurations with QEMU / KVM
You can further configure the settings of your virtual machine including the screen resolution. However, this guide focuses only on the installation aspect. Open that / docs Folder in the macOS directory containing the virtual hard disk for further information on further configuration of the system.
Your macOS virtual machine will automatically use the internet connection used by the host operating system, so you can easily proceed with installing your favorite apps. You can also install macOS using a virtual machine on a Windows operating system.
How to run macOS in a virtual machine on Windows 10
Not sure if you can get by with a Mac? Learn how to run macOS on Windows 10 using a virtual machine.
About the author
(7 articles published)
Mwiza is a professional developer of software and writes extensively on Linux and front-end programming. Some of his interests include history, economics, politics, and enterprise architecture.
By Mwiza Kumwenda
Subscribe to our newsletter
Sign up for our newsletter to receive tech tips, reviews, free e-books, and exclusive offers!
One more step …!
Please confirm your email address in the email we just sent you.