Qemu mac os windows

Running Qemu-system-ppc with Mac OS/OSX guests in Windows

(Guide updated July 7th, 2023)

Introduction

Qemu-system-ppc can run the PowerPC versions of Mac OS 9.0 to 9.2 and OSX 10.0 to 10.5. Qemu can also run some OSX release previews.

The status of various guests based on the latest builds available from the forum:

Guest Default build Sound-enabled build Argument(s) Remarks
Mac OS 9.0 OK OK -M mac99 Requires rom version 5.2.1 or above, mouse wiggle to boot
Mac OS 9.1 OK OK -M mac99,via=pmu
Mac OS 9.2 OK OK -M mac99,via=pmu
Mac OSX 10.0 OK Crackle, channel issue -M mac99
Mac OSX 10.1 OK Channel issue -M mac99
Mac OSX 10.2 OK OK, but channels reversed -M mac99 -device pci-ohci,id=usb1 -device usb-mouse,bus=usb1.0 -device usb-kbd,bus=usb-bus.0
Mac OSX 10.3 OK OK -M mac99,via=pmu Sound has speed drift
Mac OSX 10.4 OK OK -M mac99,via=pmu
Mac OSX 10.5 OK OK -M mac99,via=pmu

Requirements

  • Qemu program

  • Disk images for the PowerPC versions of Mac OS or OSX you want to install

Assumptions in this guide

This guide assumes you are installing Mac OS 9.2 on a 2gb file that will act as your hard disk for Mac OS.

The CD image you install from is called MacOS9.2.iso and the hard disk is called MacOS9.2.img

Installations of other versions of Mac OS or OSX (roughly) follow the same path.

See the table above for information about specific qemu parameters required to run Mac OS/OSX versions.

Qemu-system-ppc installation

  • Create a folder for Qemu-related files and unpack the download. Put your Mac OS/OSX disk images in this folder.

  • Create an empty disk image with qemu-img.exe. Open a command prompt and navigate to your Qemu folder.

qemu-img.exe create -f raw -o size=2G MacOS9.2.img 
  • Open your favorite text editor and create a file called qemu.bat in your qemu folder. (If one is contained in the download, edit that one).

  • Paste the code below into the file:

qemu-system-ppc.exe ^

-L pc-bios ^

-M mac99,via=pmu ^

-m 512 ^

-display sdl ^

-boot d ^

-drive file=MacOS9.2.iso,format=raw,media=cdrom ^

-drive file=MacOS9.2.img,format=raw,media=disk

  • Save qemu.bat

Short explanation of the content of the file:

qemu-system-ppc.exe starts qemu with all of the following as parameters:

  • -L pc-bios defines the location of bios files to be used.

  • -M mac99,via=pmu defines the mac model used(*).

  • -m 512 defines the amount of memory (in Mb) for OS9/OSX.

  • -display sdl instructs Qemu to use SDL for the graphical display

  • -boot d defines to boot from a drive entry marked as a cdrom, “-boot c” would define to boot from a drive entry marked as disk.

  • -drive file=MacOS9.2.iso,format=raw,media=cdrom defines the name, location, format, and type of image (cdrom) file to be used

  • -drive file=MacOS9.2.img,format=raw,media=disk defines the name, location, format, and type of image (disk) file to be used

(*)The mac model entry accepts 3 options for the via parameter:

mac99,via=pmu (with PMU, supporting usb mouse and keyboard)

mac99,via=pmu-adb (this allows some older Mac OS/Mac OS server builds to use a keyboard and mouse through the adb bus)

mac99,via=cuda (default, this allows use of the older adb (Apple Desktop Bus), now less supported cuda)

Note: to run Leopard, you have to use -M mac99,via=pmu

  • Double-click qemu.bat. This starts Qemu and boots the MacOS9.2.iso installation CD image.

Installation of Mac OS 9.2

After you booted from the CD you first need to partition the hard disk:

  • Go into the “Utilities” folder and start the “Drive Setup” program.

  • Select the entry “<not initialized>” and click “Initialize” and again in the next window.

After initialization has finished and a disk icon has appeared on the desktop, quit the program.

You can then start the installation of Mac OS. Shut down Mac OS after the installation has finished.

Please note that the initialization step has to be repeated for any NEW disk added to Mac OS.

Booting the installed Mac OS

To boot the installed Mac OS, you need to edit the qemu.bat file:

  • Change the -boot d argument to -boot c.

Double-click qemu.bat and Mac OS will boot from the hard disk.

Done.

Connecting other CDs or disk images

If you want to install software, make an image of the CD-Rom and attach it to Qemu. Add a disk after the hard disk entry to qemu.bat:

–drive file=Name-of-CD-image.iso,format=raw,media=cdrom 

or for a second hard disk:

–drive file=Name-of-hard-disk-image.img,format=raw,media=disk

