Skip to content

Instantly share code, notes, and snippets.

@DJStompZone
Created April 21, 2024 18:22
Show Gist options
  • Save DJStompZone/daebe8c9531e67e7fa67aecc8c408744 to your computer and use it in GitHub Desktop.
Save DJStompZone/daebe8c9531e67e7fa67aecc8c408744 to your computer and use it in GitHub Desktop.
Running Macos Sonoma VM on Linux

Quickstart Guide for macOS Sonoma VM on Linux using QEMU/KVM

Prerequisites

  • Modern Linux distribution (e.g., Ubuntu 22.04 LTS or later)

  • CPU with Intel VT-x / AMD SVM support

  • Install necessary packages:

    sudo apt-get install qemu uml-utilities virt-manager git wget libguestfs-tools \
    
    p7zip-full make dmg2img tesseract-ocr tesseract-ocr-eng genisoimage vim net-tools screen -y
    

Installation Steps

1. Clone the OSX-KVM Repository

  • Clone the repository to get the necessary scripts and files:

    git clone --depth 1 --recursive https://github.com/kholia/OSX-KVM.git
    
    cd OSX-KVM
    

2. Fetch the macOS Installer

  • Use the script to download the macOS Sonoma installer:

    ./fetch-macOS-v2.py
    

3. Prepare the Installation Image

  • Convert the downloaded BaseSystem.dmg to an ISO:

    dmg2img -i BaseSystem.dmg -o BaseSystem.iso
    

4. Create and Run the VM

  • Configure the virtual machine using QEMU:

    qemu-system-x86_64 -enable-kvm -m 4096 -cpu host -smp 4,sockets=1,cores=2,threads=2 \
    
    -machine q35,accel=kvm -usb -device usb-kbd -device usb-tablet \
    
    -drive if=pflash,format=raw,readonly,file=OVMF_CODE.fd \
    
    -drive if=pflash,format=raw,file=OVMF_VARS.fd \
    
    -drive format=raw,file=BaseSystem.img -netdev user,id=net0 \
    
    -device vmxnet3,netdev=net0,id=net0,mac=52:54:00:c9:18:27 \
    
    -device ide-drive,bus=ide.2,drive=Clover \
    
    -drive id=Clover,if=none,snapshot=on,format=qcow2,file=./'Clover.qcow2' \
    
    -device ide-drive,bus=ide.1,drive=MacHDD \
    
    -drive id=MacHDD,if=none,file=./'MacHDD.qcow2',format=qcow2 \
    
    -monitor stdio
    

5. Install macOS Sonoma

  • Follow the on-screen instructions to install macOS Sonoma.

  • After installation, configure your VM settings as needed.

Post-Installation

  • Install additional tools and drivers for better integration and performance.

  • Configure networking and other peripherals as necessary.

Notes

  • For detailed instructions and troubleshooting, visit the OSX-KVM GitHub page.

  • This guide assumes a working knowledge of Linux and command-line interface. .

@demian-mint
Copy link

sonoma very slow

@Sammyueru
Copy link

sonoma very slow

Try changing the allocated memory from 4096 to something higher like 8192.

@Sammyueru
Copy link

Whenever I try running Sonoma after installation the VM just restarts without letting me into the macOS installation does anyone know how to fix this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment