Sharing Windows 7 between Boot Camp and VirtualBox

Posted by: admin  :  Category: OS X, VirtualBox, Virtualization, Windows

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.

81 Responses to “Sharing Windows 7 between Boot Camp and VirtualBox”

  1. Rick Says:

    I seemed to be aware about this previously, however there were some helpful bits which concluded the image for me personally, thanks for your time!

  2. AlexL Says:

    Brilliant! Thanks for all the tips. It works for me!
    How about if I now wish to cancel the script to unmount BootCamp every time. I want to do so only when I call upon VirtualBox. Can you advise me how to reverse that nano command? Many thanks!

  3. phaq » Blog Archive » Refining application shortcut for shared BootCamp / VirtualBox Windows VM Says:

    […] a follow-up to my previous posts on sharing Windows 7 in BootCamp and VirtualBox and launching a VirtualBox VM directly through an icon […]

  4. admin Says:

    Hello Alex,

    I don’t know about on-startup hooks in VirtualBox itself to get this behaviour, but you can still achieve this if you create an application shortcut to launch the VM directly.
    I tried to summarize the necessary steps at


  5. Bob Wall Says:

    I very much appreciated your post “Sharing Window 7 between Boot Camp and VirtualBox.” It is by far the clearest explanation of how to go about this I have found on the Web. Unfortunately, I got hung up at the “sudo chmod /// /dev/disk0s3” step.

    I have a mid-year 2011 iMac (SSD primary drive and 1T spinning secondary drive) running Lion. Windows 7 is installed on the Bootcamp partition which is on the SSD. Bootcamp is the third partition on the SSD (Mac OS Recovery, Mac OS and Win7). I performed the Disk Utility step you suggested to revel the Disk Identifier of my Bootcamp partition and discovered it was “disk0s4”. So naturally I substituted 4 for 3 in your sudo … example. I got the following error message
    “Invalid file mode: ///”

    Could you please suggest what I should do to correct this problem?

    Also, I discovered using Disk Utility that even though my Bootcamp partition is NTFS formatted it was mounted. I also got the above error message if I unmounted the disk before I typed the sudo command.

    Though I can’t image it makes any difference, I had renamed the BOOTCAMP drive “Win SSD”

    I am new to the Mac world, so any suggestion you can offer would be appreciated.

  6. admin Says:

    Hi Bob,

    Sorry for the long delay, there was some issues with the comments function on my blog recently.

    After reading through your comment, I understand there is a typo in what you have typed in.

    Actually, it is NOT sudo chmod /// /dev/disk0s3 with three slashes in it, that’s three 7 (as in number Seven).

    This is why you get the Invalid file mode: /// message.


  7. Running Windows 7 from the Bootcamp partition in VirtualBox | Wouter Says:

    […] over at phaq has written a great and easy-to-follow tutorial to get VirtualBox up and running your Bootcamp partition. I’m not going to plagiarize and […]

  8. efstajas Says:

    I followed all these steps, but this is what I get:
    VBoxManage: error: Cannot open the raw disk ‘/dev/disk0’: VERR_ACCESS_DENIED
    VBoxManage: error: The raw disk vmdk file was not created
    I typed all the permission commands though and also unmounted the disk! Is it right that there isn’t a message like “Done”?

  9. Lorenzo Says:

    Ma la macchina virtuale utilizza il vero disco rigido o uno virtualizzato? se io scrivo un file da windows nativo e poi accendo la macchina virtuale, me lo ritrovo li o devo creare una cartella condivisa?

  10. Joe Says:

    I couldn’t get the raw disk file to create, I got an error about access denied to disk0. my bootcamp is on partition 4.

    I entered:
    VBoxManage internalcommands createrawvmdk -rawdisk /dev/disk0 -filename win7raw.vmdk -partitions 4

    VBoxManage: error: Cannot open the raw disk ‘/dev/disk0’: VERR_ACCESS_DENIED
    VBoxManage: error: The raw disk vmdk file was not created

    i followed all the steps before including unmounting bootcamp, not sure why i can’t create the raw disk.

  11. gdelmatto Says:

    You probably missed the “chmod” command.

    Please check back with the partition ID you looked up from Disk Manager.
    Depending on your setup, it may be something like ‘disk0s3’ or ‘disk0s4’ or similar.

    As stated in the single steps, you need to apply write permissions to the partition ID, like this:
    “sudo chmod 777 /dev/disk0s3” or “sudo chmod 777 /dev/disk0s4” or whatever may be right for your system.

    If you don’t run the “chmod” command, you WILL get the VERR_ACCESS_DENIED. Also, keep in mind that you
    need to add the startup script as described, which sets these permissions during every startup, or you will
    get VERR_ACCESS_DENIED again. This change does NOT survice a reboot!

    The check the permissions of your bootcamp partition, run this command from the Terminal: “ls -l /dev/disk0s3” (or use /dev/disk0s4 or whatever applies to you).

    You may get an output like this:

    brwxrwxrwx 1 root operator 14, 3 22 Jan 17:29 /dev/disk0s3

    Note the “brwxrwxrwx” at the begging? This is what it must look like. It simply wont work otherwise.

    And yes, some come commands simply don’t give you a “Done” or “OK” message.

    You could always try to run a commands like this: “sudo chmod 777 /dev/disk0s4 ; echo $?” by adding ” ; echo $?” (that’s “semicolon echo dollar question mark”)

    This would give you a number back, where ‘0’ (zero) usually means “everything ok” while any other number denotes an error running the command.
    A few commands also have a “-v” switch, which means “be verbose”, but that’s not a universal rule. But in general, if you run a command that does not give you
    any output, then everything it’s fine. Most of them bail out with a terrible error message if something was really that wrong.

  12. gdelmatto Says:

    You most likely missed to run the “chmod” command line: chmod 777 /dev/disk0s4

    Have a look at my reply to “efstajas” for a long explanation as well.

  13. gdelmatto Says:

    Ciao Lorenzo,

    Ma si, la macchina virtuale usa la partizione fisica del disco rigido. Non si sta creando un disco rigido virtuale, solo un riferimento alla partizione raw.
    Allora quarda le dimensioni dei file sul mio computer:

    du -h *.vmdk
    4,0K bootcamp-pt.vmdk
    4,0K bootcamp.vmdk

    Si riferiscono alla partizione raw.
    Adesso Windows nel Boot Camp e Windows nel VirtualBox può accedere alla stessa partizione fisica. C’è una sola installazione di Windows :-)


  14. Val Says:


    Just a quick and heartfelt THANKS for this excellent walkthrough!

    Everything went smoothly for me with one exception, as mentioned in the comments in Viplav’s howto: On restarting, I got a black character-mode display with the error that Windows couldn’t start because of a hardware or software change.

    The fix: Shut down the VM, and from the VirtualBox menu pick Settings> System and on the Motherboard tab, check Enable IO APIC.

    I expected to have much more trouble and your guide made it easy — grazie mille!

  15. s Says:

    I keep getting in virtual box:

    Failed to open the hard disk /Users/xxxx/win7raw.vmdk.

    The medium ‘/Users/xxxx/win7raw.vmdk’ can’t be used as the requested device type.

    Result Code: NS_ERROR_FAILURE (0x80004005)
    Component: Medium
    Interface: IMedium {53f9cc0c-e0fd-40a5-a404-a7a5272082cd}
    Callee: IVirtualBox {c28be65f-1a8f-43b4-81f1-eb60cb516e66}

  16. gdelmatto Says:

    Make sure that you granted write permissions on your device file (the /dev/disk0s3 or whatever applies to your system):

    sudo chmod 777 /dev/disk0s3

    Check also the permissions of the VMDK files created:

    ls -l /path/to/your/*.vdmk
    -rw——- 1 USERNAME staff 512 23 Jul 2011 bootcamp-pt.vmdk
    -rw——- 1 USERNAME staff 747 22 Jan 16:44 bootcamp.vmdk

    They should belong to your user account. So if you don’t see your username in the listing,
    change it like this:

    chown YOURUSERNAME /path/to/your/*.vmdk

    If multiple users on your system are going to use the virtual machine, then do this as well: chmod 777 /path/to/your/*.vmdk

  17. s Says:

    I redid everything and now it says
    Failed to access USB subsystem
    could not load the usb proxy service

    Result Code:
    NS_ERROR_FAILURE (0x00004005)
    IHost {dab4a2b8-c735-4f08-94fc-9bec84182e2f}
    IMachine {5eaa9319-62fc-4b0a-843c-0cb1940f8a91}

  18. s Says:

    I did sudo chmod 777 /dev/disk0s4 because i’m 4
    then i eject boot camp
    i type in only the first 3 lines in the nano screen
    and hit control x
    i then use the line sudo VBoxManage internalcommands createrawvmdk -rawdisk /dev/disk0 -filename win7raw.vmdk -partitions 4

    i have done all of that successfully the i put

    sudo chown Admin-Name /Users/Name/*.vmdk

    and thats where i get lost I’m not sure how to determine the path.

  19. rghazarian Says:

    I followed all the instructions on preparing the rawdisk, even checked using “ls -l /dev/disk0s3”. The response I got is:

    brwxrwxrwx 1 root operator 14, 3 25 Jan 11:35 /dev/disk0s3

    Yet when I try running the VBoxManage command I get the errors:

    VBoxManage: error: Cannot open the raw disk ‘/dev/disk0′: VERR_ACCESS_DENIED
    VBoxManage: error: The raw disk vmdk file was not created

    I’m using VirtualBox version 4.1.8 r75467.

    What am I missing?

    Thanks for your time and effort.


  20. rghazarian Says:

    An update. I just tried the command again preceding it with SUDO and that work for me. So the command I used was:

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

  21. test123 Says:

    The reason these people are getting permissions errors is because you suggested they run VBoxManage as their user account instead of as sudo.

    VBoxManage requires write access to the raw block device /dev/disk0 for the raw disk creation process. In the future it’s not needed but the VBoxManage command needs to be run with sudo to work. If you look at the tutorials you cited they did correctly use sudo in this step.

    Also rc.local is run as root during boot so there is no reason for the sudo in front of the chmod command.

  22. gdelmatto Says:

    Oh yes, I see … I checked with earlier revisions and saw, that the missing “sudo” slipped away when I moved the text blocks around. :-/
    Thanks for pointing that one out :-)

    And yes, the “sudo” in the rc.local is of little use, because bootstrap is run from root.
    But … if you ever want to run rc.local from an unprivileged user account, you can just do so:

    bash /etc/rc.local

    the ‘sudo’ in place will make sure, you get asked for the root password, which you otherwise wouldn’t.
    This is mainly in there because I’m doing some other stuff from rc.local, which I sometimes need to rerun during testing.
    Since I sometimes forget to ‘sudo bash /etc/rc.local’, it’s mainly there for my convenience 😉

    Nevertheless, I removed it, because it’s not best practice.

  23. gdelmatto Says:

    Can’t help you too much about that particular error, but on the fast track I found a possible resolution for you in this post:

    Maybe that’s gonna help you with the USB issue.

  24. Raja Says:

    I followed the instructions, but when I select the win7raw.vmdk file in VirtualBox (New VM, Use Existing Disk) the file is selected and the disk shows up as 689GB. My bootcamp partition size is only 90 GB. What am I doing wrong?

    Your help will be very much appreciated

  25. admin Says:

    Your partition should show up with its real size in VirtualBox.
    From the size you state, I suppose you have accidentally selected the OS X Lion recovery partition.
    On a default system, disk0s3 tends to be the recovery partition.
    Thus your Bootcamp will likely be disk0s4, or even different.

    Please check with disk manager that you selected the correct partition.

    Make also sure, that you use the correct partition with the VBoxManage command as well.

    disk0s3 must be “partitions 3”
    disk0s4 must be “partitions 4”

  26. Sherri Says:

    I followed everything and I have the right partition according to disk utility but the size of my virtual drive shows that it is taking the entire disk minus the size of my OS X partition. I have a new Macbook Air with an SSD. I’ve tried several times and keep getting the same result. Any suggestions?

  27. Raja Says:

    Thanks for your reply. My BOOTCAMP partition is labelled disk0s4. I unmounted the drive. In the VBoxManage command I used partitions 4. I changed the owner to admin user. But when I create a new VM and select te vmdk file it shows as 698 GB!

    Not sure what is going wrong here. Your help is very much appreciated.


  28. gdelmatto Says:

    I checked back at my VirtualBox. Indeed, the VMDK file shows up with the full size of the HARDDRIVE and not the partition.
    After some reading I found that the VMDK raw partition access limits access to a certain partition (or multiple partitions if instructed so), BUT it will always refer to the whole disk in terms of geometry and some other meta data.
    This is why the size of the hard drive is shown, and not the partition size.

    In my case (I have a 120 Gig SSD installed) it reads “bootcamp.vmdk (normal, 111.79 GB)”

    So if your harddrive is some 750 Gig in size, which would essentially translate to some 697 Gigs in binary byte calculation, then it should be all fine.

    So please ignore my previos statement, I was in error there.

  29. gdelmatto Says:

    To sum my latest findings please note, that the size of the hard drive seen in VirtualBox _must_ be the real size of the _complete_ hard drive, and not the size of the the single bootcamp partition.

    So even if your setup may look like a 120 GB SSD (decimal notation) of which let’s say 30 GB Bootcamp, 90 GB OS X are allocated, creating the ‘vmdk’ file will show up in VirtualBox with a size of approx 112 GB (binary notation), so to speak the complete hard disk.

    Despite of that, VirtualBox will only be able to access the single Bootcamp partition (the one given by the ‘–partions __n__’ statement).

  30. Danny O'Brian Says:

    I was having trouble booting a 64bit Bootcamp install with VIrtualbox. It was stuck in a reboot loop and kept saying a recent hardware change may have caused the problem.

    Then I changed to the number of processors in use by the VM at:


    To match the number of cores on my iMac, Bingo! booted just fine.

  31. Marcel Says:

    Just got a new MacBook Pro w/ Retina display and tried to set this up and ran into problems. I had this running on my old MacBook Air just fine and was really stumped as to why I couldn’t get it working on the new computer.

    It seems as though if you are installing Windows 7 on the new 2012 MBPs you actually need to skip the step where you move the disk from SATA to IDE. If you use IDE ICH9 or otherwise you will get 0000007b. SATA will boot fine with no changes.

  32. Jon Says:

    Incredibly helpful, I used both Danny O’Brien’s tip of setting the number of processors (to 4) and Marcel’s tip of keeping the SATA drive to get my MBP retina to boot my windows 7 64-bit partition.


  33. Using VirtualBox to Load the Boot Camp Partition | James Perry Says:

    […] the same using VirtualBox, which is free.  I thought I’d give it a shot.  The post is at  He indirectly […]

  34. Valerio Says:

    Ciao Gianpaolo,
    ho qualche domanda:
    – ho un Macbook Pro con Snow Leopard e partizione bootcamp con Win XP: vale esattamente lo stesso procedimento ?
    – ti risulta che ci possono essere problemi poi facendo il boot direttamente dalla partizione fisica windows ?
    – se per precauzione faccio prima un backup di Win con Winclone posso stare tranquillo che nel caso ripristino e torna tutto come prima ?
    grazie mille !

  35. Scott Says:

    currently my setup consists of Lion-windows 7 on bootcamp partition and parallels 6 that uses the bootcamp partition. Will your setup work in mountain lion? Parallels 6 does not work in mountain lion and I do not want to upgrade to parallels 7.

  36. yudy Says:

    Your guide works like charm. Adjust here and there a bit, but it works. Thanks for posting this !

  37. Error Says:

    I have a triple booted system which i created using Bootcamp and the install disk of Backtrack 5 and i get this error:
    VBoxManage: error: Two partitions start at the same place
    VBoxManage: error: Cannot read the partition information from ‘/dev/disk0’
    VBoxManage: error: The raw disk vmdk file was not created
    My question is, how do i separate these partitions and create .vmdk’s for both partitions (Windows 7/Bootcamp and Backtrack 5) to run in VirtualBox, without losing any data?

  38. Neil Says:

    My I got everything done but Windows won’t boot. I always get to the ‘Windows failed to start’ screen. A little help?

  39. Johan Says:

    This is a fantastic guide – it worked perfectly. Many thanks for sharing this. For me this is finally makes it possible for me to start using OSX as my primary boot device. I used to have a few windows only applications that I use on a regular basis which forced me to use the BOOTCAMP partition as my primary OS. Now I can finally make it my secondary OS by using this VirtualBox trick.
    Again: thanks a lot for taking the time to share this.

  40. Frode Says:

    Hello you guys! Just wanted to say THANK YOU!! to all of you!
    Very descriptive guide from blogger and lots of useful questions and comments from the readers as well!


    Frode from Norway

  41. Michael Says:

    When I run the

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

    command terminal just hangs, the files aren’t created and I can’t type any further commands… Any ideas? I’m running this on a rMBP with OS 10.8.2 and the most recent virtualbox which will no longer open…

  42. Review: Free, open source VirtualBox lags behind VMware and ParallelsQuick iPhone Apps | Quick iPhone Apps Says:

    […] to easily boot from existing Boot Camp partitions, as both VMware Fusion and Parallels can—some tutorials exist for the technically minded, but this method isn’t officially supported and you run the risk […]

  43. blouis79 Says:

    Setting processors to more than 1 kills USB support.

    MBP 17″ early 2011 2.3GHz; MacOS 10.6.8 Server (64bit); Windows7 (64bit); VB 4.2.2; BootCamp 3.3

  44. Jakob Says:

    Hey, Thank you all for this!

    Now, it seems with the recent update of virtualbox following the step of switching hard disk to IDE netted me a 0x0000007B blue screen. When I switched back to SATA, Windows booted as hoped.

  45. mathias Says:

    permission problem accessing the file for the medium
    … this is the message I get when I chose the hardrive created in terminal: win7raw.vmdk
    I am having trouble with the sudo chown part… can someone help?


  46. Using VirtualBox To Access Win7 Install Says:

    […] able to get access to my Bootcamped Win7 install in VirtualBox using a combo of these 4 guides:…nd-virtualbox/…in-virtualbox/ […]

  47. Thanos Says:

    Hello there,

    thanks for the excellent intro. I just wanted to share that some additional settings were necessary for my installation to work (on a Mountain Lion Mac Book Pro 13″ mid 2010) using VirtualBox 4.2.4:

    Settings -> System
    Set Chipset to ICH9
    Enable IO APIC

    I had to increase the video memory to 48MB (more than the suggested 27 – less than 48 might be OK as well)

  48. admin Says:

    Hi Scott, The setup described works well for me in Mountain Lion.

  49. [GUIDE][ALPHA] How to Access Your Windows 7 Boot from ML Without Rebooting Using VirtualBox Says:

    […]…in-virtualbox/…nd-virtualbox/…h-virtual.html Instructions: As I had it set up before, my […]

  50. John B. Says:

    Danny O’Brian – thanks for the x64 hint!

    Gianpaolo – thanks for great how to!

  51. actobomp Says:

    I used a setup differing in one tiny detail, but my question applies equally well to your setup as you describe it. You can use Winclone to back up the Bootcamp partition. Assuming one’s computer bricks itself, after restoring Mac OS X from backup, and Bootcamp from backup, how you restore the VM? How do you back it up? I’ve not yet found the answer to this seemingly obvious question.

  52. gdelmatto Says:

    Actually, if you do a TimeMachine backupfor OS X and some special backup aside from that for the Bootcamp partition, you should be all set for a restore.
    TimeMachine in this case will also include all the VirtualBox files needed for the restore.

    If however your partition layout changes after doing a full restore (i.e. the partition identifiers are different) then you would certainly need to re-create the VMDK file.

  53. onnlv Says:

    Thanks for the tip.

    May I translate your post into the Korean language?
    I’ll post it in my personal blog with your OP’s link
    (not an commercial blog)

    If you mind just email me then I’ll remove it.

    Thank you.

  54. admin Says:

    Sure, you’re welcome to do so. Cheers

  55. kyle Says:

    great guide, worked like a charm! i can run my win8 bootcamp partition on my rMBP from virtualbox, easy.

    my current headacheL i’m getting activation prompts when I boot into virtualbox, no prompts when im in bootcamp. (where i originally activated)

    i wasted my time calling microsoft who seem to insist that i need another license although this is the same install (CS reps + their supervisors don’t understand that)

    has anybody had similar issues? i assume its because the hardware profile is so different.

  56. admin Says:

    Well, there’s “ways” to get around this. Try one of the many activation hacks, which load a volume license signature into the system BIOS.
    These tools achieve this by installing a special boot loader, which is called just before the original Microsoft Boot Loader.
    So the boot loader runs everything you boot into both BootCamp and the VM, which give’s it a “valid” license. No more activation hurdles.

    Don’t get me wrong. I’m not for piracying, but if you own a lecal license of Windows, which you happen to have installed on your Mac and intend to share between a native BootCamp installation AND a VM on the very same machine, sharing the same disk partition/windows install as descrbed here, then there’s no other way around.

  57. DJ Says:

    Thank you so much! This worked great for me with one exception: I had to change the chipset to ich9 also to make it run. But otherwise excellent guide!

  58. Josef Says:

    I had to change chipset to ich9 as well, as well as add the drive as click in “Enable IO APIC” (both under System > Motherboard).

    As well as add the drive as SATA drive directly.

    I’m on a Mountain Lion on MacBook Pro Retina.

  59. Pthagonal Says:

    +1 for what Jakob said on October 22nd, 2012 at 8:11 am: I, too, had to revert switching hard disk to IDE and set it back to SATA, otherwise I was greeted with a blue screen.

  60. Mayank Says:

    I am getting below error , pls help

    Mayanks-MacBook-Pro-4:VirtualBox VMs MayankJain$ sudo VBoxManage internalcommands createrawvmdk -rawdisk /dev/disk0 -filename win7raw.vmdk -partitions 4
    VBoxManage: error: VMDK: could not create new file ‘win7raw.vmdk’
    VBoxManage: error: Error code VERR_ALREADY_EXISTS at /Users/vbox/tinderbox/4.2-mac-rel/src/VBox/Storage/VMDK.cpp(3557) in function int vmdkCreateRawImage(VMDKIMAGE*, VBOXHDDRAW*, uint64_t)
    VBoxManage: error: Cannot create the raw disk VMDK: VERR_ALREADY_EXISTS
    VBoxManage: error: The raw disk vmdk file was not created
    Mayanks-MacBook-Pro-4:VirtualBox VMs MayankJain$

  61. gdelmatto Says:

    Hi Valerio

    I respond in english so others may participate from your questions as well.

    Q: Is the tutorial identical for Windows XP as well?
    A: Yes, everything is identical.

    Q: Are there any known issues when booting of the physical bootcamp partition?
    A: Sharing the partition for bootcamp and VirtualBox should not cause any harm. What could happen however is the need to perform Windows reactivation, because the virtual and the physical hardware profiles are completely different.

    Q: If a complete backup of Windows with Winclone is performed, can I rest assured that in the event of recovery I can return to business as usual using the backup?
    A: Taking a backup is always recommend course of action. So yes, it may help a lot having a goog backup if something unexpected happens.

  62. gdelmatto Says:

    Please check that I/O APIC is enabled in VirtualBox settings.
    Also, make sure your virtual drive is setup as SATA and not as IDE.

  63. gdelmatto Says:

    @ Error

    I don’t know anything about your setup.

    From my point of view I would say that partitions should not be overlapping at all. Yet alone for the reason, that different operating systems may overwrite data on other partitions if they really do overlap.

    Whatever you do, take a backup first. And maybe you should inspect your harddrive for logical errors as well.

    And yet, it may be an issue with VirtualBox itself, not recognizing your particular partition layout.
    So maybe you’re better of in the VirtualBox forums finding a possible solution.

  64. gdelmatto Says:

    hi mathias

    what problems you have with the sudo/chown part?

    Please follow the instructions exactly as shown. If you have any particular error, please feel free to post the error message,
    so I can have a look at it.

  65. gdelmatto Says:

    Ho Mayank

    The message indicates, that the vmdk image already exists.

    Well, if you ran the command before and got an error already, the file itself may not have been created.

    But the image itself could have been registered with VirtualBox Disk Image Manager.

    So check in VirtualBox at File – Virtual Machine Manager – (Select VMDK file) – Release – Delete

    This will also remove the VMDK association, if any exists. Then try again.

  66. gdelmatto Says:

    Do you have multiple partitions / a multiboot system, i.e. OS X, Windows via Bootcamp and Linux as well?

    Maybe you should check your partition table for anything unusual, like overlapping partitions and such.

  67. nachtflug Says:

    Hi Gianpaolo!

    Thanks for the nice manual. I thought I followed it thoroughly but something seemed gone wrong as the following note pops up when it comes to the first step in getting up the new machine:

    Das Maschinen-Verzeichnis Win7onMBP konnte nicht im Verzeichnis /Users/MYUSERNAME/VirtualBox VMs erzeugt werden.

    Bitte überprüfen Sie, ob das übergeordnete Verzeichnis vorhanden ist und ob Sie geeignete Zugriffsrechte zum Erzeugen des Maschinen-Verzeichnisses haben.

    MYUSERNAME is certainly the placeholder for my user name :-)
    All seems fine directories exist, permissions are with me.
    Some idea?
    Many thanks!

  68. nachtflug Says:

    Never mind – but surprisingly by typing another name (Win7 instead of Win7onMBP) I could go on. I do not understand the magic here but I don’t have to (though I would be interested in learning the reason)
    Once more mille gracie!

  69. Fredrik Says:

    Hello and thanks for the great guide, I have revisited it several times whenever I had some problems with my setup.

    Recently upgraded to Mountain Lion, and latest updates to ML was done today (10.8.4). It seems this version can now mount NTFS partitions. So the “diskutil umount” etc. line now HAS TO be included in the nano script (for those that didn’t include it originally, like me).

    cheers again!

  70. Mac-App Favoriten - Blog - Sebastian Fuss Says:

    […] 80$ sein, um auch während des laufenden Betriebs unter Mac OS die Windows Partition zu starten. Gianpaolo Del Matto erklärt in seinem Blog, wie man auch mit VirtualBox seine Bootcamp Partition als Quelle nutzen […]

  71. gdelmatto Says:

    Honestely no clue about it. I see no obvious reason why this should not have worked, except for the usual suspects, like permissions and such.

    I’m glad it worked out anyways.

  72. sebwin Says:

    First of all: thanks for the thorough step-by-step guide.

    Sadly, my Windows installation crashes after a few seconds into the boot process (blue screen).
    Unfortunately, I have no clue as to why. Windows very quickly reboots into repair mode, but I am wary to let it attempt “repairs” as the installation works fine within Bootcamp.

    I’m on OS X 10.8.4 with Windows up-to-date 7 using VirtualBox 4.2.14.

  73. Nic Says:

    Great post! still works well with 2013 mbp and windows 8.

  74. Nic Says:

    One thing i noticed in using this setup is that if i take snapshots using VirtualBox when i boot into the Windows partition that it seems to load only the first snapshot and not the latest as i was expecting (hoping).
    Anyway for the moment i’ve had to remove my snapshots.

    Any tips would be welcome?

  75. admin Says:

    Interesting thing, I did never try snapshots on a shared bootcamp partition so far.
    Maybe something that should be looked further into.

  76. admin Says:

    What’s the error on the blue screen? Is it “STOP: 0x0000007B (Inaccessible Boot Device)”? If yes, please make sure to use ICH6 controller, and attach your vmdk to the virtual SATA controller.
    Other reasons for a BSOD may include wrong settings for virtual computer in VirtualBox, make sure it’s ACPI enabled, also Intel VT (hardware virtualizaton support) and nested paging should be enabled.
    It may help to provide the full error message to give a more specific answer.

  77. Sev Says:

    Hi, thanks for the great walkthrough btw, I’ve managed to get it all working on my MBA 2011 with Win 8, but I’ve just gotten a MBA 2013 and have been trying to do the same thing, but i keep getting the “No Bootable Medium” error. I’ve tried all the suggestions from this site and others but still, nothing works. Any ideas with regards to the problem?

    Mine’s MBA 13″ 2013, Win 8 64 bit system on Boot Camp parition (tried booting directly from startup, it works)
    – did the creating of vmdk raw and chown, added local.rc with necessary boot strap commands,
    – tried booting with IDE and SATA on multiple configurations..
    – tried reinstalling Virtual Box..

    any help would be appreciated! thanks!

  78. Sev Says:

    okay i think i might have solved that by putting the .vmdk files in the home directory, but now i’m getting a “Fatal: int18: boot failure” error..

  79. Florian Says:

    I have Windows7 installed in a Bootcamp partition from Mac OS X Maverick. I downloaded the latest version of VirtualBox 4.3.2.

    Before configuring Virtual Box I prepared Mac OS X, unmounted Bootcamp drive ($sudo chmod 777 /dev/disk0s4).

    Then configured Virtual Box for the first boot ($sudo VBoxManage internal commands createrawvmdk -rawdisk /dev/disk0 -filename win7raw.vmdk -partitions 4). The two files “win7raw.vmdk” and “win7raw-pt.vmdk” were successfully created.

    However when I open Virtual Box, go to “new”, select “use an existing virtual hard drive file” and then browse to the “win7raw.vmdk” file and want to open it, the following error occurs:

    Failed to open the hard disk file /Users/flohy/win7raw.vmdk.

    Permission problem accessing the file for the medium ‘/Users/flohy/win7raw.vmdk’ (VERR_ACCESS_DENIED).

    Result Code: VBOX_E_FILE_ERROR (0x80BB0004)
    Component: Medium
    Interface: IMedium {05f2bbb6-a3a6-4fb9-9b49-6d0dda7142ac}
    Callee: IVirtualBox {fafa4e17-1ee2-4905-a10e-fe7c18bf5554}
    Callee RC: VBOX_E_OBJECT_NOT_FOUND (0x80BB0001)

    I am really grateful for your help.

  80. Amit Says:

    Just Save the below code as “Install.command” and double click on it to create BOOTCAMP image for VirtualBox
    Note: Please check your disk identifier


    # Create folder in home directory

    mkdir “VirtualBox VMs”
    cd “VirtualBox VMs”
    mkdir Win7onMBP
    cd Win7onMBP



    # Set the permissions for the BOOTCAMP partition
    sudo chmod 777 /dev/disk0s4

    # Unmount the BOOTCAMP partition
    diskutil umount /Volumes/BOOTCAMP

    # Create the image file for VirtualBox

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

    ## When This will run you will observe the following output

    # Volume BOOTCAMP on disk0s4 unmounted
    # RAW host disk access VMDK file win7raw.vmdk created successfully.

    # [Process completed]

  81. Amit Says:

    Save the following code as “Run-before-VirtialBox.command” and run it by double clicking it every time you want to run BOOTCAMP partition using VirtualBox


    # Run this script before you Start BOOTCAMP using VirtualBox

    # ***** Note: Please check the Disk Identifier of the BOOTCAMP partition *****


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

    # Thanks,
    # Amit