Run vanilla Snow Leopard in a VirtualBox VM

Running (vanilla) Snow Leopard in a virtualbox VM is now a piece of cake.

If for some reason this doesn’t work (like, you don’t have a compatible processor) you might try

instead.

What you’re going to need:

  1. An Empire EFI ISO image. Download it from Prasys’ blog.
  2. An ISO image of Snow Leopard. (NOT a .dmg). Take an image of a retail copy, available from your friendly retailer.
  3. VirtualBox 3.2.6, which you can get from the VirtualBox website.

We’re going to set up the virtual machine from the command line once again. You’ll only need a total of 10 commands to get your VM installed and booted.

I’m assuming that your VM will be called “osx“. The base folder will be /vbox, you’ll store your ISO images in /vbox/iso and you’ll create a hard drive image for your virtual machine called “disk01.vdi“. These items are color coded below so you can see where you need to change them to suit your setup.

Virtual Machine initialization:

VBoxManage createvm –name osx –ostype MacOS_64 –register –basefolder /vbox
VBoxManage modifyvm osx –memory 1536
VBoxManage modifyvm osx –accelerate3d on –vram 32
VBoxManage storagectl osx –add sata –controller IntelAHCI –name “SATA Controller”
VBoxManage storagectl osx –add ide –controller PIIX4 –name “IDE Controller”
VBoxManage storagectl osx –name “SATA Controller” –hostiocache on
VBoxManage storagectl osx –name “IDE Controller” –hostiocache on
VBoxManage createhd –filename /vbox/osx/disk01.vdi –size 40960 –variant Split2G –remember
VBoxManage storageattach osx –storagectl “SATA Controller” –type hdd –port 0 –device 0 –medium /vbox/osx/disk01.vdi
VBoxManage storageattach osx –storagectl “IDE Controller” –type dvddrive –port 0 –device 0 –medium /vbox/iso/empireEFI.iso

Snow Leopard installation:

At this point, you can power on your virtual machine:

VBoxManage startvm osx –type vrdp

Note: I use vrdp because I like to run my VMs on servers, You can omit the “–type vrdp” and the reguar GUI will pop up.

At this point, the system will boot from the EmpireEFI image. You’ll see the chameleon logo and an image of a CDROM. Now you need to attach your Snow Leopard ISO to the Virtualbox VM:

VBoxManage storageattach osx –storagectl “IDE Controller” –port 0 –device 0 –type dvddrive –medium /vbox/iso/snowleopard.iso

Once you’ve done that, go back to the VM and hit the F5 key to rescan, Chameleon will pick up the Snow Leopard image. From here you can hit Enter and watch as the system boots into OSX.

At that point you can follow the regular OS X install procedure: Partition your drive, and let the installer run to completion.

Post OS Installation precedure:

Once the installer complete, you’ll see a message “Install Failed”.  Don’t panic, it didn’t really.  We just need to give it a helping hand.

Switch the EmpireEFI image back again:

VBoxManage storageattach osx –storagectl “IDE Controller” –port 0 –device 0 –type dvddrive –medium /vbox/iso/empireEFI.iso

Then reboot:

VBoxManage controlvm osx reset

Once this happens, you’ll see Chameleon come up with two choices to boot from.  Use your arrow key to select the disk you just installed OSX onto, and then type “-v” and hit enter.

OS X should boot (in verbose mode).  You’ll then be able to run through the account setup process, and eventually you’ll get your fresh, shiny OSX desktop.

Once you’re booted, you should run the “MyHack Installer”.  You can find an earlier version on the EmpireEFI CD in the folder “Extra/post-installation”. Since your networking already works, (assuming your host machine has internet connectivity)…

From the Virtual Machine, browse to http://blog.nawcom.com/?p=242 and download the latest, custom version (ready for 10.6.4 upgrade). Install the package and reboot.

Mac OS X running as Virtualbox guest – inside Opensolaris container.

With the release of Virtualbox 3.2 beta Mac OS X “guests” are now supported. 

The following guide will show you how to get OS X running inside virtualbox using the command line interface.  It applies to any host operating system, but in this case we’re adding an additional virtualization layer on top of opensolaris.

Officially, so as not to run afoul of the Apple EULA, if you want to run OS X as a Virtualbox Guest you need to be running Virtualbox on Apple hardware.

So, let’s imagine that instead of a nice, 64 core Intel nehalem server I actually have a Mac Pro on which I am – for the sake of argument and somewhat inexplicably – running Opensolaris.

Today we’re not only going to show you how to get Mac OS X running in Virtualbox, but also how to run it on Virtualbox running inside an Opensolaris container, or zone.  Just in case you had, for example, a need to add resource controls, or clone multiple versions of your resulting OS X virtual machine, teleport running VMs to another server…

You will need a copy of a modified version of the OS X install DVD.  If you search around you might locate something called “iDeneb_v1.6_1058_Lite_Edition.iso” which is what I used for this example.

If you don’t care about the Opensolaris container (or indeed the opernsolaris host OS) part of this tutorial, you can use the same sequence to run Mac OSX as a Virtualbox guest on any OS, provided you’ve installed the 3.2 beta version (or later).  You just need to ensure that whatever machine you’re using has a CPU that supports VMX.  Otherwise the OS X Install CD won’t load the Operating system properly.  (Other guests will be fine)