And save the file. Start qemu.bat. The CD image (if readable by Mac OS) will appear on the desktop for you to use.

A new hard disk needs to be partitioned as described above.

Changing the graphics settings

You can set the initial size and colour depth of the boot window, using the -g parameter like this:

–g 1024x768x32  (Without the quotes!) 

Subsequent changes to the resolution can be made with default OS tools. (e.g., the Monitors control panel in MacOS or equivalent in OSX).

Tablet driver support

Note: this will only work in conjunction with -M mac99, not when running with -M mac99,via=pmu

To enable tablet driver support download the latest version of the required ndrvloader file here: https://github.com/elliotnunn/classicvirtio/releases/tag/latest and add the following to your command line:

–device loader,addr=0x4000000,file=ndrvloader
–prom-env "boot-command=init-program go"
–device virtio-tablet-pci

Opening a serial connection to the host

You can open a connection to a com port on the windows host by adding:

–device usb-serial,chardev=com -chardev serial,path=com1,id=com

to your command line. chardev=“” and id=“” have to match, but you can open a different com port by changing the path= parameter.

When you start Qemu, a window will open in which you can set the serial communication parameters.

Inside your Mac OS 9.x guest a FTDI driver is needed from: https://www.ftdichip.com/Drivers/VCP.htm (download the 1.0f4 version)

Once installed you can open a modem connection through the “USBHighSpeedSerialConverter”, or use a terminal emulator such as zterm.

Sharing devices with the Guest—GUIDE IN PROGRESS

You can attempt to pass-through devices attached to the host to the guest. For USB devices in general this takes the form of:

–device usb-host,vendorid=0x0000,productid=0x0000"

But remember you have to adjust the vendorid and productid. On a Windows host, you can find the required USB vendorid and productid by checking the USB device in the Device Manager.
Mac OS up to 10.2.8 will only support USB 1.1. If your device uses USB 2, you can attach it to an USB 1.1 hub to force it into USB 1.1 mode.

To allow Qemu to take control of the device you might have to use a utility such as the USBDriverTool to load a different driver for the device.

Mac OS 9.0 to 10.2

Sharing an USB device with Mac OS 9.0 up to Mac OSX 10.2 is restricted to using USB 1.1 devices.
A way to push a USB 2.0 device into USB 1.1 mode is to attach it to a strictly USB 1.1 hub (as found in older Apple keyboards or regular 1.1 hubs).

–device usb-host,vendorid=0x058f,productid=0x6387 

(replace product and vendor id with what you found)

Mac OS 10.3 and above

Mac OS 10.3 and above support USB 2. To add an USB 2 device, first add a USB 2 controller and then attach you device to that controller:

–device usb-ehci,id=ehci
–device usb-host,bus=ehci.0,vendorid=0x058f,productid=0x6387 

(replace product and vendor id with what you found)

Networking

The latest Qemu-system-ppc for Windows builds emulate a network device that is supported out of the box for Mac OS 9.0 up to OSX 10.5

There are several ways to get networking going in Windows:

Slirp-based networking

Note: this is activated by default on Qemu-system-ppc, so doesn’t need to be mentioned explicitly on the command line:

  • -device sungem,netdev=network01 -netdev user,id=network01

Running two Qemu-system-ppc instances with networking

If you want to run two instances of Mac OS/OSX simultaneously, Qemu needs to be able to tell the network devices apart. You can add a mac address to the networking device:

  • -device sungem,netdev=network01,mac=52:54:00:12:34:56 -netdev user,id=network01 (this is the default mac address)

and make sure you add a different mac address to the second instance:

  • -device sungem,netdev=network01,mac=52:54:00:12:34:66 -netdev user,id=network01

Please note that adding a mac address other than the default to the network device leads to the discovery of a new network card in OSX. You need to configure that card through the network preferences.

Tap-based: Bridging one or more tap device (enabling Appletalk networking)

Install an OpenVPN tap device and bridge it with your normal ethernet connection. Then use the following on the Qemu-system-ppc command line:

  • -device sungem,netdev=network01 -netdev tap,ifname=TapEthernet1,id=network01 (and replace “TapEthernet1” with the name of the tap device network connection)

To allow two Qemu-system-ppc instances to “see” each other on the network and also have internet access, install a second tap device and bridge both tap devices with your default network connection. You must then also use different mac addresses for each connection. Note that the tap devices should have different names too.

  • -device sungem,netdev=network01,mac=52:54:00:12:34:56 -netdev tap,ifname=TapEthernet1,id=network01

  • -device sungem,netdev=network01,mac=52:54:00:12:34:66 -netdev tap,ifname=TapEthernet2,id=network01

Peer to peer networking between two Qemu instances

Qemu can use socket networking to connect two peers. The peers will have no internet access, but can exchange data between each other.

Set one guest to be a listener for network traffic:

  • -device sungem,netdev=network01,mac=52:54:00:12:34:56 -netdev socket,id=network01,listen=:1234

