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)
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.]
Rich, are there specific hardware requirements for the installation to work this way? I’m trying to get it running on win7 64 bit with the 3.2.0 Beta. My cpu is an AMD Athlon and graphics card is a ATI xpress 1500.
I can install it but once it reboots I get the EFI shell where I can’t really do anything because it can’t find the hdd.
Not sure about AMD CPUs, but you could try modifying the controller the virtual HDD is attached to. Change it to IDE from SATA, for example.
Have the same problem as Chris above. I am using VirtualBox 3.2.0 release version running on Windows 7 x64, with Mac OS X 64 bit as guest. I used iDeneb, and it seemed to install fine. But after installation the virtual machine doesn’t see any bootable partition in the HDD. I have tried both MBR and GPT, but basically just get the EFI shell, as it can’t find a bootable HD partition.
Thanks for the write-up, this was an exciting experiment!
I did indeed run into a problem with two virtual CPUs but it was fine when I set it to one. However there is no sound, is that just me or is it normal?
Well here’s what I found out. Looks like my board doesn’t support EFI which would by why it can’t find the disks. Oh well…
Not sure about AMD CPUs, but you could try modifying the controller the virtual HDD is attached to. Change it to IDE from SATA, for example.
I’ve just come across this post. Thanks for writing it up. For some reason I can’t get VB to start in my zone I get a segfault when I run /opt/VirtualBox/VirtualBox.
I suspect it’s some package that’s required on the zone that I’m missing but I’m having trouble tracking down what that might be as the VB binary is setuid so truss will only run as root and I don’t get the segfault as root. All root does is return without doing anything.
I’m using Solaris Express 11 with VB 4.0 and I’m following this guide and the updated one with the details for running a plain OSX install.
To Answer my own post (in case run into the same issue)…
I’d installed Solaris from the live CD and then followed the instructions above to build the zone. For whatever reason (this is also my first “play” with Solaris 11 but have worked with Solaris since SunOS days), there were some packages not installed. I gained enough of a lead by a comment in the manual that there was a tool /opt/VirtualBox/i386/VBoxQtconfig that could be used for configuration. I found that also core dumped. As it was a simpler binary that wasn’t setuid, I was able to use ldd and truss to see what was missing and that lead me in the right direction.
In summary the commands that fixed it were:
sudo pkg install package/svr4
sudo pkg install runtime/python-26
sudo pkg install runtime/python-24
sudo pkg install x11/library/libxinerama
sudo pkg install x11/library/libxrender
sudo pkg install x11/library/libxfixes
sudo pkg install image/library/libpng
sudo pkg install x11/library/libxi
sudo pkg install system/library/freetype-2
sudo pkg install system/library/fontconfig
sudo pkg install x11/session/xauth
sudo pkg install xclock
sudo pkg install system/library/gcc-3-runtime
sudo pkg install libxevie library/libxscrnsaver font/xorg/iso8859-1 font/xorg/xorg-core font-utilities library/libfontenc library/libxfont xfontsel
This maybe more than was required, but these are my notes of what I’ve added to now have it working.
Richard, do you have any thoughts as to why I finished up with a minimal install? Maybe VB needs some deeper dependency checking.