Home > Uncategorized > Virtualizing Mac OS X on Linux

Virtualizing Mac OS X on Linux

In my last post I wrote about virtualization. Here I’m going to introduce the world of virtualizing Mac OS X (Apple’s operating system) on linux.

Why would anyone want to run Mac OS X on virtual machine? Many reasons. Some people buy Apple’s computer but prefer linux as an operating system. However they still use from time to time native OS X applications such as iTunes. It makes perfect sense to load virtual OS X instance only when needed. Another reason might be testing new releases of OS X, software updates, etc… but the main reason, I believe, is software developers who want to develop iphone/ipad applications but don’t own Apple computer.

Before I proceed, I have to say a few things about Apple’s behavior and some legal issues as well. Imagine, that in order to develop windows application you’d have to buy computer from Microsoft. You would also have to run windows operating system and use Microsoft’s development environment only. In order to test your application outside the development environment, you’d also must register as Microsoft developer (99$ fee). When you finish developing, you’d have to submit your application to Microsoft’s store, and wait for approval. Microsoft, on it’s end doesn’t obligate to approve or disapprove your application in a given period. If your application does get to the Microsoft store, they keep the right to get it off whenever they feel like changing policy, and then no one would be able to get your application anymore.

If it sounds right, stop reading now. You better off to billy’s blog. but seriously, if Microsoft would have done it, they would have been long gone because people need their freedom of choice. That’s why we have regulation authorities. Replace every ‘Microsoft’ with ‘Apple’ and you get today’s reality. That’s how Apple treats iphone/ipad developers. Total disrespect.

If that’s not enough check out these legal notes: it’s illegal to use iphone applications that haven’t been signed by Apple (jailbreaking), it is illegal to use OS X copy that you don’t own, and even if you do, it’s illegal to use it with non-Apple computer. Of course, you can’t submit applications to Apple’s store unless you use their development tools. So, not only they don’t provide alternatives, but they made them all illegal. Well, almost. If you own Apple computer and OS X copy, you can legally use linux on it, develop apps with your tools of choice, and use OS X under virtual machine to submit them!

Sounds good ? Things aren’t that simple. Mac OS was never designed to operate on general hardware, definitely not under virtual machine. Until 2005, it could only work with PowerPC processors (the traditional Macintosh you maybe know). Since 2005 Apple added support for Intel processors which are very widespread in home computers, but still OS X would only work with very specific hardware. One particular device it needs is SMC, which has role in Apple’s “binary protection” (Apple’s attempt to prevent OS X from running on non-Apple intel computers).

To make it work, we have two options: modify the OS X operating system so it would work with our hardware, or emulate Apple’s hardware in our virtual machine. Both have been done by different people. I think the second option is preferred because that way we can use Apple’s retail software directly, no patches or modifications needed. However, it is far less common. The common option is modifying OS X, probably because many people want to install it as operating system on their non-Apple intel computer, while second option applies only in context of virtualization. Another reason might be that virtualization platform makers have no interest in that kind of emulation, specially with all the legal issues.

I planned this post to be comprehensive “How-To” guide but I realized each computer is different and my instructions probably wouldn’t work on yours. Instead, I’m going to review the different methods to virtualize Mac OS X on linux. If anyone need technical help I’d try to help.

Before I start, a brief overview of common virtualization platforms for linux:

Vmware. Very mature, commercial platform. Probably the leaders at the industry. You can get “vmware player” for free but it has no use for our purpose. Anyway, my hardware virtualization isn’t supported by them so I didn’t test it at all.

VirtualBox. Started as part of Sun xVM, Sun’s x86 virtualization solution. I checked it when it just got out. Compared to vmware it wasn’t mature. However, I checked again lately and I was impressed. Maybe Oracle’s acquisition did some good… it is very user friendly, has great performance. The product comes in two editions: VirtualBox PE, under proprietary license, but free for personal use and VirtualBox OSE, the open source (little less featureless) edition. The open source part is important because it can potentially be patched to emulate Apple’s hardware and run retail (non-modified) Apple software. I couldn’t find anyone tried doing that, though.

KVM. Kernel Virtual Machine. Created by Qumranet which acquired by RedHat at 2008. It doesn’t actually perform emulation by itself. Instead it extends kernel functionality, exposing interface that can be used by other (user space) programs such as Qemu. The two dovetail together. It is open source, which means, again, can be patched for our needs. In fact, Alexander Graf did patch it to run OS X natively!

XEN. Doesn’t run under linux. It is open source “hypervisor” that runs directly on hardware (just like operating system) but it’s not really operating system, it’s a thin software layer designed and dedicated for the sole purpose of virtualization. So, it is not useful for a desktop user such as myself but I had to mention it since it’s theoretically (maybe practically) can be used (with or without patches) to virtualize OS X. I just never went down that road.

Method 1: Virtualizing modified Mac OS X
Since the operating system is modified to work with general hardware, it can be used with any virtualization platform. I tried only with VirtualBox and KVM (explained why in the section above). You can find all about those modified versions and installation guides on OSx86 portal. The most common releases are iPC, iDeneb, iAtkos. Please don’t ask for download links. Get them from your favorite illegal software provider. You can find modified “leopard” (OS X 10.5.X), as well as “snow leopard” (OS X 10.6.X). All come in different sizes and shapes, differentiated from each other by the patches they provide. The installation process is somewhat tedious and requires lots of patience. You boot your virtual machine from the modified OS X cd, choose target hard disk, carefully choose patches to be applied and wait until installation finishes. There could be PLENTY of reasons why you wouldn’t be satisfied with your installation, from endless boot errors to unrecognized or recognized but improperly functioning devices. When it happens you can just go through the installation process again, choosing different patches or try to manually apply different patches, or try another modified OS X version. I spent days (not kidding) trying to achieve the ultimate virtual machine (performance-wise and functionality-wise), making those installations over and over, trying different patches and virtual machine settings.