Set the other guest to connect to the listener:

  • -device sungem,netdev=network01,mac=52:54:00:12:34:66 -netdev socket,id=network01,connect=127.0.0.1:1234

For both instances, set the TCP/IP settings manually to a free ip address in your IP range and set the subnetmask to 255.255.255.0. No other settings have to be made.

Forwarding (multiple) ports to the host (only needed when using the slirp network option)

You can provide services running on the guest to the host by forwarding ports to the host.

Running a webserver
  • -device sungem,netdev=network01 -netdev user,id=network01,hostfwd=tcp::8080-:80

The webserver running on the guest is then accessible through http://name-or-ip-adress-of-host:8080 from other machines running on your network.

Getting files in and out of a Mac OS 9.x or OS X guest with FTP
  • -device sungem,netdev=network01 -netdev user,id=network01,hostfwd=tcp::2121-:21

Forwarding port 21 to the host allows running an ftp server (such as Netpresenz, available from the macintosh garden site) on an Mac OS 9.x guest and read/write access to the file system of the guest. Make sure to use an FTP client capable of active transfer mode on the host (such as Filezilla, we are dealing with an old guest system after all.) For access to a Mac OS X guest, enable the ftp service.

You can access the guest by connecting to ftp://name-or-ip-adress-of-host:2121 from other machines running on your network.

Mac OS 9 guest: Enable file sharing through the control panel: Enter a Owner name, password and computer name and click Start under File Sharing. Then, at the Users & Groups pane open your user. At Show, select Sharing and set allow user to connect and select see all disks.

Next, share your hard drive: select the drive icon, use File/Get info/Sharing to set Share this item and…

Start Netpresenz setup, configure the ftp service and user: At ftp setup, Owner need full access. Then check the Summary for any additional configuration hints, then start Netpresenz.

Mac OS X guest: Open system preferences→sharing and enable the FTP service.

-On the Windows/Filezilla side:

Start Filezilla, open Edit/Settings.

Click FTP. Set Transfer Mode to Active, at FTP Keep-alive, enable Send FTP keep-alive commands.

Click Active Mode. At Active mode IP set “Ask your operating system for the external IP address”

Click OK.

In the Filezilla connection bar, enter the IP4 address of your host and your guest Mac OS /Mac OS X user name and port 2121, then click Quickconnect. Filezilla will ask for your Mac OS password and warn you about the insecure connection. In the Remote site pane you get access to your user folder.

Multiple port forwarding

You can forward multiple ports:

  • -device sungem,netdev=network01 -netdev user,id=network01,hostfwd=tcp::2121-:21,hostfwd=tcp::8080-:80

You can also forward ports for appletalk over tcp/ip:

  • -device sungem,netdev=network01 -netdev user,id=network01,hostfwd=tcp::548-:548,hostfwd=tcp::387-:387

Advanced usage

Installing multiple Mac OS/OSX onto one disk image

You can install e.g. Mac OS 9.2 and Mac OSX 10.2 onto different partitions on one disk image. Make sure the disk image size does not exceed the maximum size (8Gb) from which Mac OS/OSX can boot.

  • Boot Qemu with a Mac OS 9.2 iso and use disk utility to partition your disk to contain two partitions of size 2 gb and 6 Gb.

  • Install Mac OS 9.2 onto the 2Gb disk. Then shut down.

  • Next, boot from the Mac OS X 10.2 iso. When the installer has started select disk utility and make sure the Mac OS 9 drivers will be installed on the disk image. Select the disk (not one of the partitions) and check the appropriate box.

  • Then install Mac OS X 10.2 on the second partition. After installation shut down Qemu.

As the startup disk control panel does not work with Qemu, you need to tell Qemu which partition to boot from.

You do this by adding a line to your bat file:

  • -prom-env “boot-device=hd:X,\\:tbxi”

Where X is the number of the partition to boot from. If you started with a clean empty hard disk image there is a good chance -prom-env “boot-device=hd:6,\\:tbxi” will boot Mac OS, while -prom-env “boot-device=hd:7,\\:tbxi” will boot Mac OS X. Otherwise you might have to experiment with the partition number.

Printing

There are multiple way to print from the guest operating system to the host:

Print directly to a networked printer you have Mac OS/OSX drivers for. This assumes you have set up tap networking so Mac OS can see the windows network and networked printer.

Print to a file that is moved to the host to print. How to print to e.g., a pdf file depends on the guest operating system.

Changing the mounted cdrom image

In Mac OS: First drag any mounted CD from the desktop into the trash

  • Open the Qemu Monitor by pressing Ctrl-Alt-2

  • Type “info block” to find the name of the CD drive in Qemu (most likely: ide1-cd0)

  • Type “eject ide1-cd0”

  • Type “change ide1-cd0 Driveletter:/path/name-of-cd-image.iso” (note the forward slashes!)

  • Close the Qemu Monitor by pressing Ctrl-Alt-2 again (do not close the window by clicking the close button)

