As much as I adore my new MacBook Pro and the perks of OSX, there are those few useful apps that just aren’t offered in the apple flavor. Luckily, OXS comes bundles with a great utility called BootCamp that allows you to install a complete copy of Windows right alongside OSX, and select which OS to boot at startup. But this still requires a reboot very time I need to use windows. The solution, mount the BootCamp Windows partition with the free virtualization software, Virtualbox, and run Windows directly within OSX as if it were just another application. While that sounds awesome, I found it to be a bit more difficult than I first estimated. Now that I’ve got things setup and running perfectly, I thought I’d share my experience so that it may help you skip the headaches I went through.
Step 1: Install Windows using Bootcamp
Just for sake of clarification, these are my system specs
Computer:
- 2010 MacBook Pro
- Intel Core i5 2.53ghz
- 4gb ram
- 500gb HD 7200rpm
Software
- OSX Snow Leopard 10.6.3
- Windows 7 64bit Professional (This needs to be a full, legitimate copy of the OS)
- BootCamp 3.0.2
- VirtualBox 3.1.6
Here’s Apples own, relatively long, step by step guide to setting up Bootcamp. Make sure to read carefully when you get to “Formatting the Windows Partition” as it caused me a bit of confusion. After installing Windows, reboot back into OSX. Hint: hold the option key while booting to select the OS you want.
Step 2: Setup VirtualBox
VirtualBox is Sun’s (now Oracle’s) free utility that makes creating and launching virtual machines incredibly easy. We’ll use this it to mount the windows installation created with BootCamp. Mr. Anil Dash walks through the steps to make the BootCamp drive useable, but I ran into some troubles that I’ll try to address here.
1. The first thing we need to do is eject the BootCamp partition – Open “Finder”. “Control->Click” the “Bootcamp” drive and select “Eject” (You can also the DiskUtility as well)
2. Now for the geeky terminal stuff to make the BootCamp partition useable within VirtualBox. Open a terminal (located in /Applications/Utilities) and enter the following commands. Make sure to press “Return” after each command to run it.
sudo chmod 777 /dev/disk0s3–Changes the permissions of the BootCamp partition to allow it to be modified (enter your admin password when asked)sudo VBoxManage internalcommands createrawvmdk -rawdisk /dev/disk0 -filename win7raw.vmdk -partitions 3–Creates 2 files in your home directory, one of which will be used by VirtualBox to access the BootCamp Partitionsudo chown YOUR-USER-NAME-HERE win7raw.vmdk win7raw-pt.vmdk–changes the permissions of the previously created files (Replace YOUR-USER-NAME-HERE with the current user name)
2. Download and install VirtualBox for OSX
3. Start up VirtualBox, and make a new Windows 7 machine. Stick the with recommended memory sizes for now – you can always increase them later. When asked to select a hard drive, select “Use existing hard disk” and click the browse icon – doing so should bring up the Virtual Media Manager. In the Virtual Media Manager, click “Add” and navigate to your home directory. Here you should find two files that were created earlier. Select “win7raw.vmdk”.
4. Highlight the Windows7 Machine and select “Machine -> Settings” from the menu. Click the “Storage” Icon and change “Type:” to “ICH6″ (My Install would crash with “PIIX”). Click “OK”.
5. Startup your Windows Virtual Machine and watch the magic happen!
Step 3: Create AppleScript
Before you do your party dance, we need to do some more work to really make things happy. With my system, I found that after booting into Windows 7 (not using VirtualBox), I would get a VERR_ACCESS_DENIED error using VirtualBox. What’s happening is Windows (Or maybe BootCamp) is locking permissions of the BootCamp partition when Windows is shutdown. This may be great for security, but it makes our job a bit more difficult. We could change the partition permissions through the terminal each time we wanted to use VirtualBox, but that would be a hassle.
So, I created a quick AppleScript that not only changes these permissions, but also ejects the BootCamp Partition (if mounted) and launches the Windows7 Virtual Machine. Make sure to enter the name of your virtual machine where it say’s YOUR-VM-NAME-HERE. This was my very first excursion into AppleScripting, so I apologize if things aren’t a good as they could be. Check out this AppleScript resource if your confused about creating the script.
--Make the BOOTCAMP Partition writeable
do shell script "chmod 777 /dev/disk0s3" with administrator privileges
tell application "Finder"
if exists "BOOTCAMP" then
--Eject BOOTCAMP Volume if Mounted
do shell script "umount -f /Volumes/Bootcamp" with administrator privileges
end if
end tell
--Launch Virtual Machine
do shell script "vboxmanage startvm YOUR-VM-NAME-HERE"
Well, that’s pretty much it. You can now launch Windows 7 in OSX by simply clicking the AppleScript. Please let me know if you have any questions/suggestions. Thanks for reading!
Did you need to reactivate Windows in the VM? I would have thought that it would see the VM and the native Mac hardware in BootCamp as different machines.
Activation did get a little screwy. The main problem was that I had previously installed my copy of Windows7 on another machine (which I stopped using after geting my MacBook). I had to go through the ridiculous phone activation process to get it to work in the first place. A few days after installing, I got another activation error while in VirtualBox, and had to redo the phone activation. Since then everything’s been fine. With the popularity of VMs, Microsoft should be smart enough to allow them, but you never know. If I get another error, I’ll definitely be giving them a call… a very angry call.
Great guide. unfortunately the windows 7 vm keeps rebooting. I do not have any clue why this happens.
Does the VM reboot while using VirtualBox or when you boot Windows7 natively? If it’s a virtual box issue, make sure you have the latest version (3.2). Also, what version of OSX are you running? My machine is running the latest version of Snow Leopard with no problems.
This tutorial (esp the apple script suggestion) pretty much rocks.
I have also experienced a repeated win7 reboot behavior when launching the VM. This is occurring with vbox 4.06 and latest version of OSX. Windows partition is disk0S3. OSX and Win7 (64bit fully registered) , on the same physical device.
No errors reported during config or VM startup, the started image just keeps re-looping to
“loading windows |||||||||||||||||||||||”
Thanks so much for a gentle guide through this. As a non-commandline-geek, the forum on the VBox website had me very confused!
Unfortunately I get these errors every time I try to start the VM (this version is from the AppleScript, but it’s the same set of messages when I start up within VirtualBox):
“Oracle VM VirtualBox Command Line Management Interface Version 3.2.8
(C) 2005-2010 Oracle Corporation
All rights reserved.
Waiting for the VM to power on…
ERROR: VD: error VERRNOTSUPPORTED opening image file ‘/Users/MYUSERNAME/win7raw.vmdk’ (VERRNOTSUPPORTED).
VD: error VERRNOTSUPPORTED opening image file ‘/Users/MYUSERNAME/win7raw.vmdk’ (VERRNOTSUPPORTED).
Failed to open image ‘/Users/MYUSERNAME/win7raw.vmdk’ in read-write mode rc=VERRNOTSUPPORTED (VERRNOTSUPPORTED).
Failed to attach driver below us! Not supported. (VERRNOTSUPPORTED).
AHCI: Failed to attach drive to Port0 (VERRNOTSUPPORTED).
Unknown error creating VM (VERRNOTSUPPORTED)
Details: code NSERRORFAILURE (0×80004005), component Console, interface IConsole, callee “
Any idea what’s “not supported”? (I did check that I’d changed the storage type as you mentioned.)
Thanks!
Being that your getting the error within VB, I would troubleshoot without using the Applescript. Make sure that the virtual drive has the correct write permissions. Open Disk Utility, select your Bootcamp drive and click the “i” button. Make sure the Disk Identifier reads “disk0s3″ (This is what I used in tutorial). If it doesn’t, then open a terminal and enter sudo chmod 777 /dev/”YOUR-DISK-IDENTIFIER”. See if the VM starts now. If not, let me know and we can keep troubleshooting.
I am getting the same errors, and my Windows partition is indeed disk0S3. What else do you think could be going on?
Here is the exact error:
ERROR: VD: error VERR_NOT_SUPPORTED opening image file ‘/Users/montanajack/Library/VirtualBox/HardDisks/bootcamp.vmdk’ (VERR_NOT_SUPPORTED).
VD: error VERR_NOT_SUPPORTED opening image file ‘/Users/montanajack/Library/VirtualBox/HardDisks/bootcamp.vmdk’ (VERR_NOT_SUPPORTED).
Failed to open image ‘/Users/montanajack/Library/VirtualBox/HardDisks/bootcamp.vmdk’ in read-write mode rc=VERR_NOT_SUPPORTED (VERR_NOT_SUPPORTED).
Failed to attach driver below us! Not supported. (VERR_NOT_SUPPORTED).
AHCI: Failed to attach drive to Port0 (VERR_NOT_SUPPORTED).
Unknown error creating VM (VERR_NOT_SUPPORTED)
Details: code NS_ERROR_FAILURE (0×80004005), component Console, interface IConsole, callee “
Kevin, thanks for the above but I have the similar issue as Winhater and your recommendation does not seem to solve the issue. I have checked and mine is also disk0s3 but I still get same error i.e.
Failed to open a session for the virtual machine Windows 7VM.
VD: error VERR_NOT_SUPPORTED opening image file ‘/Users/MY_USER_NAME/win7raw.vmdk’ (VERR_NOT_SUPPORTED).
VD: error VERR_NOT_SUPPORTED opening image file ‘/Users/MY_USER_NAME/win7raw.vmdk’ (VERR_NOT_SUPPORTED).
Failed to open image ‘/Users/MY_USER_NAMEs/win7raw.vmdk’ in read-write mode rc=VERR_NOT_SUPPORTED (VERR_NOT_SUPPORTED).
Failed to attach driver below us! Not supported. (VERR_NOT_SUPPORTED).
AHCI: Failed to attach drive to Port0 (VERR_NOT_SUPPORTED).
Unknown error creating VM (VERR_NOT_SUPPORTED).
Thanks a lot for any help/advise you might have
BR, Frederic
Kevin – Great guide! I landed here after finding similar instructions in a forum; love the Apple Script (was thinking that would be a nice touch – than I came here & you’d already done it!).
I have this working in 10.5.8 as well as 10.6.4. Based on the guidance from the forum, I used VB 3.0.8, then upgraded to the latest version after it was working. One issue I’m having on both is no audio when booted as a VM. Other than that, this is a beautiful thing.
@Rick. Glad to hear that everything worked out. As for the Audio issues, make sure you have the correct audio settings in VB. If I remember correctly, audio was disabled by default on my VM and I had to adjust the VM setting to get it to work. Let me know if you can’t get it.
Kevin – Audio is working now in my 32 bit Win 7 guest. The VB manual alluded to the problem (pages 58 and 201 of the VB 3.2.8 help .pdf). Although Windows said it tried to resolve the problem, and I had run Windows Update several times, getting to Windows Update through Device Manager for drivers solved it. Looks like there is a related driver fix for Win 7 64 bit guests that I’ll try next.
Kevin
Thanks for the perfect guide! Just what I was looking for, when I needed the apple script to do both. The script works smoothly on the macbook I was originally testing it out on (running Snow 10.6.4, bootcamp 3.1 and windows 7-32). But when I am running the same script on a different macbook (running Leopard 10.5.8, bootcamp 2.0 and windows xp-32), it just keeps giving me “A privilege violation occurred” error.
The Windows 7 VM itself works fine when I open it through Virtualbox. It is only the script that does not work, so as to eject the bootcamp and chmod on the disk.
Could you help me out with this? Thanks.
@jason. It’s a bit difficult for me to test as my operating environment is much different than yours. Make sure that the virtual drive has the correct write permissions, and that you are running the chmod on the correct drive. Open Disk Utility, select your Bootcamp drive and click the “i” button. Make sure the Disk Identifier reads “disk0s3″ (This is what I used in tutorial). If it doesn’t, then open a terminal and enter
sudo chmod 777 /dev/”YOUR-DISK-IDENTIFIER”. See if the VM starts now. If not, let me know and we can keep troubleshooting.Kevin, sorry strike that about the script.I was trying to open virtualbox on the ‘leopard/windows xp’ machine using the same vb folder under Library from the ‘snow/windows 7′ test machine.
But turns out I actually do have trouble opening the vm itself (once that works, I will test the script again).
To rephrase my question, again, its a macbook running Leopard 10.5.8/Windows XP-32. I did a clean install of virtualbox, new rawvmdk created and new vm created. Now when I try to start the VM, it gives me this error on the black boot screen:
“Windows could not start because of a computer disk hardware configuration problem……(error continues)”
I have changed the ICH setting for IDE, enabled IO APIC but still won’t boot. FYI, I have also tried virtualbox versions 3.0.8, 3.1.4, 3.1.8, 3.2.8
Any idea why its causing this? Thanks.
Finally working! Even though I did not want to try the ‘vmware fusion’ method to make XP work on virtualbox, guess it wasn’t that bad after all. I was hoping for VB to work right away without the help of other softwares but nevermind.
Windows XP is booting fine now without any issues at all.
As for the script, I think Leopard takes the ‘unmount’ command differently compared to Snow leopard. Weird but the shell command needs to run like below on Leopard 10.5.8:
do shell script “diskutil unmount disk0s3″
Thanks again Kevin!
@Jason. Glad to hear you got it working!
Hello all
thanks for this good guide, nevertheless I have the same issue than Jason for booting XP (“Windows could not start because of a computer disk hardware configuration problem”)
@Jason: could you tell me what was the solution for your issue?
Thanks!
hi again kevin,
do you know what would be the variable for the username if I wanted to run the below command as part of your apple script:
# sudo chown YOUR-USER-NAME-HERE win7raw.vmdk win7raw-pt.vmdk
I need to run the script on multiple computers, so the username variable has to be for any “currently logged in user” (that is, without specifying the username). Is this possible? I tried $USER: but this does not work.
Use the ~
This gets you to the current home directory.
Hello, I have just done what you put on top of all, and everthing is messed.
I have a bootcamp partition and on windows 7 the macdrive program let me use the mac hd. Before doing the terminal stuff everything was ok, but after doing and I deleted the drive in Virtual Box and also deleted virtual box, everytime I load windows 7 macdrive takes like 10 minutes finding and letting use the mac HD. It changed my HD letter from E to G. I returned to the old value but still same problem. Fixed with fix problems on macdrive and still the same.
Do you know any solution to recover the good last stage?
Please email me with solution if you have any.
javier.rollon@gmail.com
Thanks!
Kevin,
I’m interested in trying this method but noticed that VirtualBox version 4 has been released. Is this still working the the new version or are there other steps I need to be aware of?
Pingback: phaq » Blog Archive » Sharing Windows 7 between Boot Camp and VirtualBox
Hi,
thanks for the guide, it’s the only one that I find written down clearly.
I’ve got an error at the end of point 3.
When I try to select the vmdk file to use as hd for my virtual machine VB sends me back this error:
Output code:
NS_ERROR_FAILURE (0×80004005)
Component:
Medium
Interface:
IMedium {9edda847-1279-4b0a-9af7-9d66251ccc18}
Caller:
IVirtualBox {d2de270c-1d4b-4c9e-843f-bbb9b47269ff}
Can you help me please?
I’m running Mac Os X 10.6.7, Windows 7 Pro 32bit, Virtual Box 4.0.4 r70112
Sorry, just to correct my email so I can be noticed if you reply
I followed these steps on my new MacBook Pro 13. It all worked fine until I came to boot Windows 7 within VBox.
It would crash during boot every time.
In the end I got it working, I found some useful stuff on the VBox forums. The solution to my problem was to attach the disc image to the IDE adapter rather than the default of attaching to the SATA adapter.
I haven’t had to re-activate, I’m guessing that is because my install is from an MSDN image rather than a retail/OEM disc.