[Grab the beta here]

Click here to skip to the Mac OS X guest configuration section.

Step 1:  Create the opensolaris container

At the time of writing, I was using Opensolaris b133.  The bits I typed are in bold.

1.a.  Define a new zone.

root@nehalem:/# zonecfg -z vbox
vbox: No such zone configured
Use 'create' to begin configuring a new zone.
zonecfg:vbox> create
zonecfg:vbox> set autoboot=true

1.b.  Deciide where it will live.  In this case I chose /zones/vbox.

zonecfg:vbox> set zonepath=/zones/vbox

1.c Add some networking so that you can talk to the world. In this case I have ipmp set up for redundancy. Change to suit your actual network interface. Here, mine is ipmp0, and I’ve given it the address 1.2.3.4.

zonecfg:vbox> add net
zonecfg:vbox:net> set physical=ipmp0
zonecfg:vbox:net> set address=1.2.3.4
zonecfg:vbox:net> end

1.d.  This is the important part.  Add the two virtualbox drivers from the global zone. You can’t install devices in a container, so you need to make sure that the ones that the global zone uses are available to your container.

zonecfg:vbox> add device
zonecfg:vbox:device> set match=/dev/vboxdrv
zonecfg:vbox:device> end
zonecfg:vbox> add device
zonecfg:vbox:device> set match=/dev/vboxusbmon
zonecfg:vbox:device> end

Then all you need to do is create the zone.  This will take a few minutes.

zonecfg:vbox> commit
zonecfg:vbox> exit
root@nehalem:/# zoneadm -z vbox install
A ZFS file system has been created for this zone.
 Publisher: Using opensolaris.org (http://pkg.opensolaris.org/dev/ ).
 Publisher: Using contrib.opensolaris.org (http://pkg.opensolaris.org/contrib/).
 Image: Preparing at /zones/vbox/root.
[...]

Step 2:  Install the Virtualbox package.

This needs to be done in the global zone as well as your newly-created container.  So while our new container is installing, go ahead and grab the latest beta, and install it in the global zone:

root@nehalem:/var/tmp# pkgadd -d VirtualBox-3.2.0_BETA1-SunOS-r60785.pkg
The following packages are available:
 1  SUNWvbox     Oracle VM VirtualBox
 (i386) 3.2.0_BETA1,REV=2010.04.27.22.46.60785
Select package(s) you wish to process (or 'all' to process
all packages). (default: all) [?,??,q]:

Once that’s done and your new container is ready, boot it and you’ll need to install the exact same Virtualbox package in the container, as well as some other packages.

inside the new container:

root@vbox:/# pkg install SUNWuiu8 SUNWgccruntime
[.. output omitted ..]
root@nehalem:/var/tmp# pkgadd -d VirtualBox-3.2.0_BETA1-SunOS-r60785.pkg

At this point, we’re ready to create our Guest.  We’re going to do this using the command line interface, so this will work on any operating system.  It isn’t Solaris specific.

If you’re following along from the top, make sure you’ve logged into the Opensolaris container (use “zlogin <container>”).

You don’t need to be root.  Cut and paste the following lines, being sure to change the green parts as appropriate for your system.

[Note: Since this post was written creating a Snow Leopard capable VM is now a lot simpler.  If you have compatible hardware, you might be interested to check out this post instead. ]

VBoxManage createvm -name OSX -ostype MacOS_64 -basefolder /vbox -register
VBoxManage createhd ---filename /vbox/OSX/OSX.vmdk --size 10240
VBoxManage modifyvm OSX --cpus 8
VBoxManage modifyvm OSX --memory 8192
VBoxManage modifyvm OSX --usb on --usbehci on
VBoxManage modifyvm OSX --acpi on --ioapic on
VBoxManage storagectl OSX --name "SATA Controller" --add sata \
  --controller IntelAHCI
VBoxManage storageattach OSX --storagectl "SATA Controller" \
  --type hdd --port 0 --device 0 --medium /vbox/OSX/OSX.vmdk
VBoxManage storagectl OSX --name "IDE Controller" --add ide \
  --controller PIIX4
VBoxManage storageattach OSX --storagectl "IDE Controller" --port 0 \
 --device 1 --type dvddrive --medium /misc/iDeneb_v1.6_1058_Lite_Edition.iso

Now a well-known issue with earlier versions of Virtualbox was that if you managed to install OS X you might have the guest os complaining that no keyboard was connected.  Indeed, this is what happened to me.  In order to get a Mac OS X guest to run with a keyboard and mouse inside Virtualbox, you need to add the following lines to your configuration:

VBoxManage modifyvm OSX --mouse usb
VBoxManage modifyvm OSX --keyboard usb

Now you can go ahead and boot it up, and install Mac OS X.  You don’t need to change any package selections for the iDeneb CD.  Once you’re done just, reboot and voila!

VBoxManage startvm OSX --type vrdp

To access your OSX console, use VRDP.  Point your RDP client at the IP address you gave your container (or whatever IP address is running Virtualbox as the host if you skipped the Opensolaris part).

[ One thing worth noting - sometimes Mac OS X struggles if you give it more than 1 virtual CPU.  If this happens, set the number of CPUs to 1, and reboot and it should be fine.]