Also see the qemu documentation here: https://www.linux-kvm.org/page/Change_cdrom

Mounting a real cd

NOTE: You cannot mount Mac formatted CD’s, but other formats work

  • Open the Qemu Monitor by pressing Ctrl-Alt-2

  • Type “info block” to find the name of the CD drive in Qemu (most likely: ide1-cd0)

  • Type “change ide1-cd0 /dev/cdrom” (note the forward slashes!)

  • Close the Qemu Monitor by pressing Ctrl-Alt-2 again (do not close the window by clicking the close button)

Using a virtual usb drive to exchange files with the host

NOTE: This option is not error-free

Create an empty folder to be used to exchange files. In the example below, the folder c:\QemuVVFAT is used.

Add the following to your command line:

-device usb-storage,drive=fat32 -drive file=fat:rw:c:\QemuVVFAT,id=fat32,format=raw,if=none

An USB drive called Qemu-VVFAT will appear on your desktop. You can use it to exchange files with the host.

Experimental builds and features

Qemu is being actively developed. This means that some new features can become available that are not yet incorporated into the official source code.
Currently there are several such developments, in various states of reliability:

You can download some of these experimental builds for our forum under Experimental builds : http://www.emaculation.com/forum/viewtopic.php?f=34&t=9028

-Sound support.

-File sharing with the host

-Mouse tablet driver

Issues

  • Restart doesn’t work in Mac OS 9.x. Use Shut Down and restart Qemu.

  • Qemu will not boot Mac OS when memory is set to 64Mb or less.

  • Sound only works reasonably well in Mac OS 9.x guests.

  • Sound will not work in, or crash Mac OS guests with memory set to 1024Mb or more.

Useful additional command line arguments

  • -k en-us sets the keyboard language (see below for possible languages)

The language codes available are:

ar de-ch es fo fr-ca hu ja mk no pt-br sv

da en-gb et fr fr-ch is lt nl pl ru th

de en-us fi fr-be hr it lv nl-be pt sl tr

  • -rtc base=localtime sets the guest time to the local machine time

  • -full-screen sets the guest to run full screen

  • -prom-env “auto-boot?=false” stops boot at the openbios prompt

  • -prom-env “boot-args=-v” shows verbose boot messages with OSX guests

  • -prom-env “vga-ndrv?=false” disables loading the default VGA driver

When you install multiple Mac OS/OSX on different partitions of a disk image, you need to tell Qemu from which partition to boot:

  • -prom-env “boot-device=hd:6,\\:tbxi”

  • -prom-env “boot-device=hd:7,\\:tbxi”

Version numbering

Since version 3.0.0, QEMU uses a time based version numbering scheme:

major
incremented by 1 for the first release of the year
minor
reset to 0 with every major increment, otherwise incremented by 1 for each release from git master
micro
always 0 for releases from git master, incremented by 1 for each stable branch release

The implication of this is that changes in major version number
do not have any bearing on the scope of changes
included in the release. Non-backward compatible changes may be made
in any master branch release, provided they have followed the
deprecation
policy which calls for warnings to be emitted for a minimum of two
releases prior to the change.

Why Run Windows on macOS with QEMU?

Ever found yourself in a situation where you need to run a Windows-specific application on your Mac, but don’t want to deal with the hassle of dual-booting or the cost of commercial virtualization software? Enter QEMU, a powerful open-source emulator and virtualizer that can help you run Windows on macOS without breaking the bank. In this guide, I’ll walk you through the process of setting up QEMU to run Windows on your Mac, sharing my personal experiences and tips along the way.

I’ve been tinkering with virtualization for years, and QEMU has always been my go-to tool. It’s versatile, free, and surprisingly efficient once you get the hang of it. So, let’s dive in and see how you can get Windows up and running on your Mac using QEMU.

Getting Started with QEMU on macOS

Prerequisites

Before we dive into the setup process, let’s make sure you have everything you need:

  • A Mac running macOS (preferably a recent version)
  • A Windows ISO file (you can download this from the official Microsoft website)
  • Adequate disk space and RAM (at least 20GB of free space and 4GB of RAM are recommended)
  • Homebrew, the popular macOS package manager

Installing QEMU via Homebrew

The first step is to install QEMU using Homebrew. If you don’t have Homebrew installed, you can do so by running the following command in your terminal:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Once Homebrew is installed, you can install QEMU with this command:

brew install qemu

Downloading a Windows ISO

Next, you’ll need a Windows ISO file. You can download this directly from Microsoft’s website. Make sure to choose the version that matches your needs (e.g., Windows 10 or Windows 11).

Setting Up Your Virtual Machine

Creating a Virtual Hard Disk

