Boot Camp is very convenient as it lets me run Windows 7 programs that I need such as Microsoft Visual Studio. It would be even more convenient if I could open it while in OS X for the times I don’t need the best performance (as I would if were playing 3-D games for example). There are virtual machine programs available that advertise that ability, such as Parallels but I found a post that claims to do the same using VirtualBox, which is free. I thought I’d give it a shot. The post is at http://phaq.phunsites.net/2011/03/05/sharing-windows-7-between-boot-camp-and-virtualbox/. He indirectly referenced http://luckyviplav.blogspot.com/2011/06/windows-7-on-mac-os-x-through-virtual.html in his steps.
To go through the steps, I had to set up a password on my user account on the Mac. To make the changes below, it requires you to have a password to authorize them as an administrator. Also be aware that one thing about VirtualBox is you often have to move the mouse after clicking a button, otherwise it will often not recognize the click (at least while using a touchpad/trackpad).
The steps I took on my MacBook Pro running OS X Lion 10.7.4 were:
- Installed Windows 7 in Boot Camp (already done)
- Installed VirtualBox (current version – 4.1.18 r78361)
- Launched Disk Utility
- Highlighted the BOOTCAMP partition and clicked Info
- Made note of the Disk Identifier (disk0s4 – though his was disk0s3)
- Opened Terminal
- Typed pwd (print working directory) to confirm I was at my home directory (Users/USERNAME). Note: “cd ~” will get you there if you’re not.
- Made directories and went to them
- Typed mkdir “VirtualBox VMs” (the quotes are necessary because of the space)
- Typed cd “VirtualBox VMs”
- Typed mkdir Win7onMBP
- Typed cd Win7onMBP
- Changed permissions by typing: sudo chmod 777 /dev/disk0s4 (remember his was disk0s3)
- Ejected the BOOTCAMP partition by highlighting it in the Finder, right-clicking on it and chose eject (This was important – it wasn’t immediately obvious that I had to eject it since he said he didn’t have to nor was it obvious how to do it)
- [I skipped the step he had next which makes my steps 9 and 10 automatically run upon rebooting because I can’t clone the Boot Camp partition if it’s dismounted. I did it a different way instead and moved it to step 14.]
- Created the VirtualBox RAW disk files by typing: sudo VBoxManage internalcommands createrawvmdk -rawdisk /dev/disk0 -filename win7raw.vmdk -partitions 4 (his was -partitions 3 because he had disk0s3 in my step 5)
- Changed owners of the two files (I’m still not sure why I had to but I definitely had to) by typing: sudo chown USERNAME *.vmdk (replaced USERNAME with my real username)
- I made a script that makes the necessary changes mentioned in step 11. The changes last until you reboot OS X. I can simply double click the script (run it) before launching Virtual Box if the changes haven’t already been made. (The script how-to came from kaz-k at https://discussions.apple.com/thread/3175771)
- Launched TextEdit
- Typed the lines he had (adding sudo before chmod):
- #grant VirtualBox permissions to Boot Camp partition
- sudo chmod 777 /dev/disk0s4
- diskutil unmount /Volumes/BOOTCAMP
- I saved it as a plain text file to the desktop and named it “Virtual Box Permissions.command” (note the file extension command instead of txt)
- Back in Terminal, I typed cd ~ (to get back to the home directory)
- Typed cd Desktop
- Typed chmod +x “Virtual Box Permissions.command” (to make it executable)
- In VirtualBox
- Clicked “New” and clicked “Continue”
- Typed Win7onMBP (Microsoft Windows and Windows 7 were automatically selected) and clicked “Continue”
- Set the memory size to 1024 MB (1 GB) and clicked “Continue”
- Pressed the “Use existing hard disk” button
- Clicked the picture of the folder (Choose a virtural hard disk file…)
- The directory Win7onMBP was already highlighted so I clicked win7raw.vmdk and clicked “Open”
- The window closed and I clicked “Continue” in the original window
- Clicked “Create”
- Back on the main VirtualBox screen, I clicked “Settings”
- [I skipped the part about changing the disk to IDE – it caused problems and ended up being unnecessary]
- At the top, I clicked “System” and on the “Motherboard” tab, checked “Enable IO APIC” (This was mentioned in the comments on his site)
- At the top, I clicked “Display”, and changed the Video Memory from 16 MB to 128 MB (for step 21 below) and clicked “OK”
- Next up was to press “Start” in VirtualBox. A message shows up about Auto capture keyboard. It notes the host key is the left COMMAND key. I pressed “OK”
- It showed a mouse pointer integration message so I clicked “OK”
- Windows 7 loaded like a charm. A message popped up saying “Installing device driver software.” It then said “Device driver software was not successfully installed.” It wanted to restart but before doing so, I set the Network Location to Home.
- After restarting, things seemed fine. Device Manager showed an exclamation mark for “Base System Device” under “Other devices” but it went away later.
- Next up was installing Virtual Box Guest Additions. In the VirtualBox menu at the top, I clicked Devices, then “Install Guest Additions…”
- An AutoPlay screen popped up in Windows 7 and I clicked “Run VBoxWindowsAdditions.exe” and installed it. I opted to add the experimental Direct3D Support though it warned me that it required at least 128 MB of Display memory (which is why I added step 15-L above).
That’s it. I now had the Boot Camp Windows 7 installation working in Virtual Box running in OS X. The exclamation mark I mentioned went away after installing Additions. When I reboot, I just need to double click the file Virtual Box Permissions.command (made in step 14), then run Virtual Box as normal.
I wouldn’t play a graphically intensive Windows game this way but for running things like Visual Studio, it’s perfect! I can even press COMMAND-F to go full-screen. If you’re already running Boot Camp, I highly recommend trying this VirtualBox installation out if you think it might be useful. After all, it’s free!
A side-effect is the left Windows key no longer works. VirtualBox is using it as its host key. The right Windows key works fine though. You’ll have to press the FUNCTION key in addition to the F keys for things such as ALT-F4 if you leave OS X to its default configuration for those keys. Enjoy!