Virtualising retail Mac OS X images on OS X with virtualbox

For testing changes related to OS X in pkgsrc I revisited trying to get virtual machines of the various releases of OS X running to improve test coverage. At present I’m confined to testing on Tiger and Mavericks though I also have machines running Leopard and Lion but they need setting up.
By default, it’s not possible to boot an instance of Mac OS X from a genuine install image, on a Mac host, running OS X using virtualbox.
Searching around reveals using modified images intended for building Hackintosh as the solution most people use. Virtualbox supports OS X guests but when following the usual steps in the wizard to create a new VM & pointing it to your unmodified OS image, nothing much happens.
Depending on the version of OS X you’re trying to boot you’ll either end up with a XNU hang/panic or just dropped straight to an EFI prompt.
Again, depending on the version of OS X being attempted the issue differs. I’ve managed to install 10.7 to 10.10 successfully on virtualbox so far. 10.5 & 10.6 remain to be done.

10.7 – Lion

With the release of 10.7, Apple changed the way OS was packaged, the digital distribution came with a disk image named InstallESD.dmg nested inside an application named Install Mac OS X Lion.app. It’s possible to use this disk image with virtualbox as-is without change however the system will not boot from the image because it fails a test by the boot loader to ensure the image is being booted on a genuine Mac. In my case it is, but unfortunately the cpuid virtualbox presents to the operating system is not one that the OS recognise & so it fails.
The solution to this is to tell virtualbox to mask the cpuid of the guest, unfortunately depending on the version of hardware? or virtualbox that you’re using you may have to experiment with which ID works. I first tried the ID 00000001 000306a9 00020800 80000201 178bfbff listed in the post by BitTorrent engineering but it did not work on a Mid-2012 MacBookAir5,1 with VirtualBox 4.3.22 r98236.
Searching around I found the ID 1 000206a7 02100800 1fbae3bf bfebfbff to try in a comment on another guide which did work.

To create a working VM of Lion in virtual
1) Create a VM in virtualbox named something, type Mac OS X, version Mac OS X 10.7 Lion (64 bit).
2) Before booting the VM, switch to Terminal and change the cpuid of the guest by running
VBoxManage modifyvm something --cpuidset 1 000206a7 02100800 1fbae3bf bfebfbff
3) Right click on Install Mac OS X Lion.app, select “Show Package Contents” and navigate to Contents/SharedSupport. Copy InstallESD.dmg to a locate on your disk which is navigatable.
4) Start the VM & when asked for an install disk, point to the InstallESD.dmg which you copied out in the previous step. The system should boot without any need for further modification (most guides recommend other changes such as switching to a PIIX chipset).

10.8 – Mountain Lion and newer

With Montain Lion, InstallESD.dmg was changed once again, this time to contain multiple partitions (EFI, Boot/Rescue, Install), unfortunately it’s not possible to boot these images successfully as the notion of multiple partitions is not applicable to media such as optical so what happens is that the system is able to boot from the disk image & load the kernel but unable to continue to load the install environment.
What needs to happen is a new “flattened” image needs to be generated which is on a single partition & contains everything from the boot partition.
There is no need to modify any settings for the VM such as cpuid as previous or chipset as recommended by other guides like Engadgets

To flatten the image a tool called iESD is used.
iESD can either be installed via gem(1) or if you’re a pkgsrc user, I’ve created a WiP package.

The instruction in the Engadget guide pretty much covers everything needed. Just make sure that the disk images are fully detached before issuing the hdiutil commands, quickest way being to open Disk Utility.app, selecting mounted disk images & pressing eject or checkout the output of hdiutil info & using hdiutil detach $devicename to detach all device names associated with the disk images.

6 Replies to “Virtualising retail Mac OS X images on OS X with virtualbox”

  1. So I got a Yosemite image set up, on a mac running yosemite – and it hangs partway into the boot unless I change the CPUid. Once I made that change, it boots into the installer. So, I’m not sure your “no changes are needed” is entirely true.

  2. The one where I had to change the CPUid is a mid-2014 macbook pro; however I just tried it on a mid-2010 imac, and I did _not_ have to change anything. So, there’s that. 🙂

  3. I’ve had no problem with Snow Leopard using the retail “upgrade” DVD and –cpuidset 1 000206a7 02100800 1fbae3bf bfebfbff.
    I can’t get Leopard to boot though as it hangs at the ACPI kext which leads me to believe I need to find a cpuid string for a core 2 duo such as “2.0 GHz (P7350) Intel Core 2 Duo” which was in the Early 2009 mac mini that shipped with 10.5.6 (so therefore the 10.6 DVD would recognise the older CPU).

  4. Oops I just realised my comment was all over the place. The CPUID string I need to find is for the core 2 duo such as “1.83 GHz (T5600) or 2.0 GHz (T7200) Intel Core 2 Duo” which was in the Mid 2007 Mac Mini that shipped with 10.4.10 (hence allowing my retail 10.5.0 DVD to boot). I have seen that “–cpuidset 1 000206a7 02100800 1fbae3bf bfebfbff” will work if you find a 10.5.8 DVD around.

    I’m going to be reunited with my 12″ powerbook soon so I won’t need to run a VM for some of that lovely tiger goodness.

Comments are closed.