Before you can install Windows, you need to create a virtual hard disk. This will act as the storage for your Windows installation. You can create a virtual hard disk using the following command:

qemu-img create -f qcow2 windows.qcow2 60G

This command creates a 60GB virtual hard disk named windows.qcow2. You can adjust the size as needed.

Launching the QEMU Virtual Machine

Now that you have your virtual hard disk, you can launch the QEMU virtual machine and start the Windows installation process. Use the following command to launch QEMU:

qemu-system-x86_64 -hda windows.qcow2 -cdrom /path/to/windows.iso -m 4G -boot d

Here’s a breakdown of the command:

  • -hda windows.qcow2: Specifies the virtual hard disk
  • -cdrom /path/to/windows.iso: Specifies the Windows ISO file
  • -m 4G: Allocates 4GB of RAM to the virtual machine
  • -boot d: Boots from the CD-ROM (the Windows ISO)

Replace /path/to/windows.iso with the actual path to your Windows ISO file.

Installing Windows

Once QEMU launches, you should see the Windows installation screen. Follow the on-screen instructions to install Windows. The process is straightforward and similar to installing Windows on a physical machine.

Post-Installation Configuration

After Windows is installed, you’ll want to make a few adjustments to ensure everything runs smoothly:

  • Install the VirtIO drivers for better performance. You can download these from the VirtIO Windows repository.
  • Adjust the screen resolution and other display settings to your preference.
  • Install any necessary updates and software you need for your workflow.

Optimizing QEMU Performance

Allocating More Resources

One of the easiest ways to improve the performance of your QEMU virtual machine is to allocate more resources. You can increase the amount of RAM and CPU cores dedicated to the VM. For example:

qemu-system-x86_64 -hda windows.qcow2 -m 8G -smp 4 -boot c

This command allocates 8GB of RAM and 4 CPU cores to the virtual machine.

Using KVM for Hardware Acceleration

KVM (Kernel-based Virtual Machine) is a Linux kernel module that allows QEMU to use hardware virtualization features. While macOS doesn’t support KVM natively, you can use a tool like HAXM (Hardware Accelerated Execution Manager) to achieve similar results. Here’s how to install HAXM:

brew install --cask intel-haxm

After installing HAXM, you can enable it in QEMU with the following command:

qemu-system-x86_64 -hda windows.qcow2 -m 8G -smp 4 -enable-hax

Network Configuration

To access the internet from your Windows VM, you’ll need to configure networking. QEMU supports various networking options, but the simplest is to use the -net user option:

qemu-system-x86_64 -hda windows.qcow2 -m 8G -smp 4 -net user

This command sets up a user-mode network stack, allowing your VM to access the internet through your Mac’s network connection.

Troubleshooting Common Issues

Slow Performance

If your Windows VM is running slowly, consider the following tips:

  • Allocate more RAM and CPU cores to the VM.
  • Ensure that HAXM is enabled for hardware acceleration.
  • Close any unnecessary applications running on your Mac to free up resources.

Display Issues

If you’re experiencing display issues, such as low resolution or flickering, try the following:

  • Install the VirtIO drivers to improve graphics performance.
  • Adjust the display settings within Windows.
  • Use the -vga std option in your QEMU command to switch to a different graphics mode.

Network Problems

If your VM can’t connect to the internet, check the following:

  • Ensure that the -net user option is included in your QEMU command.
  • Verify that your Mac’s network connection is active.
  • Check the network settings within Windows to ensure that the network adapter is enabled.

Advanced QEMU Configuration

Pass-Through Devices

For advanced users, QEMU supports pass-through devices, allowing you to dedicate specific hardware to your VM. This can significantly improve performance but requires careful configuration. Refer to the QEMU documentation for detailed instructions on setting up pass-through devices.

Snapshots and Backups

Snapshots allow you to save the state of your VM at a specific point in time, making it easy to roll back if something goes wrong. You can create a snapshot with the following command:

qemu-img snapshot -c snapshot1 windows.qcow2

To restore a snapshot, use:

qemu-img snapshot -a snapshot1 windows.qcow2

Custom Kernel Modules

If you need to load custom kernel modules into your Windows VM, you can do so by modifying the QEMU command to include the -kernel option. This is an advanced topic and requires a good understanding of both QEMU and Windows kernel modules.

Conclusion: Embrace the Versatility of QEMU

Running Windows on macOS with QEMU is a powerful and flexible solution for those who need to use Windows applications without leaving the macOS environment. While it may require some initial setup and configuration, the benefits of using QEMU are well worth the effort. From cost savings to the flexibility of open-source software, QEMU offers a robust alternative to commercial virtualization solutions.

So, why not give it a try? Embrace the versatility of QEMU and see how it can enhance your workflow. And remember, the journey of learning and tinkering is half the fun!

FAQ

