This page was exported from phaq [ http://phaq.phunsites.net ]
Export date: Sun Apr 21 18:11:58 2019 / +0000 GMT
I always used to have Windows installed through Boot Camp on my MacBook Pro. The reason for it being simple: I need it for some games ;-)
On the other hand, I use OS X for my primary work, but again, sometimes there's no way around Windows. So I had the same Windows installed again within VirtualBox.

Well, what a waste of valuable disk space. So, after I got my new MacBook Pro, equipped with an SSD, I decided to go for it and share the Boot Camp partition between Windows 7 running natively and VirtualBox.

Actually, there exist a lot of posts on this topic already. So here's a few I came across:



The best and most complete one is IMHO luckypiplav's howto, as it already covers most of the issues and caveats.

So my today's post will be sort of an aggregate of all these posts before. I'm not trying to duplicate, my focus is to show what I had to do to get my setup working for me.

To begin with, here's a short summary of my specs:

  • Apple MacBook Pro 15", February 2011 model, equipped with an 120 GiB SSD instead of a 500 GiB hard drive

  • OS X 10.6.6 on HFS partition (80 GiB)

  • Windows 7 SP 1 on Boot Camp partition (40 GiB)



Install Windows 7 through Boot Camp



I'm not going to loose big words on this. I used the Boot Camp assistant to prepare the hard drive for installation.
My hard drive was split into a 80 GiB partition for OS X and a 40 GiB partition for Windows 7.
The process is straight forward. For those not so familiar with it, here's a howto.

After completing Windows 7 setup I first installed SP1 and all additional updates. I also activated the Windows 7 license. Then I booted right back into OS X.

Setup RAW partition access



Oh well, here's some tech stuff to go through. This is also one of the things I dislike about all the other posts on this topic (sorry guys, I'm just honest): Everyone tells you to do some shell magic trickery, like write access to the partition device files. However, if your setup is only slightly different, you're most likely doomed ;-)

So, let's start on looking up the partition information first. For this you need to launch Disk Utility first.
My screen shots are from a german language OS X, but for the sake of demonstration purpose, this will be sufficient.

On the main window, click your Boot Camp partition first and the "Information" icon second.



This will reveal the partition information. The most important thing for us to work with, is the partition ID, which in my case reads "disk0s3" (first disk, 3rd slice). In most cases this will be identical for you, but chances are, that it's not. If it reads something different for you, then use this instead.



Now open up Terminal. Your starting directory in Terminal is usually your home directory, which evaluates to /Users/USERNAME. In my case it's /Users/Gianpaolo. You can always verify your current location using the "pwd" (Print Working Directory) command.
I store all my VM related stuff in my home directory in a folder called "VirtualBox VMs", so I change to this directory and create a new folder for the new Windows 7 VM.


cd "VirtualBox VMs"
mkdir Win7onMBP
cd Win7onMBP


Now, we need to grant permissions to the partition we inspected before. Rembember, mine was "disk0s3"? Don't forget to use the one, that correctly applies to your system.
Note: You'll be asked to enter your password to run this command:


sudo chmod 777 /dev/disk0s3


You will also need to eject the Boot Camp volume, in case it's mounted.
Note: If you decided to format your Boot Camp partition with NTFS, then it won't be accessible from OS X. In this case, it won't be mounted as well. This is the case for me, so I effectively left this step out.


diskutil umount /Volumes/BOOTCAMP


To have this settings parmenently applied to the system, you will need to add them to the local boot script. For this purpose, we use the "nano" command, a simple text editor which is simpler to use then "vi". Just type and quit using the "CTRL-X" key stroke.
Chances are that this file does not yet exist, but never mind, it'll be created automatically.


sudo nano /etc/rc.local


Add the following text to your rc.local file:


# grant VirtualBox permissions to Boot Camp partition
#
chmod 777 /dev/disk0s3
diskutil umount /Volumes/BOOTCAMP




Again, if the Boot Camp volume is NTFS formatted, it won't be mounted anyway, so the "diskutil" line can be omitted in this case.
Type "CTRL-X" to save and exit.

Now it's time to create the RAW disk file for use with VirtualBox. For this, you should be inside the VM directory we created previously. If in doubt, check this using the "pwd" command. From here, run the following command:


sudo VBoxManage internalcommands createrawvmdk -rawdisk /dev/disk0 -filename win7raw.vmdk -partitions 3


Please note that this time, you won't need to give the whole "disk0s3" string to the command above. Instead leave the last two characters away, just stating the physical disk name, which is "disk0". You will need however to supply the partition number "3" taken from the "disk0s3" string to the "-partitions" argument as seen above.


Create the VM



Simply follow the instructions of luckyviplav's howto.

Important to note however: As of VirtualBox 4.x, the disk drives are always attached to a SATA controlled, as shown on the screenshot below.
It is effectively required to remove the disk from the SATA controller and attach it to the IDE controller as primary master instead. Also do not forget to set the IDE controller type to "ICH6", otherwise you'll get a "STOP: 0x0000007B" BSOD (Inaccessible Boot Device)".





I strongly recommend to keep the SATA controller in the VM profile. This will have the SATA drivers automatically installed during your first boot.

First Boot and driver installation



So you're now ready to boot your VM off the Boot Camp partition.
This will cetainly take a while as all the drivers need to be installed. Please take the chance to also install the VirtualBox guest additions.

Note: If you want 3D acceleration, you'll need to install the VirtualBox drivers from safe mode (press F8 during boot to get into safe mode).

Optional: Re-attach boot drive to SATA controller



One of the most dramatic performance improvements for VirtualBox is the use of the virtual SATA controller in favor of the IDE controller.
So after you successfully installed all the drivers including the VirtualBox guest additions to your VM shut it down first. Then open your VM settings in VirtualBox and navigate to the storage controller section. Remove the hard drive from the IDE controller and re-attach it to the SATA controller. I asked you to keep it there in the first place so the drivers could be installed, remember?

During the next boot, Windows will automatically pick up the disk from the SATA controller and use this for booting.

As a result overall performance in VirtualBox will be a little snappier as with the IDE controller, which also used a bit more CPU power than the SATA controller.

So here's finally our Windows 7 VM bootet off the Boot Camp partition. And yet, it's still possible to run the very same Windows 7 natively by booting directly into Boot Camp.

Powered by [ Universal Post Manager ] plugin. HTML saving format developed by gVectors Team www.gVectors.com