UPDATE (2011-08-04)! If you installed OS X Lion and are having problems with “missing operating system” when you boot your virtual machine, it is because Lion installed a new recovery partition that re-arranged the partition numbering scheme. Replace any references to disk0s3 with disk0s4 and “-partitions 3″ with “-partitions 4″. That should get you up and running.
Just wanted to put all this out there so that hopefully other people can find it. I’ll need this again as a reference for when I set up my wife’s laptop as well!
Please note that anything documented here is how it worked for me on my laptop. If you have issues, look for any notes below. If you can’t find an answer, check Google.
As a last-ditch effort, you can comment here, but I don’t know if I will have an answer or not. Oh, and each line in the fancy code blocks below starts with #. That way it will hopefully make it easier to read if something is word-wrapped. I forgot I had a GeSHi plug-in installed. Ignore the strikethrough stuff.
First off, get VirtualBox. As of the time of this post, the current version is 3.2.4. Install it per the instructions. The easy part is done!
Now, open Terminal. You will need to make the Bootcamp partition accessible to VirtualBox. Run the following command:
sudo chmod a+rw /dev/disk0s3
Next, we’ll need to build a VirtualBox vmdk image:
cd /path/to/wherever/you/want/to/keep/files sudo VBoxManage internalcommands createrawvmdk -rawdisk /dev/disk0 -filename bootcamp.vmdk -partitions 3
And, finally, make the vmdk file accessible:
sudo chmod a+rw /path/to/bootcamp.vmdk
But, don’t get too excited yet. You’ll lose that whole “chmod a+rw” if you reboot. You can build an AppleScript that will do all that fancy stuff and then launch VirtualBox. Go ahead and start the AppleScript Editor and use the following code (replacing your_password_here with your password–it’s compiled, so I think it’s fairly safe):
1 2 3
do shell script "chmod a+rw /dev/disk0s3" password "your_password_here" with administrator privileges do shell script "chmod a+rw /path/to/your/vmdks/*.vmdk" password "your_password_here" with administrator privileges do shell script "open -a VirtualBox"
Save the AppleScript as an application. I named mine “VirtualBootcampBox”. If you want to give it an icon, you can download the applet.icns (icon borrowed from here) and copy it to the Contents/Resources directory of the application you created with AppleScript.
That should do it. Open the application that you created with AppleScript and point your new VirtualBox machine to the vmdk you created and have fun!