Q: Can I run other operating systems besides Windows with QEMU?
A: Yes, QEMU supports a wide range of operating systems, including various Linux distributions, BSD, and even older versions of macOS.

Q: Is QEMU suitable for gaming?
A: While QEMU can run some games, it’s not optimized for high-performance gaming. For the best gaming experience, consider using a dedicated gaming PC or a cloud gaming service.

Q: Can I use QEMU on a Mac with Apple Silicon?
A: As of my knowledge cutoff in 2025, QEMU support for Apple Silicon is still evolving. While it’s possible to run QEMU on Apple Silicon, performance and compatibility may vary. Keep an eye on the QEMU documentation for the latest updates.

Q: How does QEMU compare to other virtualization solutions like Parallels or VMware?
A: QEMU is a highly versatile and free open-source solution, making it a great choice for those who prefer flexibility and cost savings. However, commercial solutions like Parallels and VMware often provide better performance and ease of use, especially for less tech-savvy users.

Running MacOS on Windows 10

Note — Unfortunately this no longer works due to movement in the WSL offering for Windows 11 Dev Channel. Am leaving this here incase some of the workarounds for issues below help others in their projects!

I needed to record a demo on a Mac, I don’t own a Mac and was contemplating borrowing one from a friend. Then I realised, I finally had an excuse to give this a go! I’ve been itching to since I read — Accelerated KVM guests on WSL 2, an awesome write-up on how to run accelerated KVM guests on WSL2 from @unixterminal

This is a walkthrough of how I used the excellent work of @unixterminal and @FoxletFox and got my 3 year old XPS Intel i7 to run MacOS on Windows 10! Without their writeups and scripting this post probably wouldn’t exist.
I am still stunned how good the performance is having run through this! I’ve tried a couple of other Linux distro’s too, seriously slick.

Before starting check out the requirements from the top of the «Accelerated KVM guests on WSL2» post. One thing that’s not obvious is your CPU needs to support virtualisation. Unless you’re running an Intel CPU from the early 2000s or even earlier you should be OK. If your CPU does support virtualization it might not be enabled in your BIOS, it’s worth a check before you start. If you’re already running a hypervisor, it’s likely this is good to go.

You’ll also need to be running a windows insider build of Windows 10. The insiders Fast ring which is mentioned in the pre-requisites is now the Dev channel. One of the features required didn’t come into Windows 10 until build 19619 and the nested virtualisation support for AMD didn’t come in until build 19636 either, so that’s a must if you are on AMD too. The windows insider page currently lists 19042.423 as the highest build available in Beta and 19041.423 as Release Preview, so for the moment this will not work correctly without using the Dev channel.

The insider channel renaming is described here. Dev channel is described as Ideal for highly technical users. Insiders in the Dev Channel will receive builds that is earliest in a development cycle and will contain the latest work-in-progress code from our engineers. These builds will have rough edges and some instability that could block key activities or require workarounds.

With this in mind, think twice about running the Dev channel on your main machine, or if you wouldn’t consider yourself a highly technical user! If you’re OK with that, dive right in :

  1. Follow the steps in «Accelerated KVM guests on WSL2» until you reach the section titled Important note about building a module in WSL: Time was fairly tight for getting this up and running, I wasn’t going to be tweaking performance and I didn’t want to keep loading the KVM for Intel module manually, so:

Virtualisation options

KVM for Intel processors was selected as above, note that the AMD selection is below it.

  1. Carry on from «Exit the Virtualization» paragraph until you get to this command:


 kvm-ok


Enter fullscreen mode

Exit fullscreen mode

If you’ve followed the steps carefully and hit all the pre-reqs when you execute kvm-ok you should see:



INFO: /dev/kvm exists
KVM acceleration can be used


Enter fullscreen mode

Exit fullscreen mode

If not you are likely to see:



INFO: Your CPU does not support KVM extensions
KVM acceleration can NOT be used


Enter fullscreen mode

Exit fullscreen mode

If you are seeing the above you are definitely running a Windows 10 Dev channel, run back through the steps once more, you might have missed something.

  1. Check nested KVM is OK

If you’re getting «KVM acceleration can be used» you can proceed with the steps in the post.

The next steps is:



cat /sys/module/kvm_intel/parameters/nested


Enter fullscreen mode

Exit fullscreen mode

When executing this command N was being returned. Having traced back through the steps it was time for a search which yielded an issue from the WSL github repo. So reverting back to the step Install your kernel in WSL 2 and enable nested KVM the .wslconfig was changed to:



nestedVirtualization=true
kernel=C:\\Users\\<username>\\bzImage
debugConsole=true
pageReporting=true
kernelCommandLine=intel_iommu=on iommu=pt kvm.ignore_msrs=1 kvm-intel.nested=1 kvm-intel.ept=1 kvm-intel.emulate_invalid_guest_state=0 kvm-intel.enable_shadow_vmcs=1 kvm-intel.enable_apicv=1



