Apple OS X virtualization with VirtualBox
A long time ago virtualizing Apple OS X was forbidden by the End User License Agreement, with the exception of Server versions of the operating system. Consequently Oracle (the maintainer of VirtualBox) was not very supportive, and many replies on the end user forum for VirtualBox still point to the then default answer.
Countless hackers spent endless nights to work around this issue, and thousands of posts offer tricks and step-by-step guides that are now mostly obsolete. Also, many of these refer to the process of virtualizing OS X on non-Apple hardware, which is illegal (so called “hackintosh”).
Two years ago, with OS X Lion (10.7) Apple started allowing users to run up to two additional instances of OS X on the same machine without a need for extra licenses. It took some time to the VirtualBox developers to pick up this fact and enhance their support for OS X guests, but with VirtualBox 4.3 released on October 15th, 2013 things start to be useable.
More precisely the following is a report on running Apple Max OS X 10.7, 10.8 and 10.9 as guests under VirtualBox 4.3.2 on a 10.7 host.
To create 10.7 and 10.8 guests, you need to extract the InstallESD.dmg from the restore image or from the installer downloaded from the iTunes store. There are step-by-step guides around to do that. You do not need to patch the InstallESD.dmg in any way.
Just go ahead and create a new VM with the correct OS type (i.e. Mac OS X) and version (i.e. Mac OS X 10.7 Lion (64 bit) or Mac OS X 10.8 Mountain Lion (64 bit)). Pick up all the default options or change RAM and disk sizes, then attach the InstallESD.dmg file to the VM’s CD/DVD.
Before you launch it, if you like you can prepare for setting the VM screen resolution to 1440×900 by executing these commands in a terminal of the host:
VBoxManage setextradata "OSX_108" "CustomVideoMode1" "1440x900x32 VBoxManage setextradata "OSX_108" "GUI/CustomVideoMode1" "1440x900x32" VBoxManage setextradata "OSX_108" VBoxInternal2/EfiGopMode 4 VBoxManage setextradata "OSX_108" VBoxInternal2/UgaHorizontalResolution 1440 VBoxManage setextradata "OSX_108" VBoxInternal2/UgaVerticalResolution 900
(these may well be quite redundant but they’re guaranteed to work).
The install process should be slower than on bare metal, but smooth with the exception of some occasional hangs on booting (just kill the VM and retry).
When you are done, remember to turn off energy saving (set timeout to “Never”) in the system preferences as recommended here.
To complete the procedure for setting the VM screen resolution to 1440×900, execute the command:
sudo vi /Library/Preferences/SystemConfiguration/com.apple.Boot.plist
in the guest operating system, and inside the
<dict> ... </dict>
section insert:
<key>Graphics Mode</key> <string>1920x1080x32</string> <key>Kernel Flags</key> <string>"Graphics Mode"="1920x1080x32"</string>
The matter with 10.9 is different because VirtualBox does not seem to be able to start the VM from the unpatched InstallESD.dmg, even if the correct OS version is chosen (Mac OS X 10.9 Mavericks (64 bit)). The method I used was to clone a 10.8 VM and launch the installer from there.
Mandatory screenshot: