Qemu Ubuntu For Mac

Today, a talented OS X enthusiast and TPP community member had Mac OS X 10.15 Catalina installed and working on a Hackintosh, just minutes after the Apple keynote ended. His secret to success where others failed was the Linux kernel virtual machine.

If you’d like to learn how to do this check out part one of our guide, and try asking around on our discord.

QEMU on OS X (macOS) hosts. While QEMU's main host platform is Linux, it is also supported on operating systems for Apple's Mac computers (known as OS X or macOS).The official support policy covers the last two released versions of OSX; QEMU might work on older versions, but it is not guaranteed and it might not even compile on older versions. For Mac developer, this meant a choice of VMWare or Parallels and now you can also use Linux with KVM / QEMU and Clover/OVMF. Here are the high level steps and instructions required to get macOS (OS X) up and running on Ubuntu with KVM / QEMU. Get Ubuntu running with virtualisation enabled Install KVM / QEMU software. Cdrom ubuntu-16.04.iso: Finally we told QEMU that we want to boot our ISO file “ubuntu-16.04.iso”. After you run the previous command, QEMU will start for you as a standalone window: Now, if you want to just boot from the image file without the ISO file (for example if you have finished installing and now you always want to boot the. QEMU is a fast, cross-platform open source machine emulator which can emulate a huge number of hardware architectures for you. QEMU, a generic open source machine emulator, it runs Cisco ASA, PIX and IPS. Then install macOS in that image using the '/usr/libexec/qemu-kvm' command in the original post. Then, download the Ubuntu 15.04 server installation image and boot the Virtual machine. I already downloaded the installation image and kept it in my home directory. To boot the Virtual machine, run: qemu-system-x8664 -hda ubuntu.img -boot d -cdrom /home/sk/SoftBackup/OS Images/New/ubuntu-15.04-server-amd64.iso -m 640. For 32bit VM, use.

Qemu Ubuntu For Mac

Virtually Unbeatable Catalina Install Time

Mac

A few minutes after 3:40 PM EST, Foxlet, an active TPP contributor and Hackintosh enthusiast, had the newest version of OS X running with 3d acceleration on a Ryzen system. Many others attempting this ran into issues, mostly related to Clover injection. The difference between Foxlet’s setup and the more ordinary configurations being used by others was Foxlet’s OS X install was virtualized. He offered logs of the recovery image downloads as further proof:

Qemu

Catalog dump showing the time that the Catalina index was archived by Foxlet’s machine.

Because qemu abstracts the base system and allows the user to define a much more OSX compatible environment than a baremetal install would normally allow, he was able to get it up and running in minutes instead of hours or days. He reported his success on twitter just minutes later:

If you're using macOS-Simple-KVM, the git has already been updated to support the new macOS Catalina beta! pic.twitter.com/EubcVMUOVj

Qemu ubuntu mac os x

— Foxlet (@FoxletFox) June 3, 2019

Shortly after Foxlet reported success on twitter, another TPP member had a working Hackintosh VM up and running:

let's see pic.twitter.com/WwED55uOGK

— dangered wolf (@dangeredwolf) June 3, 2019

Implications beyond OSX 10.15

The earliest reported baremetal Catalina Hackintosh was up and running 2 hours later, but this time delta demonstrates the practical utility of using a passthrough VM for OS X rather than running it on your hardware in more naive configurations.

The VM can be changed to be more friendly to new releases more easily than hardware can, and certainly faster than clover and/or kexts can be patched to accommodate more niche hardware. As Foxlet points out:

“It really does show KVM is pretty resilient when configured properly. Since kext injection was broken, a standard hackintosh would be left unable to boot as the SMC (FakeSMC) wouldn’t work. Not only does KVM let you run alongside Linux, but it lets you jump in the moment it drops.”

In other words, even if something does go wrong, you still have a functioning system layer you can use to look up info and troubleshoot without rebooting your machine or switching devices.

This utility would be somewhat diminished if you had to rely on software graphics acceleration. However, GPU passthrough, a technique that lets your VM communicate directly with a hardware GPU has been working on OS X guest machines for a while now, so you retain 3d functionality with this method of installation.

Considering the looming implications of the T2 chip, recent build quality problems and issues with baremetal Hackintosh installation on past releases, KVM might be the future for Hackintosh if you value convenience and compatibility.

Images courtesy Foxlet/DangeredWolf

Consider Supporting us on Patreon if you like our work. The site is and will always be ad-free, and we rely on direct support from our audience. If you need help or have questions about any of our articles, you can find us on our Discord. We provide RSS feeds as well as regular updates on Twitter if you want to be the first to know about the next part in this series or other projects we’re working on.

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.

Installing libvirt and QEMU

  1. First, install homebrew, which is a package manager for macOS.
  2. Run brew install qemu gcc libvirt.
  3. Since macOS doesn't support QEMU security features, we need to disable them:
  4. Finally start the libvirt service, with brew services start libvirt. It will start after boot as well.

Qemu Gui Mac

Installing Ubuntu Server 20.04

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.

Qemu Kvm Mac

  1. Create a vms folder in your home directory, and generate a disk image. Change 50g to the size of your prefered disk:

  2. Download the Ubuntu Server 20.04 Install Image and my libvirt XML template and place the .iso and .xml files in the same folder.

  3. 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.

  4. 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.

  5. 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.

  6. To send a shutdown signal to your VM, run virsh shutdown ubuntu. To force shutdown, run virsh destroy ubuntu.

  7. 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

Multiple VMs

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.

Qemu Ubuntu For Mac

References:

Qemu Ubuntu For Mac High Sierra

Note: More discussion on Hacker News