Enter fullscreen mode

Exit fullscreen mode

You’ll need to restart WSL once more and check the command once more.

Note the command line args are almost identical to those added to kvm_intel.conf, I haven’t investigated why the nested setting isn’t picked up from the conf file.

Also note that setting debugConsole opens up the WSL debug console, you can turn this and pageReporting off later by removing them from the .wslconfig file and restarting WSL. I left it in for a while in case I needed to troubleshoot further.

The check for nested KVM now returned a Y as required:



cat /sys/module/kvm_intel/parameters/nested
Y


Enter fullscreen mode

Exit fullscreen mode

  1. Config X for WSL2.

Having run a far few X servers in the past I just wanted something that just worked without a lot of setup. Therefore, I went for X410 which is £9ish in the Microsoft store, but as I’m planning to use this until GUI support comes out later in the year, it was worth the price for the easy setup.

Install as normal in the store then add the environment variable in the steps to your .bashrc:



cd ~
nano .bashrc


Enter fullscreen mode

Exit fullscreen mode

Add DISPLAY environment variable to .bashrc

Once nested KVM is up and running and you’ve configured WSL to send X output to windows, you are ready to try a distro. If you keep following the post at this point you’ll set up an Ubuntu 20.10 daily build. I ran through this as a check to see if everything was working, the steps for this were exactly the same as in the post.

  1. Setup for MacOS VM

The MacOS-Simple-KVM GitHub repo is linked from the original post. It is described as «set up a simple macOS VM in QEMU, accelerated by KVM.» If you ran through setting up the Ubuntu 20.10 daily build in step 4 you’ll already have seen QEMU being mentioned. You might be thinking, why are there two types of virtualization technologies? The key part is in how KVM and QEMU differ, which is summed up nicely in this post. KVM uses the CPU virtualization extensions for Intel and AMD, and QEMU is performing the virtual hardware emulation, or to put it another way, KVM is QEMU’s «go faster stripes»!

The steps were followed as listed but with the following tweaks. First clone the git repo in, make sure to use the linux filesystem as it is faster at the moment on wsl2 than windows (/mnt).

This walkthrough is using Ubuntu so it’s the top line to install QEMU, Python and Pip if you haven’t already got them:



sudo apt-get install qemu-system qemu-utils python3 python3-pip


Enter fullscreen mode

Exit fullscreen mode

Run jumpstart.sh to fetch the MacOS media of your choice:



./jumpstart.sh --mojave


Enter fullscreen mode

Exit fullscreen mode

I also went with Mojave.

Now create a hard disk, I went with 32GB, I wanted to try and go a little lower but on investigation I found some issues logged where less than 32GB looked to be creating issues for other users:



qemu-img create -f qcow2 MacOS.qcow2 32G


Enter fullscreen mode

Exit fullscreen mode

Note I’ve changed the name of my disk, by this point I had a few VM’s setup so wanted to make it more obvious!

Edit basic.sh to add the VM disk into the VM :



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


Enter fullscreen mode

Exit fullscreen mode

Now make sure the X server from step 4 is running as QEMU will try and use graphics mode by default. If it isn’t running when you run basic.sh in this next step it’ll have for a minute or so then fail:



./basic.sh


Enter fullscreen mode

Exit fullscreen mode

The VM boots but there are some errors:

Errors running basic.sh

The top section boxed in red is caused by the -cpu line in basic.sh. The standard settings in the basic.sh file are sending instructions around performance enhanced features to the host CPU which it cannot understand. The box in green are errors related to sound, I’m not so worried about those, and explain my sound related issues with Ubuntu above. You can edit basic.sh further to straighten these out, but the VM still booted with these errors present.

The VM boots to the Clover boot manager, where you can use your keyboard to hit return (no mouse at this point) and «Boot macOS Install from macOS Base System» will begin:

Clover boot manager

The macOS utilities screen is now displayed and you should have mouse support. If your mouse pointer is out of synchronisation with the one on the VM you will need to adjust the settings in the basic.sh file. Shut the VM down using the apple icon top left and edit basic.sh in nano once more:

Setting the usb device to tablet

The usb device line needs to be altered from usb-mouse to usb-tablet. Run basic.sh once more and your mouse should now align.

As mentioned in the steps from the macOS-Simple-KVM instructions, you need to partition the disk first. If you enter Disk Utility, find your QEMU HARDDISK from the left hand menu and Erase it and partition it.

You can now return back to the macOS Utilities menu and choose Reinstall macOS, from here it is the same as a standard reinstall, this does take quite a while! No further tweaks were required from this point on:

Install complete

You can move in and out of fullscreen with ctrl+alt+backspace and remove the VM banner with «Machine View» at the top with ctrl+alt+F.

If you now leave your setup as-is with no further tweaks you will be sent into the Clover bootloader each time you reboot or run your VM:

