How To Use QEMU on Mac OS X

by Mike Levin SEO & Datamaster, 07/28/2010

Note: You can instantly download and start playing around with QEMU and Linux on Mac OS X using my own respin distribution of Linux called Levinux. <– Visit this page and download it!

Welcome everyone searching for qemu on the Mac. Let’s get it out of the way: this article is about Q, the still-viable, but rapidly becoming out-of-date version that takes advantage of Mac’s user interface, and my experience getting it working and dissecting the way it can package stand-alone copies that don’t require installing the whole package. My goal was to (accomplished) make the same stand-alone virtual machine run with a double-click and no install from the desktop of either Linux, Mac or Windows.

Mission accomplished.

[caption id=”” align=”alignright” width=”300”]USB flash drive (Disposal) Image via Wikipedia[/caption]

I took my work home last night to test the portability of this QEMU virtual computer to my iMac. It worked like a charm. I carried my QEMU folder on my keychain USB drive and popped it into my Mac and copied over the folder, installed some software, created a new configuration, and fired up the VM.

This post will cover that process, and how to hack a Mac OS X bundle or package to execute the precise QEMU command that we need. In short, everything worked fine up until the point of making it a dependency-less carry-around “file”.

The idea now is that I will make one folder from which I can click one icon to fire up the VM on the Mac, and a different icon to fire up the VM on the PC. Either way, it’s the identical VM running. It’s just that the Mac and PC have different ways of launching programs, so there will be two icons.

To this end, I’m copying the files over to the Mac to do some setup work, but plan on copying the files back onto the USB drive, and then forever forward run it directly from the USB drive.

The advantage to running the virtual computer directly off the USB drive, albeit a bit slower, is that there will only ever be one master instance, and all changes I make, whether from home on my Mac or from work on my PC will be to that master harddisk.raw file. I will never be “forking the code” so to speak, with file copying. The trick is to make one folder that has everything necessary for both platforms, without so much as requiring pre-installed QEMU software. You can indeed sit down at any modern PC or Mac, pop in your drive and fire up your virtual machine, to pick up working right where you left off, without having machine admin privileges or needing to install anything.

To put this in perspective with the greater mission of this Shankserver website, the resulting USB drive is indeed your virtual instance of a shankserver. Some might think that the Knoppix LiveCD would be a better example of a “server” to pull out of your pocket, but I advocate not even having to reboot the machine you sit down at in order to have your server magically materialize. Instead, if you have access to the USB port of any modern Mac or PC, you’ve got a server.

Time to roll up your sleeves. It’s harder on the Mac than on the PC.

The next step is to download the customized version of QEMU for the Mac called Q ( http://www.kju-app.org/ ), which provides a user interface. Be sure to get the nightly build, or else you will get a ton of errors during boot-up. I made that mistake at first, and it’s tough to track down the problem. It’s easy to suspect a wrong Linux kernel. It’s not. It’s an old copy of Q. Get the latest, which at the time of this writing is Q-0.9.1d118 - 10.2mb.

This brings up an interesting point. QEMU as an open source project is distributed primarily as un-compiled code. The official site at wiki.qemu.org doesn’t even give out pre-compiled packages for PCs and Macs. Instead, you have to go to it’s “links” page, and then you will find some shady Japanese anime-looking page named TAKEDA Toshiya under Unofficial QEMU binaries for the Windows version, and a marginally less shady site labeled Q repository (Mac OS X port) under Alternate QEMU repositories. THAT’S the link you want to follow for this program.

So download it, and double-click the .dmg file, but DON’T drag it to your Applications folder. The idea is that we’ll be deleting it from your system momentarily anyway.

Double-click the Q program in-location. In the interface that pops up, hit the Yellow plus sign to Create new Guest. I used the word Debian for my guest. Hit Create PC.

It’s not critical, but I like to disable file sharing and the CD-ROM. This is just for a run-once test anyway. We’ll be overriding all the QEMU parameters that this is controlling. This is just to do a test to get it running on the Mac before being bundled up. The important thing now is to choose your harddisk.raw file.

Okay, now for the moment of truth. Was the selection of QEMU worth it? Is jumping through the hoops of not choosing VMWare, VirtualBox, or any of the other proprietary ones worth it for the tantalizing prospect of a truly portable virtual machine?

Click the little “run” icon in the Q interface. Here’s what I see…

And it finishes booting and presents me with the login prompt. Booyah!