How To: Run Windows 7 (Bootcamp) in VirtualBox

Bootcamp is great and all, but… the fact that we have to reboot is not !

Sometimes you want to do a little task that really has to be run on Windows or there’s no alternative software for Mac, but you don’t want to reboot into Bootcamp to do it. And you want to keep Bootcamp, since it lets you run Windows to its potential. Well, VirtualBox can certainly help you ! It’s a great piece of freeware that I recently fell in love with.

It lets you startup Windows 7 that you have on Bootcamp as a virtual machine (VM) relatively easy. So the data stays in sync whether you boot up from Bootcamp or VBox inside Mac OS (since it’s really the same installation). Instead of creating a virtual hard disk file like normal virtual machine, it uses a small special file that essential let the VM access the real physical disk.

Step-by-step guide:

  1. Install VirtualBox in Mac OS X.
  2. Create New Virtual Machine, follow the step until you have to select Virtual Hard Disk, leave it like that. The steps are,
    • Name your VM, select Windows 7, click Continue (I name mine “Bootcamp”)
    • Allocate Memory (Ram) for the VM (essentially, you should give at least 1 GB, 1024 MB), press Continue
    • Virtual Hard Disk, leave it like that for now, don’t close it or anything, we’ll do something else before continue.
      .
  3. Open Finder, go to Home Directory, look for folder named “VirtualBox VMs”, make sure it contains your VM folder (mine is Bootcamp).
  4. Open Terminal (Applications > Utilities > Terminal) and type these commands,
    • diskutil list

      press Enter/Return, then look under “/dev/disk0” find the partition number associate with your VM (Bootcamp). It should be 4.

    • diskutil unmount /dev/disk0s4

      If your number from previous command is not 4, replace it N with yours, in disk0sN. (Do the same in the next command)

    • sudo chmod 777 /dev/disk0s4
    • sudo vboxmanage internalcommands listpartitions -rawdisk /dev/disk0

      Type it all in one line, and press Enter/Return

      • Type your Admin password (should be your own password). Nothing will show while you’re typing the password, and it’s normal, keep typing and make sure you type correctly. Then press Enter.
      • It will show a Partitions List. This time you’ll not see their names. So make your paritition 4 (or whatever yours is) is the Bootcamp partition. (Compare the size)
        .
    • cd VirtualBox VMs/Bootcamp/

      Type cd, space, then Virt and press tab, Terminal will automatically complete the folder name for you. Type Bootcamp (VM name) and press Enter.

    • sudo vboxmanage internalcommands createrawvmdk -rawdisk /dev/disk0 -filename "win7.vmdk" -partitions 4

      Type it all in one line, and press Enter/Return

      • If the process is successful. It will show “RAW host disk access VMDK file win7.vmdk created successfully.”
      • Go back to Finder, look inside Bootcamp Folder (or your VM folder) that win7.vmdk and win7-pt.vmdk are there.
        .
    • sudo chown (username) win7*.vmdk
      • Replace (username) with your Account name (If you’re not sure, type whoami in Terminal and press Enter).
      • Press Enter and type your password.
        .
  5. Go back to VirtualBox. Select Use existing hard disk and click yellow folder on the right side to find and select the created win7.vmdk, and click Continue.
  6. VirtualBox will present you a Summary page, click Done.
  7. Open up Settings of the created VM, configure the settings to your liking.
    • Network: you should select Bridge Adaptor, and the network interface you use to connect to the Internet.
    • Shared Folders: select a folder, so you can share files between Mac and Windows while running the VM. Don’t forget to tick Auto-mount.
      .
  8. Start up the VM.
    • Install Guest Additions (Select from Menu Bar in Mac while running the VM) Device > Install Guest Additions, then in Windows 7, a virtual CD will be there. Install and restart the VM.
    • After restart, if the Shared Folder does not show up in Computer, click Map network drive in Toolbar and look for your Shared Folder and tick Reconnect at login.
    • If you use VBox’s Seamless Mode, it’ll be like Windows app is running on Mac natively (of course not truly natively), pretty cool.
      .
  9. Back to Mac OS, this is what you need to know.
    • Before starting up Bootcamp in VM, you’ll always have to unmount Bootcamp partition first. Also you have to grant permission to access the data on the disk. (2nd and 3rd Termianl commands in step 4)
    • If you want this to happen automatically after you login to Mac account, open up Terminal and follow the steps,

        1. sudo nano /etc/rc.local
        2. Type your password, Enter. Teminal will show a relatively blank page.
        3. Type these lines in (change N number in /dev/disk0sN to match your Bootcamp disk)
          # grant VBox permissions to Bootcamp
          sudo chmod 777 /dev/disk0s4
          diskutil unmount /dev/disk0s4
        4. Press Control+O , and Enter to save chanegs.
        5. Press Control+X to exit.
          .
  10. End of Story šŸ˜Ž