I’ve got a few more options to choose from than you will have as I’d been playing around with things before I took this. The key thing is you need to use the arrow keys to choose «Boot macOS from macOS», this will boot your install and you are good to go!

Are you looking to run macOS on your Windows machine? If so, using QEMU could be your best option. In this detailed guide, we will navigate through the process of installation, its benefits, and some troubleshooting tips, all while ensuring you achieve the best performance possible. Let’s delve into the world of macOS virtualization on Windows! #macOS #Windows #QEMU #Virtualization

What is QEMU?

QEMU is an open-source machine emulator and virtualizer. It allows users to run multiple operating systems simultaneously on a single machine. This means if you’re running Windows, you can also run macOS through QEMU, making it a great tool for developers or anyone wanting to experience macOS features without purchasing Apple hardware. #QEMU #Virtualization

Why Use QEMU to Run macOS on Windows?

The reasons for using QEMU to run macOS over Windows include:

  • Cost-Effective: You do not need to invest in a Mac hardware.
  • Flexibility: Easily switch between operating systems.
  • Development Testing: Test cross-platform applications without needing separate devices.
  • Educational Purpose: Learn how macOS works without investing in Apple hardware.

System Requirements

Before setting up macOS using QEMU, ensure your Windows system meets the following requirements:

  • Minimum of 8 GB RAM: More memory will enhance performance.
  • Processor with Virtualization Support: Ensure your CPU supports virtualization (Intel VT-x or AMD-V).
  • At least 50 GB Free Disk Space: For macOS installation and files.

Step-by-Step Installation Guide

Step 1: Download Required Software

To begin, you will need to download several tools and files:

  1. QEMU — the latest version will ensure compatibility and performance.
  2. macOS ISO file — you can obtain this through various means, but ensure it’s a legitimate source.
  3. OpenCore or Clover — bootloader to help configure the macOS installation.

Step 2: Install QEMU

Once downloaded, install QEMU by running the setup file and following the installation instructions. Make sure all necessary components are installed for optimal performance.

Step 3: Preparing the macOS ISO

Now, prepare your macOS ISO file. Sometimes, it needs to be modified to ensure compatibility:

# Example command to convert the disk image (optional)
hdiutil convert /path/to/macos.iso -format UDRW -o /path/to/macos.img

Step 4: Setting Up QEMU for macOS

Now, it’s time to set up QEMU to run the macOS system. You will create a command script to initiate QEMU with the right parameters:

qemu-system-x86_64 -enable-kvm -m 4G -smp 4 \
-machine q35,accel=kvm \
-cpu Penryn,vendor=GenuineIntel \
-usb -device usb-tablet \
-drive format=qcow2,file=macos.img \
-netdev user,id=mynet0 -device virtio-net-pci,netdev=mynet0 \
-device ide-drive,bus=ide.0 \
-drive file=macos.iso,media=cdrom \
-boot d

This command initiates QEMU with:

  • -m 4G: Assigns 4GB of RAM to the virtual machine.
  • -smp 4: Uses 4 CPU cores.
  • -enable-kvm: Enables KVM for better performance.

Step 5: Booting macOS

After executing the script, you should see the QEMU window opening and request to begin the macOS installation. Follow the on-screen instructions to complete the installation process.

Troubleshooting Common Issues

Here are some common issues you may encounter when installing macOS via QEMU and their solutions:

  • Boot Loop: Ensure that you are using a compatible macOS version and that your QEMU settings are correctly configured.
  • Slow Performance: Allocate more RAM and CPU resources to QEMU, and ensure your Windows system is not running unnecessary applications.
  • Black Screen: Verify the integrity of your ISO file and use the correct display settings in QEMU.

Performance Tuning Tips

To ensure optimal performance while running macOS in QEMU, consider the following:

  • Use VirtIO Drivers: They drastically enhance performance for disk and network operations.
  • Allocate Adequate Resources: As mentioned earlier, provide sufficient memory and CPU cores to your virtual machine.
  • Regular Updates: Keep QEMU, your OS, and any drivers updated for the best reliability.

Conclusion

With this guide, you should be able to successfully install and run macOS on your Windows machine using QEMU. Advocating this method not only saves costs but also flexibilities in usage, especially for developers and tech enthusiasts. Remember that while this method serves many, it may not replace the full experience of genuine Apple hardware. Enjoy your macOS adventure! #macOS #QEMU #Windows #TechTips


Remember to leave us a comment or share your experience with running macOS on Windows using QEMU. What challenges did you face? What tips would you add? Let’s continue learning together! #MacOsOnWindows #QEMUGuide

Понравилась статья? Поделить с друзьями:
0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Как менять иконки в windows 10
  • Как удалить пин код для входа в windows 10
  • Windows 2008 install snmp
  • Pinnacle studio под windows 7
  • Подготовка к настройке windows не выключайте компьютер server 2012