Method 2: Emulating Apple’s hardware
The closest emulation I could find was Alexander Graf‘s KVM-Qemu patches. It’s close because it allegedly emulates everything you need: processor model, ide chipset, network interface, smc, bios, etc… but installation doesn’t work out of the box. So instead retail OS X installation, I started with iDeneb, selecting no patches at all. The basic operating system worked, but had some issues. I had to change KVM settings to make the networking work and install iDeneb’s patch to get rid of the mouse lag. USB devices were recognized by “usb prober” but weren’t usable.

The SMC device contains two keys (OSK0, OSK1) being used to decrypt system binaries (aka Apple’s binary protection). To emulate it, you have to know these keys. The patched KVM gets these keys from -osk parameter. How would you know your keys ? Assuming you legally own genuine Apple computer, you can extract them from your real SMC using Alexander’s script getkey (for old hardware) or mackey.c (for new hardware, you have to compile it first, though).

VirtualBox vs. KVM
As you understand, I tried both methods with VirtualBox and KVM (method 2 with KVM only). For reference, most of the time I was installing iDeneb 1.5.1 (OS X 10.5.7) on VirtualBox PE 3.1.6, and KVM 0.11.0 (initially original and eventually Alexander’s patched version). I always gave it 512MB of RAM. My operating system is Ubuntu 9.10 (karmic) 64 bit running on AMD Athlon(tm) 64 X2 Dual Core Processor 4400+. Here are my conclusions (comparing the best results I got from each platform):

  • Overall experience – VirtualBox is very user friendly and in most aspects I found it a little better than KVM although it’s not perfect.
  • Responsiveness – VirtualBox mouse responsiveness and graphics smoothness maybe a little better but not significantly. It’s based only on feeling.
  • Audio – I couldn’t get it working with either of them, although I didn’t try too hard. I read somewhere that it’s impossible with VirtualBox, because it emulates sound card that is too old. On KVM I might have succeeded if I tried harder.
  • Networking – I tested simple ftp file transfers between guest (OS X) and host (linux). It took more time to get it working on KVM. On both platforms, I got it working at up to ~13-14 MBps. Misconfiguration on VirtualBox (using KVM’s bridge interface) rendered the system completely unresponsive, transferring at ~3 MBps.
  • USB support – KVM got the devices recognized (by usb prober) but for some reason they weren’t usable by Finder/iTunes. VirtualBox got them working out of the box.
  • Other – With VirtualBox, I couldn’t get the keyboard working during boot phase. It has serious consequences because if the operating system gets broken or for some reason need manual boot params, I wouldn’t be able to provide them. EDIT: The keyboard works with Chameleon v1.0.12 bootloader.

Final words
I hope you enjoyed this post and have better understanding of OS X virtualization. There is a lot of room for further developments to the point everything would work out of the box. Until then, you can find plenty of “How-To” guides promising installation of OS X on your PC/virtual machine. Remember, retail Mac OS X can not run natively on your PC. On your virtual machine- as long as there won’t be 100% Apple hardware emulation there would still be hardware dependent parts, which might not work with yours.

One last thing… don’t break the law.

Share and Enjoy:
  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Yahoo! Buzz
  • Twitter
  • Google Bookmarks
  • Slashdot
  • email
  • Print
  1. Pavel
    April 11th, 2010 at 16:56 | #1

    Just get OS X on your hardware. It is much better than virtualized one. Actually thinking on switching to OS X SL as primary OS…

    • April 11th, 2010 at 17:31 | #2

      Well, linux is my favorite and I don’t really need anything from OSX except maybe Xcode… but be my guest, give it a try (call me if you need any help)

  2. CCH
    June 17th, 2010 at 17:28 | #3

    this tutorial helps me a lot~

    actually I’m implementing the method 1 with KVM in ur survey above and having some driver-patch trouble(what u just happened).
    I tried 3 distribution(iPC 10.5.6, iATKOS v7, and iDeneb v1.6) before and only one of them works(iPC), in addition, I also met some issues such as “About this Mac” causes screen reload problem, no network problem, and no sound problem.

    I follow the instruction on this page:
    http://www.insanelymac.com/forum/index.php?showtopic=124427

    And, these are my HW of guest emulated by qemu(I don’t know what version it is, what I know is I use Debian AMD64 Lenny as host and use apt-get to download the whole kvm-qemu workspace), this info dumped from the windows 7 quest with everest:
    cpu: 2x , 2800 MHz (5 x 560)
    chipset: Intel Natoma 82440FX
    vga: VGA d (4 MB)

    From your experience, I must do a lot of try-and-error to get (or never get) what I want. so, can you give me a little hint about what patches should be choosed and what shoudn’t.

    this is the patch list:
    http://macyourpc.com/wp-content/uploads/2009/03/ipcppf5packagelist.png

    still, I have to say thank you, this tutorial really corrects some concepts of mines :)

    • June 18th, 2010 at 00:03 | #4

      Well, as said all the patches that worked for me are probably irrelevant for you. If I remember correctly I used ICH6 fix, PS2 keyboard fix, something with USBFamily and Voodoo kernel… and chameleon boot loader (otherwise the keyboard wouldn’t function on boot). What I DO remember is that was hell… :)

      If you need help with other stuff just ask

  3. Karl
    September 17th, 2010 at 21:31 | #5

    Great, thank you!

  4. iPAS
    February 16th, 2011 at 10:34 | #6

    Thanks for sharing. I found out something weird since install iDeweb in Virtual-Box v.3.2.12 last year. It’s about monitoring screen that show over real screen on my Ubuntu system.

  1. No trackbacks yet.