This will start qemu in 64 bit mode. “-hda osx.img” should be the name of the image file you created above. “-cdrom iPC OSx86 10.5.6 Universal PPF5 (Final ).iso” should be the full path to your installation iso. “-m 2048” is how many megabytes of memory you want to make available to the system. “-soundhw ac97” is used to. Check if the CPU has the support of hardware for virtualization. On Intel, the processor is Intel VT.
It is possible without too much difficulty to get OS X Leopard running as a guest in a virtual machine with Linux as the host without too much difficulty. It is illegal as far as I know unless you have Linux running on real Apple hardware and don’t want to reboot just to use OS X but if you’re in this boat you can also use Virtual Box which officially supports OSX guests on Apple hardware. If you don’t have Apple hardware you’re only option is qemu and now it’s possible with having to manually patch qemu.
An ISO of OS X
Recent version of Qemu.
A processor with virtualization technology, AMD-V or Intel VT-x capable. I’m not sure if it is technically required but it certainly helps.
Lots of Ram and disk space.
iPC is one of many “distributions” of OS X for non-Apple computers, and is a computer you can get in stores as Computers R Us online. Check the iPC site for more information on using it. You won’t find any download there though, you’ll have to find a more creative source.
First create an image file to hold the installation.
This creates a 20 GB image file osx.img in raw format. Specify more GBs if you will want more space but I wouldn’t do any less then 10GB.
Start Qemu with the new image file and your installation ISO.
This will start qemu in 64 bit mode. “-hda osx.img” should be the name of the image file you created above. “-cdrom iPC OSx86 10.5.6 Universal PPF5 (Final).iso” should be the full path to your installation iso. “-m 2048” is how many megabytes of memory you want to make available to the system. “-soundhw ac97” is used to emulate the ac97 sound card which is supported by OSX. “-boot d” is used to tell the system to boot of the cdrom first.
If all goes well you should see this message:
Pressing any kill should bring up the language selection menu:
If you don’t and it just stalls at the Apple logo. Try using F8 and then -v to startup with diagnostic messages. That might give you some clues as to what’s going on.
Click next and continue. Then accept the software agreement. Then it asks, “Where do you want to install Mac OS X?” and gives you a blank list of possible installation locations. This is because the image file has not yet been formated. Choose “Utilities” from the top and “Disk Utility”.
Select “QEMU HARDDISK”, choose “erase” from the top and click the “erase” button twice.
The disk image is now formatted so close the Disk Utility. You should not have a destination avaliable to install OS X too. Select it and click “continue”. It is very important that you customize the installation on the next screen so you can install the proper drivers.
It’s very important that you select the 9.5.0 Voodoo Kernel or you will be unable to boot your new system. You will need the LegacyAppleIntelPIIXATA under chipset drivers or your hard drive will not work.
For audio drivers select AC97 Audio which is under Other Audio Drivers. For Ethernet select PCGENRTL8139. If you want to try to get usb to work you will need the Patched USB drivers. Also the responsiveness of the mouse and keyboard can be improved by selecting the PS/2 Keyboard FIX under the fixes section.
Click “Done” and “Install”. Then in about 20 minutes you should have a working OS X installation.
Upon reboot you get a welcome screen asking for the region your in. The rest of the setup is pretty straight forward. You don’t have to register with Apple. Be sure to choose DHCP for network setup. Upon completion you’ll see the beautiful Leopard desktop.
Networking in OS X on qemu has been rather tricky to do but following these directions makes it pretty simple. Close QEMU by shutting down OS X. Modify the qemu command to this:
The magic here is the “-no-kvm-irqchip” which disables a certain accelleration function that causes problems with networking being very slow in OS X. “model=rtl8139” is chosen because that’s what we selected during installation. “-smb $HOME” is used to allow file transfers between the host and guest operating system.
To share files open finder. Choose Connect to Server… from the “go” menu. Enter “smb://10.0.2.2” in the server address. Choose “Connect as Guest”. Choose a volume and then it should mount it on the left side of the finder.
If sound doesn’t work try installing the following updated driver.
Qemu ICH AC97 Audio Driver
If you want to take advantage multiple cores you can use the option “-smp 3” which tells qemu to make 3 cores available to the guest machine.
Occasionally the system crashes. It seems to happen most often when I’m downloading large files such as Xcode.
I first learned about libvirt
and QEMU
three years ago when I wrote a guide on how to virtualize macOS on a Linux system. Today I will be showing the opposite, virtualizing Linux on macOS using the same tools. I was surprised that with so many software developers using MacBooks everyday, nobody has created a guide on how to use libvirt
and QEMU
with macOS.
Why is libvirt
and QEMU
better? First of all, it's free and open-source. Unlike Parallels Desktop and VMWare Fusion, you won't need to pay for expensive subscriptions or manage licenses. There does exist an open-source alternative (from Oracle!) called VirtualBox, which works pretty well. However, VirtualBox does not support macOS's Hypervisor.Framework, a virtualization API created to limit kernel modification. This means the installer will ask for admin access to install kernel extensions, a feature Apple is now phasing out for security reasons. QEMU
on the other hand has had support for Hypervisor.Framework since 2018. Just say no to kexts!
Furthermore, like many developers, I like to run VMs headless, i.e. without a desktop GUI, so that I can SSH into them. Running VMs in the background seems like a simple feature, but it requires a lot of complex configuration for both VirtualBox and VMWare Fusion. And Parallels wants you buy the Pro Edition to gain access. Market segmentation at its finest... With libvirt
, VMs start headless. Plus, when you shutdown macOS, it sends a shutdown signal to your VMs as well.
To be clear, this method doesn't support USB Passthrough, GPU Passthrough, or bridge networking. But if you just need to test, for example, node.js or nginx on a Linux VM, then this method is great.
brew install qemu gcc libvirt
.brew services start libvirt
. It will start after boot as well.There are two ways to access the virtual display of the VM, either using a VNC client or the virt-viewer program. I recommend RealVNC Viewer. The VNC client is responsive and quick to install, but if you have multiple VMs you need to manually manage the different ports. With virt-viewer, you get a popup with all the VMs currently running, but it is laggy and takes an eternity to install. virt-viewer can be installed through homebrew. The rest of this guide uses VNC.
Create a vms
folder in your home directory, and generate a disk image. Change 50g
to the size of your prefered disk:
Download the Ubuntu Server 20.04 Install Image and my libvirt XML template and place the .iso and .xml files in the same folder.
Modify the following elements in the ubuntu.xml
file to match your your VM preferences and file paths. Save, then run virsh define ubuntu.xml
followed by virsh start ubuntu
.
Start RealVNC Viewer and connect to localhost
. Click the Ctrl+Alt+Del
button to reboot the machine, and quickly press Esc
to get into the boot menu. Press the number that matches the Ubuntu Server image.
Install Ubuntu Server normally, making sure to enable the SSH server. Once it restarts you can connect to the VM from your terminal by running ssh -p 2222 user@localhost
.
To send a shutdown signal to your VM, run virsh shutdown ubuntu
. To force shutdown, run virsh destroy ubuntu
.
To forward a port, e.g. port 443 from the VM to port 8443 locally, run the following: ssh -p 2222 -L8443:localhost:443 user@localhost
If you want to create multiple VMs, create an XML file for each machine with a unique UUID, VM name, and VNC port. Also, change the hostfwd
argument so that each VM exposes a different port for SSH, e.g. 2223
instead of 2222
. After you have defined them all, you can get a list of the VMs that are currently running with virsh list
.
Note: More discussion on Hacker News