šŸ˜€
Note: I did this long time ago, and followed various tutorials, which I didn’t keep the links. So the credit goes to people out there who originally wrote the tutorials, and you can also check out VirtualBox Manual section 9 for more technical details.

About Dekpient

A crazy kid who never wants to grow up.

60 thoughts on “How To: Run Windows 7 (Bootcamp) in VirtualBox

  1. […] How To: Run Windows 7 (Bootcamp) in VirtualBox (kindlevsmac.wordpress.com) […]

  2. […] my previous post on how to run Bootcamp in VirtualBox, I just realize I forget to mention this launching tip, so here it […]

  3. Raja says:

    Under VirtualBix the newly created vmdk file win7.vmdk shows up as the full size of my Mac HD rather than the size of the bootcamp partition. That made me nervous, so did not go ahead. Am I doing something wrong or is this correct?

    • Dekpient says:

      This might answer your questions (let me know if I get it right).
      First, win7.vmdk file size should be under 1KB, that’s very small (as it actually kinda point to the actual bootcamp partition).
      And second, make sure you got #4 right, when you “createrawvmdk” you should specify the bootcamp partition number at the end, so it only represents the bootcamp partition, not the whole disk.

      cheers!

      • oriste says:

        Having the same issue as Raja. can someone confirm that the size mentioned in the Summary screen (where you click “Create”) is indeed the size of the whole disk, bot just the Bootcamp partition

    • Wil Martin says:

      This happened during my initial setup as well. I went ahead to the next step and everything appears to be running normally. I was able to verify that my disk partitions had not been written incorrectly.

      It appears that this method of creating the virtual box pulls the file size from the entire disk (disk0 in this examples case) rather than just a single partition. Within windows the hard drive is still the same as I selected when setting up bootcamp initially.

  4. Humberto says:

    Thank you! I was having BSOD issues during startup but I was able to solve them by moving the win7.vmdk from SATA to IDE and selecting ICH6 as the type (Windows 7, 32 bits)

    • Heitor Gribl says:

      Thanks Humberto! Now it’s working!

    • Pavel says:

      Also worked for me, thank you.

    • themacmeister says:

      Humberto, you are a LEGEND. Many thanks, this got my Win7-64bit working on my Mid-2010 Core i3 iMac.

    • vko says:

      Hola ya intente cambiar el win7.vmdk de SATA a IDE pero no me da la opciĆ³n. Solo puedo cambiar a ICH6 un nivel arriva de donde esta instalado el win7.vmdk. He seguido todos los pasos que aquĆ­, solo que cuando intento cargar el w7 en la maquina virtual la cual se ejecuta en interfaz mac, no encunetra los archivos y muestra un mensaje de recuperaciĆ³n…

      Agradeceria cualquier ayuda.

  5. Frederik says:

    I don’t know if it’s my 64-bit windows, that makes this error.
    When the virtual machine is trying to boot – it says Windows is loading files with this gray bar. When it’s done loading, the virtual machine restarts. What should I do?
    – Nice guide, i’ve been looking for this!

  6. Frank says:

    This was very helpful. Thank you.

  7. Robert says:

    Tried enabling IO ACPI in System settings but still have the grey bar and “Windows is loading files”.

  8. Nick says:

    I too have the “loading files” bar and then it goes to the windows recovery screen. If i select “start normal” or “in recovery mode” it just boots to the same screen again. My bootcamp also boots to this screen, but if i select recovery it does recover and work again. Any ideas? I have a mbp retina with SSD

  9. PA says:

    Nice tuto, very helpful, thank you!
    It also works with win 8 šŸ˜‰

  10. Hi, I’m also trying to have my bootcamp partition boot with VirtualBox, and thank you for this guide. I have a question about unmounting the Bootcamp partition. Another guide I’m reference states that it is unnecessary to unmount a partition if it’s formated in NTFS. Within Disk Util, I have the option to mount and unmount the bootcamp. If I use terminal – diskutil unmount dev/disk0s4 – it responds with failed unmount. disk0s4 is the correct identifier for bootcamp. So should I skip the unmount step as the other guide states?

  11. I’m gone through the steps and now I’m experiencing same problems as Nick.

  12. raph says:

    same issue here, how did you fix it ???!!!

  13. raph says:

    answer to myself : use ICH6 ide protocol

  14. Mikel says:

    my terminal doesn’t accept “-raw” as parameter.

  15. Corey Butler says:

    Thank you so much for this.

  16. I installed everything right through step 8, when the system start after the loading screen of windows has display system error (blue display). Link screenshot : http://img706.imageshack.us/img706/972/errorjm.png as I solve this problem?

    • Hien Ng. says:

      I have same issue as Lucas. I have iMac Mid 2011 with core i5 and running Mavericks. Anyone has any luck?

  17. Anre says:

    Failed to open the hard disk /Users/Anar/VirtualBox VMs/windows/win7.vmdk.

    Permission problem accessing the file for the medium ‘/Users/Anar/VirtualBox VMs/windows/win7.vmdk’ (VERR_ACCESS_DENIED).

    Result Code: VBOX_E_FILE_ERROR (0x80BB0004)
    Component: Medium
    Interface: IMedium {29989373-b111-4654-8493-2e1176cba890}
    Callee: IVirtualBox {3b2f08eb-b810-4715-bee0-bb06b9880ad2}
    Callee RC: VBOX_E_OBJECT_NOT_FOUND (0x80BB0001)
    what it means ..?

    Im New in VB.

    • Dekpient says:

      You’ll probably need to change the permission of the .vmdk file. Redo the ‘chmod’ command and see if the issue goes away.

      • Val says:

        I had the same problem. Re-doing the ‘chown’ command worked – BUT DON’T FORGET THE ASTERISK! I left out the asterisk the first time, so I had run ‘chown’ only on the “xxxx.vmdk” file, and not on the “xxxx-pt.vmdk” file. That was causing my error, so re-running the ‘chown’ command with the asterisk (sudo chown (username) xxxx*.vmdk) did the trick.

  18. Grateful says:

    THANK YOU!
    Out of all the similiar posts out there, yours made the most sense. I DID ALSO HAVE TO MAKE SOME IDE / ATA SETTINGS CHANGES ON VIRTUALBOX FOR WINDOWS TO PROPERLY INSTALL.

    Some of the command lines I did not use for my particular configuration.

    The one thing I still cant figure out is how to script correctl for automatic righs and unmounting. This works perfect the first setup but when I reboot , I have to delete the TERMINAL list and start all over to get it to work.

    I can t seem to get the scripting correct for auto unmount and auto acces.

    Once again thanks a million.

  19. Jorge Salvador MC says:

    I followed all your steps, at the end it do not open (stays at the initiating windows start screen) at Vbox. What could be my error? Additional info: MacBook Pro OSX 10.9.1, BootCamp, Win7…

  20. […] Note: I did this long time ago, and followed various tutorials, which I didnā€™t keep the links. So the credit goes to people out there who originally wrote the tutorials, and you can also check out VirtualBox Manual section 9 for more technical details. More Information See Here […]

  21. telemakos says:

    This used to work very well in Mavericks and previous OS versions but in OS X 10.10 Yosemite the startup script rc.local is not supported anymore. Virtualbox does not start bootcamp anymore without first entering the terminal commands from rc.local manually. Any thoughts on how to create the same startup script in Yosemite?

    • Dekpient says:

      Hey there,
      I believe you can create a LaunchDaemon to run a script on startup.
      For example, say you have the /etc/rc.local then you can download this plist file (change the extension to .plist), edit the file to replace /path/to/your/script and put it in /Library/LaunchDaemons/. Make sure the mode and permissions of both files are correct. The script must be executable by root and the plist file must be 644:root:wheel like:
      -rw-r--r-- root wheel com.dekpient.unmount_bootcamp.plist

      Please report back if it works, and I’ll update the post. Cheers!

  22. Brad says:

    It seems like the rc.local technique no longer works in Mac OS 10.10 Yosemite. Is there a work-around available? The instructions work fantastic until you reboot the computer, then the vmdk becomes inaccessible by VirtualBox.

  23. Noah says:

    Hi, good tutorial :)! Thanks for that.
    But when I want to boot the system I always get a “Bluescreen”.
    To boot in the diagnostic mode of widows works. But normal windows won’t start šŸ˜¦ please help me

  24. geveZEUS says:

    Hi,

    I did the win7 installation.
    VirtualBox running smoothly over.
    but whether MacBook restart win7 boot gives the following error message. I could not find any solution. I would be grateful if you can help. Thank you.

    Windows failed to start. A Recent hardware or software change might be the cause. To fix the problem:

    1. Insert your windows installation disc and restart your computer.
    2. Choose your langugae settings, and then click next
    3. Click “repair your computer.”

    Status: 0xc000000e
    Info: The boot selection failed because a required device is inaccessible.

    • Henry Ng. says:

      I got the same issue but thanks to this thread http://phaq.phunsites.net/2011/03/05/sharing-windows-7-between-boot-camp-and-virtualbox/. At comments #30:

      “Danny O’Brian Says:
      March 19th, 2012 at 12:32 pm
      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:

      Settings->System->Processor

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

      This worked for me. It only took me about 1 year to find this answer! So thanks to Danny O’Brian!

  25. […] How To: Run Windows 7 (Bootcamp) in VirtualBox | Kindle VS Mac ā€“ Oct 14, 2011Ā Ā· Hi, Iā€™m also trying to have my bootcamp partition boot with VirtualBox, and thank you for this guide. I have a question about unmounting the Bootcamp …… […]

  26. Sissy says:

    Is it normal that my Bootcamp folder just disappear of my Finder? :O Just after i created the win7, which I’m not able to find, even if it said that it was “created successfully”….

  27. I have a late 2011 13.3″ mbp and recently added a mercury electra 6G SSD. Installed Yosemite and then added Win7 64 pro using Bootcamp. I tried what most of these tutorial shows and it worked, I have now Virtualbox running that bootcamp partition without any problem… But now Bootcamp won’t load Windows anymore. It stays in the ‘Loading Windows’ screen, the logo animation doesn’t freeze, so it’s working, but never gets to the logon screen. After that I restart in Yosemite and have no problem running the Virtualbox image.
    Any clues? Maybe the Virtualbox addons modified the drivers and that is the cause? Any ideas on how to recover it and allow me to use that partitions in virtualbox AND bootcamp?

    • xThe Beastx says:

      I’m having the exact same problems Claudio, did you ever find a fix for this?

      • Hi, I finally made it work a long time ago, I don’t remember exactly in which of those attempts I was able to make it work. What you describe looks to me like a corrupted image; if you downloaded it try generating it directly in your Mac installing the VBox OS from scratch and modifying the files per instructions in the original post. It could also be related to choosing correctly between SATA and IDE for the image. Take a look into this thread, looks pretty similar and covers both:
        http://superuser.com/questions/154874/virtualbox-imported-vm-verr-not-supported-verr-cfgm-value-not-found

        Anyways, if you want to know my opinion is that it doesn’t worth the effort. Although the feeling of achievement is nice, a lot of things just won’t work as desired. You will probably face problems with some USB devices, some software won’t like the environment and of course performance will never be even close to what you get from using Bootcamp.
        For instance, you need access to your OSX partition so you will probably install MacDrive or something similar in Windows… It won’t work. I mean, you will finally make it work, but it will crash when you start the other way; if you install it using VBox, when you boot with Bootcamp it will crash and you’ll need to reinstall, that and the other way around, which is absolutely annoying and an enormous waste of time, which goes exactly against the whole objective of doing all of this. Every time you need to use it you will need to reinstall and reboot, this ruins the whole idea of virtualizing, which is to avoid reboots with the convenience of doing live operations on both systems without restarting anything.
        I prefer Bootcamp because it all runs natively and performance is 100% for whichever OS you’re using. Besides, so far I’ve never needed to do anything in Windows in order to immediately continue in OSX and back to Windows again. You need Windows or OSX, but it’s very unlikely to need both at the same time.

        There’s other thing that I recommend, and it’s all about hardware. Add some more RAM and switch to a SSD hard drive. You will have an entirely new machine after that. I got a 2013 MacBook Pro with an I5 processor; added 4 GB of RAM which left me with 8 GB total, and replaced the slow 500 GB hard drive with the SSD disk, 480 GB of storage capacity. Both Windows 10 and El Capitan boot in under 7 seconds, usually you get to the login screen within 3 to 4 seconds. The inconvenience of rebooting is now history, and the annoyance of having hardware incompatibility or software deactivation and reinstall is history as well. Everything is smooth as silk and my system just flies, it’s fantastic, and I forgot about VBox.

        Bottom line, replace your disk with a SSD drive and add RAM if you can. You’ll end up with a big, wide smile in your face, guaranteed!

  28. soelu says:

    When I try to start the VM, the following error occours:

    System: El Capitan 10.11.2
    VBox: 5.0.10 r104061

    VD: error VERR_NOT_SUPPORTED opening image file ‘/Users/soelu/VirtualBox VMs/Bootcamp/win-bootcamp.vmdk’ (VERR_NOT_SUPPORTED).
    VD: error VERR_NOT_SUPPORTED opening image file ‘/Users/soelu/VirtualBox VMs/Bootcamp/win-bootcamp.vmdk’ (VERR_NOT_SUPPORTED).
    Failed to open image ‘/Users/soelu/VirtualBox VMs/Bootcamp/win-bootcamp.vmdk’ in read-write mode (VERR_NOT_SUPPORTED).
    Failed to attach driver below us! Not supported. (VERR_NOT_SUPPORTED).
    AHCI: Failed to attach drive to Port0 (VERR_NOT_SUPPORTED).

    Result Code:
    NS_ERROR_FAILURE (0x80004005)
    Component:
    ConsoleWrap
    Interface:
    IConsole {872da645-4a9b-1727-bee2-5585105b9eed}

  29. I followed you step-to-step only that I’m trying to do it (from el Captain and ) for Windows 10,

    And I get this error once I try to start the vmachine:

    VD: error VERR_NOT_SUPPORTED opening image file ‘/Users/toniweb/VirtualBox VMs/Win10/win10.vmdk’ (VERR_NOT_SUPPORTED).

    Any idea?

    Thank you very much for you time

  30. Leslie says:

    I followed you step-to-step only that Iā€™m trying to do it (from el Captain and ) for Windows 10, but I get “Missing Operating System”. Any ideas?

  31. […] I understood that rc.local is not supported anymore in Yosemite and launchd should be used instead. Source:: How To: Run Windows 7 (Bootcamp) in VirtualBox. […]

Leave a reply to Mikel Cancel reply