How to install macOS in Linux using KVM?

macOS is a Unix-based proprietary graphical operating system which is developed by Apple Inc. It is the primary OS of Apple’s Mac computers and the second most widely used desktop OS after Microsoft Windows.

In this article, I will discuss how to install macOS in KVM which is installed on a Linux system. We will use macOS-Simple-KVM code which is available on GitHub to

Prerequisites

To follow this guide you should have the following –

  • QEMU installed and KVM module should be enabled on your Linux system
  • Python3 and Pip installed

Installing macOS in KVM

Follow the steps that are given below to install macOS on QEMU-KVM in a Linux system.

Installing QEMU

If you are using Ubuntu or Debian system and if you do not have QEMU installed on your system then you can install it by using the following command –

sudo apt install qemu-system qemu-utils qemu-kvm libvirt-daemon virt-manager bridge-utils virt-install -y

Next, start and enable KVM by using –

sudo systemctl start libvirtd
sudo systemctl enable libvirtd

Finally, reboot your system with –

sudo reboot

Installing Python and Python pip

Next, use the following command to install Python3 and Python pip

sudo apt install python3 python3-pip -y

Installing git

We need git to clone the macOS-Simple-KVM repository, use the following command to install git on your system –

sudo apt install git -y

Clone the macOS-Simple-KVM code from GitHub

Use the following command to clone the macOS-Simple-KVM repository on your system –

git clone https://github.com/foxlet/macOS-Simple-KVM.git

Move to the downloaded directory –

cd macOS-Simple-KVM

Next, run the installer script to download installation media for macOS –

./jumpstart.sh --catalina

Here you can use choose which version to install among --high-sierra, --mojave, or --catalina.

Installing macOS

Allocate disk for macOS installation with qemu-img command.

qemu-img create -f qcow2 MyDisk.qcow2 50G

Open basic.sh file using a text editor and add the following lines at the end.

   -drive id=SystemDisk,if=none,file=MyDisk.qcow2 \
   -device ide-hd,bus=sata.4,drive=SystemDisk \

Save this file and exit from the editor.

Now run basic.sh file using the given command in your terminal.

./basic.sh

This will start qemu for macOS installation. Click on the macOS icon to start the installation process.

install macos

Next, select Disk Utility and click on Continue.

macOS utitlities

Format the disk which is created for installing macOS.

format disk

Now exit from Disk Utility and Reinstall macOS.

reinstall macos

In the next window click on Continue.

macos install

Accept the user licenses agreement by clicking on Agree.

accept license

Now select the disk and click on Install to install macOS.

install macos

This will take some time to install macOS on your system.

installation of macos

Once completed, you can import the setup in Virt-manager for further configuration.

sudo ./make.sh --add

Now add the MyDisk.qcow2 as storage in the properties of the newly added virtual machine.

For more information, you can read its official documentation.

Conclusion

Ok, so you have successfully installed macOS in kvm. Now if you have a query then write us in the comments below.

Leave a Comment