Using Virtualbox with an Existing Windows Partition

posted in: HOWTO | 232
The recursion might blow your mind.

I am not able to help troubleshoot this anymore, as I have switched over to VMWare Player; However, I am still maintaining this document. If you happen to discover anything about making it work, please post in the comments below and I will update the post text with your findings and credit you.

Last week, a friend of mine needed me to do an audio file conversion, but the app that I use is installed on my windows partition. I really don’t ever boot into Windows unless I have a good reason for it — I’m much happier tooling around in Linux — there’s just something satisfying and comfortable about being able to pop open a shell at any time.

Anyways – it got me thinking: I’ve booted into a Windows XP image,  why can’t I use VirtualBox to boot from a whole partition? Surely that is possible…

Tonight I finally got to play with it. And as you can see from the image here, I got success. 🙂

It’s a little challenging, but it’s doable. I had to spend some time to iron out the kinks, but you can reap the benefits!

UPDATE: Sandeep has submitted screenshots with instructions on getting this to work with Windows 7, see below, at the very end.

UPDATE: If you are getting the error message: Offset must be a number: rce
I have found the fix for it. See the instructions below.

UPDATE: Bogdan (see comments) was able to get Windows Vista working under Virtualbox OSE, using the method below. See his comments for specifics on Windows Vista.

UPDATE: Dan has found some tricks for getting this to work with Win7 if you are getting a BSOD on bootup.

UPDATE: Julian has successfully gotten it to work with Windows 8 Pro, see below, near the end of the post content.

UPDATE: user PCWorld has submitted some suggestions to get this to work with Windows 7

UPATE: user ComputingFroggy has cross-posted some tips on Windows 7 integration with Lubuntu.

Install Virtual Box

Ok, for starters, you need the CLOSED SOURCE version of VirtualBox. As in — do not install the one from the Ubuntu Software Center. Go directly to Sun Oracle’s website and download the appropriate version for your OS.

Ubuntu users should use the PPA instead of downloading the binaries. Be sure to check the link above for the most recent PPA. This sample applies to 12.04, Precise Pangolin, but there will quite possibly be a newer version on the website when you read this.

  1. Open up Ubuntu Software Center
  2. Click on the Edit top menu, and select “Software Sources
  3. Choose the “Other Software” tab
  4. Click on “Add…
  5. Paste: [cci]deb http://download.virtualbox.org/virtualbox/debian precise contrib[/cci]
  6. Click on “Add Source”

Now you’ll want to update your repo cache and get the key:

[cc]$ wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add –
$ sudo apt-get update[/cc]

And then install the package of your choice.

[cc]$ sudo apt-get install virtualbox-4.2[/cc]

Whether you do binary-based install or package based install — install the most recent version of the personal edition (NOT “OSE”, which is the open-source version.) As of this post, the current version for Precise Pangolin (12.04) is VirtualBox 4.2.

The Virtualbox documentation also indicates that Ubuntu/Debian users should install the dkms package.

[cc]$ sudo apt-get install dkms[/cc]

Install “mbr”

In order to successfully trick Windows into booting into a confined space, you need to fake your mbr (no grub). Fortunately this is WAY easier than it sounds:

[cc]$ sudo apt-get install mbr
$ install-mbr –f ~/.VirtualBox/FAKE.mbr[/cc]

That’s it! We’ll use that later.

Your system will NOT be affected by this — all it does is copy the MBR from your computer, dump it into a file and that’s it.

NOTE: Originally, I had used the full name flag (–force) which uses two dashes. Due to the way my stylesheet renders italicized fonts, it looked like it was a single dash, understandably confusing some people. If you are getting the error message:

[cc]$ install-mbr: Offset must be a number: rce[/cc]

Then either use just -f instead, or ensure that you are using two -‘s before “force”.

UPDATE: Ken D has debugged an issue he had with install-mbr by using the -e1 option.

[cc]$ install-mbr -e1 –force ~/.VirtualBox/FAKE.mbr[/cc]

His windows partition is /dev/sda1, so if yours is not, you need to use -eN where “N” is the number of the partition where windows is installed. Or not. (More info)

Create a VDMK file

This is actually the trickiest part. A VDMK, which I am not sure what that is an acronym for, is essentially a micro-image that contains instructions to tell MBR where it’s booting from. If your computer is modern, your hard drives are likely SATA drives (and thus represented as /dev/sda). If you’re unsure, just go into a shell and type “fdisk -l” (no quotes, and that last part is a “dash lowercase-L” not “dash one”). What you want is the device name for your harddrive… mine is /dev/sda  — depending on how many hard drives you have and what type they are, it might be /dev/hda/ or /dev/sdb/ etc.

It’s worth noting that if you are currently mounting your windows partition in Linux (I do) so that you can access your Windows filesystem while in Linux, you will need to unmount (eg. sudo umount /windows) it first.

You’ll want to determine which partition contains Windows, so we can restrict Windows to ONLY using its own partition — this is actually a Linux-exclusive ability (the Windows version of Vbox can’t do this, because Windows is a wuss). So to do this, first you need to know what partition(s) Windows is on. This command will tell you:

[cc]$ VBoxManage internalcommands listpartitions -rawdisk /dev/sda[/cc]

For the last part, use whatever you determined from above. It’s PROBABLY /dev/sda for you too, that’s pretty common.

The command will produce output that looks something like this:

[cc]VirtualBox Command Line Management Interface Version 3.1.2
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.

Number  Type   StartCHS       EndCHS      Size (MiB)  Start (Sect)
1       0x83  0   /1  /1   1023/254/63         53348           63
2       0x82  1023/254/63  1023/254/63          4000    109258065
3       0x83  1023/254/63  1023/254/63        155998    117451215
4       0x07  1023/0  /1   1023/254/63         91895    436935870[/cc]

I have to admit, I feel a little naked showing the whole Internet my partition table…

The last line is the one you want to look for, although yours may not be your last line. Whichever one(s) have 0x07 as their “Type” are the one(s) you want. Jot down the number(s) for those. (In this case, my number is just “4”).

Now there’s one last thing we have to do that may make you a little uncomfortable, if you’re a paranoid person. We need to change the permissions on the hard drive device nodes. If you don’t know what that means, then you are probably not paranoid about that. 🙂

Fortunately, we only need to change the permissions slightly, and only on the Windows partitions. So it’s not THAT big of a deal.

In a terminal, type:

[cc]$ sudo chmod 666 /dev/sda
$ sudo chmod 660 /dev/sda4[/cc]

That second line should reflect whichever hard drives you are using (remember that fdisk -l we did?) You’ll need to repeat the command for each hard drive that you want Windows to be able to access.

For those of you that are paranoid: You should be able to change the permissions back to 600 after we’ve created the VDMK file — VirtualBox needs access to your partition table so it can do its job.

There’s one last thing we need to do, and that’s adding you to the “disk” group, so you can access the partitions you just opened up. You’ll need to logout and log back in after doing this, so that your permissions are reset. (Previously forgot to include the username — thanks Ken!)

[cc]$ sudo usermod -a -G disk yourusername[/cc]

Ok, now you’re ready to actually create the VDMK file. Get ready because this is a handful.

[cc]$ VBoxManage internalcommands createrawvmdk -filename ~/.VirtualBox/winxp.vmdk -rawdisk /dev/sda -partitions 4 -mbr ~/.VirtualBox/FAKE.mbr -relative[/cc]

First off — the “sda” is whatever you determined you’re using, from earlier. It’s probably “sda”, like I mentioned earlier.

The number next to the partitions is the numbers you jotted down from the previous “listpartitions” command (the one where I said I felt naked). If you are using more than one partition, you will need to list them as comma-separated values. So if you wanted partitions 1 and 2 for Windows, you would replace the “4” I wrote there with “1,2”. Partitions 2, 3 and 4 would be “2,3,4” and so on.

The “partitions” parameter is what tells VirtualBox “only give Windows access to these partitions, and no where else!”

UPDATE: In the comments below, Heix writes:

Got a Win7 64bit Home Professional, with an ACER Recovery Partition as partition 1, the “boot loader”(?) partition as 2, and the actual win7 partition as 3, so i did a “-partitions 1,2,3″. Had to use the .iso of the win7 recovery disc afterwards.

Just to break down what’s going on here:

[cci]VBoxManage internalcommands createrawvmdk[/cci] this portion runs the program to “Create Raw VMDK”. Self-explanatory. DO NOT USE SUDO HERE (h/t to Javier, below!)

[cci]-filename ~/.VirtualBox/winxp.vmdk[/cci] this is the output file that actually holds the micro-image. You can call it whatever you like, and you can put it whereever you like. If you have multiple Virtual Machines, you may like to file them away in a separate folder. Whatever you like.

[cci]-rawdisk /dev/sda -partitions 4 [/cci] This tells it that the raw Windows installation is located on device /dev/sda and that you only want to use partition 4 (yours may be different, as noted above)

[cci]-mbr ~/.VirtualBox/FAKE.mbr -relative[/cci]
the -mbr parameter tells it to use that Fake MBR we created earlier. It won’t work without this. -relative is a parameter that works in conjunction with the -partitions parameter, to allow you to explicitly specify which partition you want to use.

[cci]-register [/cci] This used to tell VirtualBox to register it in its database of available images, but has since been deprecated. Do not use this with version 4 of VBox. (Thanks, Ken D!)

That’s it. Chances are, if you are going to get errors anywhere, it’s likely to be here.

Possible causes, based on my experience and what I’ve read about on the Internet, is that you didn’t set permissions correctly, didn’t unmount your device, are using the Open-source edition (which doesn’t have createrawvdmk) instead of the closed-source personal edition. If you get an error, you can post it in a comment and I’ll see if I can help you, but google around — there are a LOT of resources online for this. Below, I’ll include links to the places I looked.

Load your new VDMK into Virtual Box

Load up Virtualbox, if you installed it through the automated installation (rather than compiling it manually), you should see it by opening dash (click on the Unity icon) and typing “Virtual”. If you don’t see it there, try logging out and logging back in.

In VirtualBox, click on “New”, and follow the instructions for the first couple of screens. Name it whatever you like and select your OS (these instructions have all applied to Windows XP so far — caveat operor on any other versions / OSs). Once you get to the “Virtual Hard Disk” screen (pictured here) select “Use existing hard disk” and you should see the VDMK file we just created. If you don’t, click the little folder icon next to the drop down list. It will allow you to “add” your vdmk file that you created.

Once that’s done, you’ll be back at the main screen.

Click once on your new Virtual Machine, and click the “Settings” icon at the top. You need to do a few more things first.

Configuring your Virtual Machine

In the “System” area, be sure to check “Enable IO APIC” in the “Motherboard” tab. In “Processor”, specify how many CPUs you want to use (ie. I had a Core 2 Duo, so I could choose more than one). You really only need 1 — if you’re doing stuff that requires more, you should probably boot into Windows natively.

In the Acceleration tab — some CPUs have the native instructions built for virtualization — modern Intel CPUs do. If you paid a little extra for your CPU and you bought it in the past year or two, you might have these. I forget the specific models that have it, but it’s something that’s easy to overlook. 🙂

Under “Display” area, adjust the slider to specify how much Video RAM you want to give your VM. I picked “64MB” for mine… very modest. You can also check “Enable 2d Acceleration” and “Enable 3d acceleration” simply because it won’t hurt to do so… but again, if you’re doing things that require hardware acceleration, a VM probably isn’t the best way to do it. 🙂 (sidebar: with computing power as strong as it is nowadays, you can realistically run 3D accelerated games in a VM, provided you can devote enough resources to it)

That’s it — the rest of the stuff is just icing. You can tinker with it if you want, but you’re good to go.

Click on “OK” to get out of there, then click “Start” (green arrow at the top). The first time you boot up, it may take a little while longer than usual.

This is the other point that is prone to errors. The first time I did this, I had errors because I didn’t do the -partitions parameter in my VDMK creation, which gave me “disk read” errors. You might get a blue screen of death or some other nonsense. If you get any errors — google it. Like I said earlier, there’s lots of support for it.

UPDATE (Additional Notes for Windows 7 Users)

To anyone struggling to get this running with Windows 7, I might be able to save you some time:

If Windows bombs straight to a blue screen of death on boot, in your VM go to settings->storage. If your .vmdk file is listed under SATA, then remove the attachment, then add a new hard disk under IDE, selecting your vmdk file. Next – and this is the crucial bit, in the storage settings again, select the IDE controller, then change its type to ICH6.

Save your settings, and your Windows 7 partition should boot – given you’ve followed all the previous instructions (particularly the windows 7 disc repair option part, which will get you past the ‘MBR 1FA’ problem.)

Thanks to Dan (@lazydan) for the feedback!

User-submitted Walkthrough for Windows 7

http://wiki.ubuntuusers.de/Dualboot-Windows_virtualisieren describes a solution for Windows 7 so that you won’t need to do a “Repair Installation” each time you want to switch from native to the VM and vice versa (you won’t need any Windows 7 Installation Disk at all)

First, run sudo fdisk -l on your host system, you’ll need the value behind “Disk identifier:” of the hard drive your Windows 7 is on.
After you’ve created the VM (leave out the step telling you to boot from the Windows 7 Installation Disk), attach an Ubuntu (or any other Linux) live CD image to the VM:
Settings -> Storage -> Controller: IDE -> Add CD Device (first icon) -> Choose Disk -> select the image of your live CD
Then boot the VM, it should boot the live CD image. Once you’re in there, run
sudo fdisk /dev/sda to start fdisk’s interactive mode (replace /dev/sda with the hard drive your Windows 7 is on).
Enter x, then enter i
Put in the disk identifier you’ve gathered in the first step, then press w to rewrite the MBR and quit fdisk.

After this, shut down the VM and remove the live CD image from the VM’s storage devices.
And note that the device name (e.g. /dev/sda) you have to use on the guest system might differ from its name on the host system.

Now you should be able to boot Windows 7 both natively and through the VM without Windows complaining.

To everyone else that has problems, I suggest you to read the wiki article linked at the top of my comment, it’s very comprehensive and has many troubleshooting tips at the end.

UPDATE: For Windows 8 Professional users

Julian says:

I’ve managed to get Windows 8 Pro (64bit) to boot in my 64bit version of Ubuntu 12.04.

I had a few issues getting it booting to start with, but using the windows 8 installation disk to get into command prompt and run

[cc]> bootrec.exe /fixboot
> bootrec.exe /fixmbr
> bootrec.exe /rebuildBCD[/cc]

got this working. I couldn’t access my other SATA HDD that carries all my media, (And adding this as a separate vmdk in my virtual machine’s options made it borky and not detect the original Windows installation), but I’ll try and work it out.

Once You’re In Windows

Some of the sites I’ve read have suggested creating an alternate hardware profile for when you boot into Vbox. This is a good idea if you plan on booting into it normally once in a while (for games or whatnot). To create a new Hardware Profile, right click on “My Computer” and click “Properties”. Select “Hardware” then at the bottom, select “Hardware Profiles”. Create a new one and name it “Raw Boot”, and rename the current one to “VBox Boot”.

Windows will go through some growing pains this first boot sequence, as it maps all the hardware drivers to the VirtualBox extensions provided — You will likely need to restart. No guarantees on all the hardware working as it does in a native boot. You should be able to use things like Word, browse the web, use Photoshop (if you allocated enough RAM…you can always change that later), etc. Anything relatively lightweight should be fine.

Working with Windows 7 (Update!)

One of the commenters below, Sandeep (“Sandy”), has figured out how to get a Windows 7 partition to work with this method. There are a couple small steps that need to be done, and he was cool enough to take screen shots for this blog:

  1. Before you begin, be sure your VDMK is configured, per the instructions above [screenshot]. You will also need to have the Windows 7 Rescue ISO loaded, which can be done within the VirtualBox configuration  (before starting a VM instance)
  2. Once that’s ready, boot up the Windows  7 VM [screenshot] Sandeep is using a newer version of VirtualBox, apparently, but AFAIK, it should still work even if yours says “Sun” instead of “Oracle”
  3. When prompted, boot to the rescue CD by pressing the appropriate key. [screenshot]
  4. At the menu, select “Repair Installation” [screenshot]
  5. Select “Repair & Restart” [screenshot]

I have not personally done this, but based on the comments below, this seems to work for most users. I gather that the problem is an issue of Windows 7 not liking being second banana in the MBR.

I am pretty sure that if you alternately boot raw and boot virtual, you will have to do this rescue disk procedure each time. Be careful with doing a repair on a raw boot, though, if you use Grub. Currently, I do not know of any way to use the partition for both Windows 7 raw and virtual boots without using the rescue disc fix.

Congratulations!

That’s it! Tinkering and optimizing aside, you’re done.

Further Reading

I would not have been able to do this without help from many other bloggers and hackers out there. Here are some of the resources I used to get this working:

232 Responses

  1. I’m getting stuck at one point:
    sudo usermod -a -G disk

    I’m using ubuntu Karmic, and I get an error message:

    usermod: user ‘disk’ does not exist

    Is there an equivalent user in 9.10?

    Javier

  2. I copied and pasted from the article:

    sudo usermod -a -G disk

    Thanks for the quick answer!

    Javier

  3. Nevermind, I got past that. I added my user to the disk group using the user and group manager on gnome. However, now I’m stuck at adding the VDMK file: When I hit add, I find two files. I tried with both, and I get a

    “Failed to open the hard disk /home/javierd/.VirtualBox/winxp-pt.vmdk.
    Could not open the medium ‘/home/javierd/.VirtualBox/winxp-pt.vmdk’.
    VD: error VERR_ACCESS_DENIED opening image file ‘/home/javierd/.VirtualBox/winxp-pt.vmdk’ (VERR_ACCESS_DENIED).”

    Best regards,

    Javier

    • Could you paste the command you typed? I think I know what you did wrong, but knowing your command would help me know for sure. 🙂

      IIRC, the issue might simply be a permissions issue with your /dev/sd* devices (your hard drives). Show me the command you used to create the VDMK and I should be able to identify the problem.

  4. Nevermind that last comment too… 🙂 Just a correction for this CLI:

    sudo VBoxManage internalcommands createrawvmdk -filename ~/.VirtualBox/winxp.vmdk -rawdisk /dev/sda -partitions 4 -mbr ~/.VirtualBox/FAKE.mbr -relative -register

    Must be run WITHOUT the sudo… otherwise, the permissions will be for root only 😉

  5. Ah!

    thank you — I will correct that above.

    cheers for that!

  6. Sorry to pester again, but I run into another issue: My Windows now asks me for activation!! >:( I have tried manually assigning the MAC ID’s in order to have them match the same as the fisical ones… but no luck! 🙁

    Native XP still boots up without issues, only when I start it through VB I get prompted to activate it…
    Any ideas?

  7. hmm… I didn’t have that problem.

    Can you tell me a little more about your situation? You’re using an existing Windows XP installation, right?

    On my system, I had a Windows partition that I was already using for dual-booting — that’s like what you have, right?

  8. Yes, exactly the same.

    Hmmm… It may have to do with licensing… mine is a OEM with a laptop. Maybe you have a retail version? For OEM, it checks some hardware serial numbers and uses that as a fingerprint for a machine… I’m guessing that because it doesn’t recognize the new values it believes I may have reinstalled it in another machine. I tried matching the MAC ID’s of the virtual interfaces, but didn’t work. The other thing I thought of, was having my VB use both processors (I have a core 2 duo laptop) instead of 1 as I did it at the beginning… but for some reason, it didn’t work with 2, only accepted one… I may just erase the windows partition and start running everything from VB, it may solve my problem, and I don’t really use Windows for much, just to access a Microsoft CRM web… ies4linux and IE with wine are not estable.

  9. Ahhhh… yeah — I have a retail (well, semi-retail — I bought it from my univ.) version.

    Not sure how to address that problem, but perhaps someone else on the Internet has had that experience? Windows is such a fickle beast w/r/t hardware and whatnot… it’s pretty ridiculous.

    The only time I ever really boot into windows is to play the 2 games I can’t get to work in Wine, use Reason 4, and use adobe CS4. that’s it. And I rarely do those things, even.

  10. Great post, Aaron. I’ve had a similar setup on my desktop / workstation since I first installed Linux a couple years ago. I must admit, you make the process seem much easier than I remember it being! Definitely useful though, as I do have a couple programs that from time to time I need from that partition. I’ve created a “true” virtual XP machine for the one program I use most often, mainly because when you run the physical WinXP install you don’t get features like snapshots and saving the machine state.

    Javier, I’ve encountered the exact same problem as you. I did the same thing with my laptop, using the WinXP key it came with. For some reason it just doesn’t like being booted up both physically and virtually. It always asks for activation when I’ve switched from one to the other, even though I have set up separate hardware profiles. So frustrating. For a while I was having to call Microsoft each time (over some threshold I guess) but now I’ve gotten back to where I just tell it to activate each time and it works. Annoying, but usable in a pinch. My desktop (which has an OEM licensed but self-purchased version of XP) has never once had this problem. Go figure. Good luck!

  11. Matt:
    I can totally see why those features would be helpful — really the only reason I am doing this is so that I can pop into InDesign, Dreamweaver, or SoundForge in a pinch. 🙂 I’ve heard that Vbox can translate 3d hardware to the vm, but never actually experimented with that yet — I’m kind of skeptical.

    I’m guessing that you and Javier’s problem with activation is that you were using an OEM copy of WinXP, rather than a purchased copy? The OEM copies tend to be nerfed slightly, since they’re subsisdized.

  12. Hello Aaron:
    I followed all the steps trying to boot my Win7 partition with a few issues of typing but no big deals. The last 2 steps were:
    peter@Mymachine:~$ install-mbr -f ~/.VirtualBox/FAKE.mbr
    peter@Mymachine:~$ VBoxManage internalcommands createrawvmdk -filename ~/.VirtualBox/win7.vmdk -rawdisk /dev/sda -partitions 1 -mbr ~/.VirtualBox/FAKE.mbr -relative -register
    VirtualBox Command Line Management Interface Version 3.1.2
    (C) 2005-2009 Sun Microsystems, Inc.
    All rights reserved.

    RAW host disk access VMDK file /home/phoboz/.VirtualBox/win7.vmdk created successfully.

    When i get the VirtualBox GUI i only found an existing hard disk named Win7.vdi so i took it and follow all the next steps.

    When i started the VM i get this: FATAL: No bootable medium found! System Halted

    Could you tell me which is my mistake?

    Regards

  13. Hello Aaron:
    I followed all the steps trying to boot my Win7 partition with a few issues of typing but no big deals. Some of the important steps were:

    peter@Mymachine:~$VBoxManage internalcommands listpartitions -rawdisk /dev/sda
    VirtualBox Command Line Management Interface Version 3.1.2
    (C) 2005-2009 Sun Microsystems, Inc.
    All rights reserved.

    Number Type StartCHS EndCHS Size (MiB) Start (Sect)
    1 0x07 0 /32 /33 1023/254/63 84434 2048

    peter@Mymachine:~$ install-mbr -f ~/.VirtualBox/FAKE.mbr
    peter@Mymachine:~$ VBoxManage internalcommands createrawvmdk -filename ~/.VirtualBox/win7.vmdk -rawdisk /dev/sda -partitions 1 -mbr ~/.VirtualBox/FAKE.mbr -relative -register
    VirtualBox Command Line Management Interface Version 3.1.2
    (C) 2005-2009 Sun Microsystems, Inc.
    All rights reserved.

    RAW host disk access VMDK file /home/peter/.VirtualBox/win7.vmdk created successfully.

    When i get the VirtualBox GUI i only found an existing hard disk named Win7.vdi so i took it and follow all the next steps.

    When i started the VM i get this: FATAL: No bootable medium found! System Halted

    Could you tell me which is my mistake?

    Regards

    • I don’t know how much help I can be, since I havent used Win7 at all — my first guess is that Win7 has different reqs than XP as far as the MBR is concerned; Windows tends to be very jealous and wants a monogamous relationship with your hard disks. XP wont run unless you spoof its presence in the mbr (as you’ve seen). If Win7 is even more jealous, then your best bet is to start googlin’! 🙂 If you DO find anything interesting regarding this particular issue, I’d love to hear about it!

      On the off chance its something else, can you post the result of fdisk -l for me? I might be able to help if I can see your partitiion table.

  14. Tks Aaron!! Sure… here it is:

    Disk /dev/sda: 120.0 GB, 120034123776 bytes
    255 heads, 63 sectors/track, 14593 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Disk identifier: 0x57c6d2a2

    Device Boot Start End Blocks Id System
    /dev/sda1 * 1 10764 86460806 7 HPFS/NTFS
    /dev/sda2 10765 14593 30756442+ 5 Extended
    /dev/sda5 10765 14429 29439081 83 Linux
    /dev/sda6 14430 14593 1317298+ 82 Linux swap / Solaris

    Disk /dev/sdb: 41.1 GB, 41110142976 bytes
    255 heads, 63 sectors/track, 4998 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Disk identifier: 0xa8418303

    Im googling and changing some parameters, if i success ill be happy to share…
    🙂

  15. Hey,

    Some users having problems to activating their windows-xp after migrating it to virtualbox due to connectivity problems. The original windows seems to remember the MAC-Address of your network adapter, be sure to set the mac-address of your virtualbox adapter to the one you physically have – worked for me.

    Cheers

  16. Another note: If you experience Bluescreen after migration, reboot into windows, apply the MergeIDE drivers to your current windows installation. See MergeIDE ( http://www.virtualbox.org/wiki/Migrate_Windows ). MergeIDE populates your windows installation with standard drivers which should work with Virtualbox. After having MergeIDE successfully installed, boot your windows with Virtualbox.

  17. Thanks for this tutorial !!
    Based on it I was able to load an
    existing Windows Vista partition in VirtualBox OSE !!
    I don’t know why you said not to use OSE. I work to a company and OSE was so much required because it is free and even if it’s old it does it’s job.
    Using grub image didn’t work for me (would receive “Unknown partition type 0x7”) and I removed it from booting sequence. After creating the vmdk file I just power the machine (no grub). The only thing though I need to repair Vista boot with Vista’s CD using Repair option. Otherwise would say that it needs repaired and cannot boot. Another thing was that I needed to activate Windows again after booting in VirtualBox with the same key it was before (key written on my computer box). I had some problems (blue screens) with the programs that had attached all kinds of drivers to them (drivers that failed in VirtualBox). After removing them from the system Vista worked, I used them anyway on Linux.
    So, I have a Vista licensed activated and working in Linux. By the way I hate Windows…

    • Terrific! I’m glad you were able to do it!

      My reason for advising against OSE is for two reasons:

      1. Sun does not keep the OSE up to date as much as the closed source version, so it’s going to be older.
      2. Options such as Guest Additions are not available in OSE (this is more of an extension of #1, since I think it’s simply a version issue.)

      OSE *is* perfectly functional, but unless you plan on hacking the code or modifiying it in some way, there’s really no reason to limit yourself to the OSE version.

      I think the reason you needed to repair the boot was because Vista is very jealous about the MBR — it doesn’t like not being top dog.
      Your hardware drivers issue: Try creating a separate hardware profile. I don’t know how to do it in Vista, but in XP it’s under My Computer -> Properties. This step is somewhat critical if you plan on being able to boot into Vista directly still — separate hardware profiles will keep the drivers that work fine in solo boot working, but also allow you to disable the drivers that DON’T work in a vbox boot.

      Glad to hear you got it working though, I’ll put a note up in the post.

  18. My question for you is this: How do you make a fake MBR file in Fedora 12? There is no MBR program for it that I was able to find. I have a good feeling that’s why my Windows XP will not start. I get the windows splash, but then the blue crash screen seconds later. If you can tell me where to find a program to generate the FAKE.mbr file for Fedora, please let me know.

  19. Yazlanka — sorry for the delay in approving / replying. I’m usually a lot quicker than that. 🙂

    The program is pretty basic, you could *probably* download the .deb of mbr from one of the debian / ubuntu repositories, then use “alien” (yum install alien, I think) to convert it to an RPM.

    I haven’t used Fedora core since FC9, unfortunately, and I don’t have it installed on any systems right now. :/

    Try that out, though — I don’t think it should give you any problems. Let me know if you have any success — I’ll update the blog post with your findings. Thanks!

  20. I tried the above method and failed. All the preparations go well. And the MBR seems working because I can see the boot loader interface. But when booting the windows XP error shows up with ” file ntldr ” and a standard error code 0xc000000e. I think the reason is VM can not read any information from the VMDK file winxp.vmdk, because I am sure the ntldr file is there in the windows partition.

    I have both windows xp and win7 installed on different partitions, and use win7 boot loader. Could that be the reason ?

    • I don’t know that the instructions above will work for Windows 7, my guess is that they revised the bootloader for Windows 7 — since it’s not based on the 2000 kernel, that’s a pretty strong hunch. 🙂

      I unfortunately don’t have Windows 7, so I have no way of testing out a new solution for it. :/

      HOWEVER

      The bootloader is only necessary to fake the MBR for the win XP partition — I’m pretty sure you can fake it for just the XP partition and have Win7 be completely unaware of it. What is your partition scheme for your computer? I bet we can get a VBox working for you with WinXP, but I can’t promise anything for win7.

  21. OK. Here is my partition list

    Device Boot Start End Blocks Id System
    /dev/sda1 * 1 1912 15358108+ 7 HPFS/NTFS
    /dev/sda2 1913 35089 266494221 5 Extended
    /dev/sda3 35090 38913 30716280 7 HPFS/NTFS
    /dev/sda5 1913 15332 107796118 7 HPFS/NTFS
    /dev/sda6 15333 17320 15968578+ 83 Linux
    /dev/sda7 17321 21654 34812823+ 83 Linux
    /dev/sda8 21655 21859 1646631 82 Linux swap / Solaris
    /dev/sda9 21860 30384 68477030+ 7 HPFS/NTFS
    /dev/sda10 30385 35089 37792881 83 Linux

    sda1 is where windows xp is , and you see it’s also the default boot partition. I also have windows7 install in sda9, and the win7 loader is installed on sda1.
    Now I use grub as the global boot loader, which means I have grub installed on MBR.

    Actually thre is one thing I can not understand. I tried the above method and I can see the win7 boot loader interface. But I believe the real MBR in my disk should be the grub boot code and it’s stage1. So where does this win7 loader boot interface come from ? Or maybe the real question is : what did this command “install-mbr -f ~/.VirtualBox/FAKE.mbr” really do ?

  22. I think the fake MBR file tricks Windows XP into thinking that it was booted up normally. IIRC, without the fake MBR it will begin booting but ultimately fail. The documentation for install-mbr said that it just copies your existing MBR into a file. VBox will then use that file to spoof the bootup process.

    It’s not like creating the VDMK where you have to specify the partitions and all — the fake MBR is basically a dummy file that simply needs to be there to reassure windows that “it’s ok, you’re not being booted into a virtual console, I promise,”

    As far as Win7 is concerned — I don’t know if this will work or not, particularly since it’s built off of a different kernel.

    One thing that puzzles me about your situation is that I think you said you are getting the boot loader (GRUB, right?) interface? I don’t get that when I do mine, even though I *do* have GRUB loaded for conventional dual-booting. FWIW, My linux partition is sda1 and winXP is sda4. I don’t know that will make a difference, though.

    The error code you’re getting sounds really familiar, and I wish could remember it.

    I just reviewed some of my resources and did a quick google search — you’re kind of pioneering new territory with the Win7 hybrid machine.

    How much different were the steps listed above from those that you had to take to get to where you’re at? Were there any deviations?

    when mine boots up, I see the Sun Vbox splash screen, then a black screen with “MBR” in the top left corner, then the windows XP loading splash — no grub or anything.

  23. First let me clarify some points

    1. I’m using grub as the default boot loader, and have windows xp ,win7 and Ubuntu installed.

    2. When I boot in VM, I first see the black screen with “MBR”, then the win7 boot loader interface, not the grub’s.

    After reading your explanation I understand why that happens: The fake mbr boots the system to trigger the boot sector of the vmdk disk, which is exactly where win7 boot loader is located. In your case the fake mbr triggered the winxp boot loader, and if you only have one system installed, there should be no loader interface, you got into windows xp directly. If you add to the file boot.ini another line of boot entry, I think you’ll also see the loader interface, i.e., the loader interface of windows xp.

    3. When I follow the steps, I do encountered one deviation. I ran the command “sudo usermod -a -G disk”, and the system said “no user disk”.
    So I open the users-admin gui, and added myself into the disk group.
    Everything else is OK.

  24. At the very beginning, I am having difficulty with install-mbr.

    “install-mbr –force ~/.VirtualBox/FAKE.mbr” returns
    Offset must be a number: rce

  25. Hey there, thanks a ton for the guide, and the laughs 🙂 Only problem is I’m hitting a road block and am thinking it’s because Oracle might have changed VB around a bit since you wrote this? anyway, i’m pretty sure i’m doing everything right, but am getting this error:
    Number Type StartCHS EndCHS Size (MiB) Start (Sect)
    1 0x07 0 /1 /1 1023/254/63 152626 63
    root@ubuntu:/home/owner# sudo chmod 666 /dev/sda1
    root@ubuntu:/home/owner# sudo chmod 660 /dev/sda1
    root@ubuntu:/home/owner# VBoxManage internalcommands createrawvmdk -filename ~/.VirtualBox/wixxxxxnxp.vmdk -rawdisk /dev/sda -partitions 1 -mbr ~/.VirtualBox/FAKE.mbr -relative -register
    WARNING: The vboxdrv kernel module is not loaded. Either there is no module
    available for the current kernel (2.6.32-22-generic) or it failed to
    load. Please recompile the kernel module and install it by

    sudo /etc/init.d/vboxdrv setup

    You will not be able to start VMs until this problem is fixed.
    WARNING: The compilation of the vboxdrv.ko kernel module failed during the
    installation for some reason. Starting a VM will not be possible.
    Please consult the User Manual for build instructions.
    Oracle VM VirtualBox Command Line Management Interface Version 3.2.4
    (C) 2005-2010 Oracle Corporation
    All rights reserved.

    RAW host disk access VMDK file /root/.VirtualBox/wixxxxxnxp.vmdk created successfully.

    and upon following their instructions, sudo /etc/init.d/vboxdrv setup, i get this error

    Number Type StartCHS EndCHS Size (MiB) Start (Sect)
    1 0x07 0 /1 /1 1023/254/63 152626 63
    root@ubuntu:/home/owner# sudo chmod 666 /dev/sda1
    root@ubuntu:/home/owner# sudo chmod 660 /dev/sda1
    root@ubuntu:/home/owner# VBoxManage internalcommands createrawvmdk -filename ~/.VirtualBox/wixxxxxnxp.vmdk -rawdisk /dev/sda -partitions 1 -mbr ~/.VirtualBox/FAKE.mbr -relative -register
    WARNING: The vboxdrv kernel module is not loaded. Either there is no module
    available for the current kernel (2.6.32-22-generic) or it failed to
    load. Please recompile the kernel module and install it by

    sudo /etc/init.d/vboxdrv setup

    You will not be able to start VMs until this problem is fixed.
    WARNING: The compilation of the vboxdrv.ko kernel module failed during the
    installation for some reason. Starting a VM will not be possible.
    Please consult the User Manual for build instructions.
    Oracle VM VirtualBox Command Line Management Interface Version 3.2.4
    (C) 2005-2010 Oracle Corporation
    All rights reserved.

    RAW host disk access VMDK file /root/.VirtualBox/wixxxxxnxp.vmdk created successfully.

    i think this is the good stuff from the log:

    echo ” ERROR: Kernel configuration is invalid.”;
    echo ” include/linux/autoconf.h or include/config/auto.conf are missing.”;
    echo ” Run ‘make oldconfig && make prepare’ on kernel src to fix it.”;

    anyway, i’m looking forward to your response! hopefully sooner than later because i would love to see this baby work 😉

    • Hi! Glad you enjoyed it 🙂

      Ok — first off, which version of VBox are you using?

      I had to use Virtualbox closed-source, downloaded directly from them. If you are using the Vbox OSE package, I can’t guarantee this will work.

      Did you try doing: sudo /etc/init.d/vboxdrv setup as it suggested? What was the result?

  26. Nice! Wasn’t expecting such a timely response 🙂

    I am using this version downloaded direct from VB’s website, I believe this not to be the OSE edition as provided in the Ubuntu Software Repository. Specifically, this is what I installed: http://download.virtualbox.org/virtualbox/3.2.6/virtualbox-3.2_3.2.6-63112~Ubuntu~lucid_amd64.deb

    Second, this is the error in the log file:

    i think this is the good stuff from the log:
    echo ” ERROR: Kernel configuration is invalid.”;
    echo ” include/linux/autoconf.h or include/config/auto.conf are missing.”;
    echo ” Run ‘make oldconfig && make prepare’ on kernel src to fix it.”;

    Thanks!
    Robert

  27. I try to respond somewhat quickly 🙂

    Let me check on that when I get home — I want to see what version I’m running. It sounds like it may just be a dependencies issue — my first guess is that you need the kernel-source package installed — If you check in synaptic for them, you should be able to load those.

    I’d start there. If it doesn’t fix the problem, no harm done — it’s just space on your drive. 🙂

  28. I will definitely do some more strolling around the site sometime soon, I am sure to find some more awesome content 🙂

    So not that I am intending on being spoon fed or anything as I opened the Synaptic Package Manager and searched for kernel-source, but see a ton. Some make sense to me, like the ones with VSE, but I’m not sure which ones to enable/install.

    Thanks again,
    Robert

    • Sorry for the belated reply — I’ve been approving comments from my phone while we work on prepping our house for sale. 🙂 Just finally got time to sit down at the laptop.

      The package you want is “linux-source”, sorry — Try installing that package (apt-get install linux-source) and that should do it. Let me know if it doesn’t work.

  29. Aaron,
    Thanks for publishing this, I’m running into the same problem as Puzzled in comment 31:

    At the very beginning, I am having difficulty with install-mbr.
    “install-mbr –force ~/.VirtualBox/FAKE.mbr” returns
    Offset must be a number: rce

    Could you let me know how to get around that?

    Thanks

  30. Hey there I’ve run into a problem when I try and set up the VMDK file. Here is the command I ran pretty sure its exactly the same as what you have listed above and then I also included the output:

    VBoxManage internalcommands createrawvmdk -filename ~/.VirtualBox/winxp.vmdk -rawdisk /dev/sda1 -partitions 1 -mbr ~/.VirtualBox/FAKE.mbr -relative -register

    ERROR: VMDK: incorrect partition data area ordering set up by the caller in ‘/home/shauna/.VirtualBox/winxp2.vmdk’
    Error code VERR_INVALID_PARAMETER at /home/vbox/vbox-3.2.6/src/VBox/Devices/Storage/VmdkHDDCore.cpp(3492) in function int vmdkCreateRawImage(VMDKIMAGE*, VBOXHDDRAW*, uint64_t)
    Error while creating the raw disk VMDK: VERR_INVALID_PARAMETER
    The raw disk vmdk file was not created

    Thanks for any help you could provide.

    • @Shauna #38 – Can you please comment back with your partition table data? Type:
      fdisk -l

      and paste the output here. If your partition table is different from mine (certainly possible), you will have to setup that VMDK file differently.

  31. To everyone experiencing the “offset must be a number: rce” problem — I realized why this was:

    In my instructions, the font doesn’t make it clear, but you must use TWO dashes (-) before the “force” for it to work. I will update my instructions above to reflect that.

    Alteranately, and this is what I will change it to above, you can just use a single dash and use the “f” flag.

    install-mbr -f ~/.VirtualBox/FAKE.mbr

    I just tested it and it works. 🙂

    What was happening was that it was seeing:
    -force and interpreting it as if you had typed:
    -f -orce

    the “-o” flag specifies an offset, and “rce” is clearly not a number.

    Hope that helps!

  32. Here you go. Thanks

    Disk /dev/sda: 80.0 GB, 80026361856 bytes
    255 heads, 63 sectors/track, 9729 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x95aa95aa

    Device Boot Start End Blocks Id System
    /dev/sda1 * 1 5100 40959968+ 7 HPFS/NTFS
    /dev/sda2 9025 9729 5654880 c W95 FAT32 (LBA)
    Partition 2 does not end on cylinder boundary.
    /dev/sda3 5100 9025 31531009 5 Extended
    /dev/sda5 5100 8858 30186496 83 Linux
    /dev/sda6 8858 9025 1343488 82 Linux swap / Solaris

    • Based on what I read on the Vbox forums here:
      http://forums.virtualbox.org/viewtopic.php?p=26912

      It looks like you aren’t the only one with this problem. I *think* the crux of your problem is the fact that you’re using an extended partition, but the note that “Partition 2 does not end on a cylinder boundary” seems to be more damning.

      See this comment from that link above, written by one of Vbox’s site moderators:
      http://forums.virtualbox.org/viewtopic.php?p=26912&sid=5a7f106e3c227378f9323e67d9b51486#p26912

      The problem that you guys are having is actually because of a bug in src/VBox/Frontends/VBoxManage/VBoxInternalManage.cpp. Function partRead builds an internal partition table from the partition sector and then adds the extended partitions. It then does a simple exchange sort to order these, checking for overlaps etc. as it goes (lines 595-641). What it doesn’t do is to exclude the Extended Partition Entry from these checks, and of course this does overlap and start at the same place as other partitions, so of course this validation fails. So why doesn’t fail all the time? Ah, that’s because a second bug means that these checks aren’t always applied, so if the Extended Partition is the last one, we have a case of two wrongs making a right, or maybe in this case a write

      It’s a bug in VBox, I guess.

      As far as what you can do:

      You’re only *really* using 4 partitions, so the extended partition is unnecessary — If you have the luxury of being able to dust off the whole drive and starting fresh, that would be ideal.

      If that’s *not* the case, and you are able to backup / re-install Linux, what I’d suggest is to boot into gParted [gparted.sourceforge.net], blow away partitions 3, 5, 6, then create partitions 3 (type 83) and 4 (type 82) as primary partitions.

      That *should* fix the problem. 🙂 Sorry it’s not something easier :/

  33. I’m new to open source..
    I want to use my other partitions too while using virtual box…
    will i be able to use the other partitions…

    PS:I have installed Windows 7 in virtual box
    Currently using Ubuntu 10.04

    thnx in advance

    • There *is* a way to do that, but it’s somewhat tricky, and potentially dangerous.

      The step where you create the VDMK, you can specify other partitions with the -partitions flag. I’ve never done that PERSONALLY, but I think it would be something like: -partitions 1 2 3 4 instead of just -partitions 4 if you wanted the VBox guest to have access to partitions 1-4.

      the danger here is that you should *not* give it access to to any partitions that are currently mounted — ie. do not specify your active linux partitions!

      If, for example, your partition table was something like this:

      1 – Linux Native
      2 – Swap
      3 – Linux Native
      4 – [extended]
      5 – NTFS (Win XP)
      6 – FAT32 (Win 95)
      7 – FAT16 (Win 3.x)

      And you wanted the VBox session to have access to partitions 5, 6, and 7 — that’s probably OK to do. But do *not* give it access to partitions 1-3 (assuming those are all mounted).

      If you are simply wanting to share files between Linux & windows, your best bet is to use the internal VBox “Share a folder” feature, then map a network drive within the Windows VBox session — that’ll allow you to easily copy stuff to/from the host OS (Linux). I strongly discourage mounting additional partitions unless they are absolutely necessary for the guest OS to function, however.

  34. Hi Aaron,

    Great blog post! All of the steps work very smoothly, except for the step where I was supposed to add myself to the disk group- for some reason it complained there wasn’t a group called disk. I added myself via the gui group manager though. I’m getting back to linux after a long, dark night in Windows-land (long story), and bloggers like you are one of the reasons this has been easy and fun! Thanks for taking the time to share what you know.

    • Glad it’s worked well for you so far!

      A number of people have had issues with the usermod command — the GUI group manager seems to be the more successful route to take; glad you were able to figure it out on your own. I’ll update my original post to reflect that.

      Be sure to check out the rest of my Linux FTW series, if you’re just getting back into things. 🙂 (Oh, and be sure to look into WinE — it’s changed a *LOT* in the past few years and with the easy installation of DirectX you can play many modern games in linux — they actually run better without all the Windows overhead. 🙂

  35. WOW dat was a quick reply…
    Basically all i want is to access all my installed softwares(Installed in WIndows 7)
    in the Windows7( guest OS),
    which will help me in not to reinstall the softwares again….

    hope u r getting my pt. 🙂

    i did tried d 2nd option dat u suggested(sharing) but came of no use…
    & plz can u ellaborate on “then map a network drive within the Windows VBox session…”
    thnx *_*

    • Once you have the stuff in the original post set up (with your VDMK and all that), you can do this:

      There is an option inside of the Virtualbox software (load it in Linux from the main VirtualBox interface). Click on your Virtualbox guest OS (Windows XP in my case — Windows 7 in yours) and click “Settings”
      then choose the last option, “Shared Folders”
      Click on the folder that has a “+” on it, on the right side, to add a shared folder. On my system, I use /home/aaron/Public — but you can use whatever you like (/home/sandy/Documents/ for example).
      Once you’ve selected all the folders you want to share, click “OK” to get out of there.

      when you start the Virtual Machine (*not* when you boot into Windows from a clean boot), you will see those shared folders under your Network Places — it should show up as if it were another computer on your home network. 🙂

      Which Linux OS are you using? Ubuntu? Fedora core? I can give you more specific information to help you if I know what you’re running. 🙂

  36. Aaron,
    Thanks for all your help I went a head and blew away my linux and the extended partition as well here is what I get when I run fdisk -l

    Disk /dev/sda: 80.0 GB, 80026361856 bytes
    255 heads, 63 sectors/track, 9729 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x95aa95aa

    Device Boot Start End Blocks Id System
    /dev/sda1 * 1 5100 40959968+ 7 HPFS/NTFS
    /dev/sda2 5100 9476 35155968 83 Linux
    /dev/sda3 9476 9730 2034688 82 Linux swap / Solaris

    I’ve tried to get the command to run:

    VBoxManage internalcommands createrawvmdk -filename ~/.VirtualBox/winxp.vmdk -rawdisk /dev/sda1 -partitions 1 -mbr ~/.VirtualBox/FAKE.mbr -relative -register

    But I still get the same error output:

    Error code VERR_INVALID_PARAMETER at /home/vbox/vbox-3.2.6/src/VBox/Devices/Storage/VmdkHDDCore.cpp(3492) in function int vmdkCreateRawImage(VMDKIMAGE*, VBOXHDDRAW*, uint64_t)
    Error while creating the raw disk VMDK: VERR_INVALID_PARAMETER
    The raw disk vmdk file was not created

    Anything else I could try?

    Thanks
    Shauna

    • Yes, I see one tiny little thing you can do differently that might make it work:

      You typed:

      VBoxManage internalcommands createrawvmdk -filename ~/.VirtualBox/winxp.vmdk -rawdisk /dev/sda1 -partitions 1 -mbr ~/.VirtualBox/FAKE.mbr -relative -register

      But try this instead (changing “sda1” to just “sda”)

      VBoxManage internalcommands createrawvmdk -filename ~/.VirtualBox/winxp.vmdk -rawdisk /dev/sda -partitions 1 -mbr ~/.VirtualBox/FAKE.mbr -relative -register

      You only need to specify the device itself for the “rawdisk” option — the “partitions” option takes care of specifying the partitions on that disk. 🙂

      Try that out — I bet it’ll work for you.

      Good luck!

  37. Awesome tutorial….
    Well For WIndows 7 users all you have to do is

    “To use your Windows Installer and select Repair option…”

    Nice work Aaron

    • That will more than likely restore the actual MBR to boot Windows primarily, but will probably not help with getting the VirtualBox VDMK set up — what did you use that for, in your situation?

  38. It works for me…
    Rebooted my system…& no changes were made to the actual MBR…

    # I have a query & i want to post a screenshot of my query…

    • I think you might be misunderstanding me —

      This post isn’t about doing a “dual boot” setup, where you have both Windows and Linux on the same computer. In those cases, yes, doing a “Repair windows installation” would help to fix the problem by resetting the MBR to be windows-friendly.

      This post is about using VirtualBox (virtualbox.org) to run an existing Windows partition *while currently booted into Linux*. ie. I boot into Linux, click a single icon in my applications menu, and then Windows boots up in a separate window. Check out here and here for examples of what I mean.

      Normally, you have to create a separate “disc image” to use with VirtualBox, but with the instructions above, you can use an existing partition completely, without modifying it.

      As far as how to post a screen shot — the comments area unfortunately doesn’t support uploading, but if you can find some way to post it online (twitpic.com, imageshack, and other online storage systems will all work) you can link to it from here and ask your question. 🙂 I’d be happy to take a look!

  39. http://picasaweb.google.com/sandyridgeracer/DropBox?authkey=Gv1sRgCJLU8Kbnt97oNA#5492938771966452978

    I want the VBox to utilize the whole screen..i.e. i dont want those white void spaces…is there any way by which i can chage the “resolution”.

    in previous posts I meant “to boot your windows7 installer dvd in #VBox and then select repair ”

    🙂

    • Ah! Ok — glad we cleared that up. That’s good to know, I’ll add it to the original post above!

      As far as VBox utilizing the whole screen, there are a couple things you can try:
      – While in your session, click on “Machine” then “Fullscreen Mode”
      – Install “Guest Additions” (requires you to *not* use the OSE version), then enable “Seamless Mode” (also found under “Machine”

      Fullscreen mode may require Guest Additions to enable it, I’m not sure.

      Fullscreen mode will use up all your screen real estate, but it might take a couple minutes before the Windows desktop auto-resizes to fit the screen.

      Fullscreen mode works kind of like Remote Desktop in Windows — there’s a tab at the top that will emerge if you move your mouse to the top of the screen. You can also just press the Host key (Right-Ctrl on my system) and “F” at the same time, that’ll exit out of it.

      Hope that helps!

  40. thnx a lot….

  41. I am using Ubuntu 10.04 that installed using Wubi on my Windows Vista (double booting). Now mostly I am working in Ubuntu and I want to access Windows Vista using VB. I just share Ubuntu and Windows on the same partition /dev/sda2 mounted to /host, so how can I run my existing Windows Vista using VB inside my Ubuntu? Please help 🙂

    • My advice here will be somewhat limited as I have never *personally* loaded Windows Vista in Linux VBox — but I know a couple of the commenters have — be sure to read through the comments for some extra insight. (Check Bogdan’s comment specifically)

      As far as how to do it:
      Start out by going through the steps listed above — AFAIK, the process of getting a Vista VDMK registered with Virtual box is nearly identical to doing it with Win XP except there are some last minute finessing steps w/r/t getting Vista to play nice with being second banana.

      Once your VDMK is registered with VBox, you can adjust the settings to establish a specific folder / network drive inside of your Vista guest session so that you can access the host (Linux) — this is useful for when you want to copy files into or out of the VBox guest session.

      Let me know where you’re at with the process. Don’t be too intimidated by it — the commands listed above aren’t really capable of inflicting any damage on your system. 🙂 You can do it!

  42. Hi, I tried everything and can’t get passed the winxp splash screen. It just freezes there, no error messages or anything. When I disabled the intelppm in the registry I got the blue loading bar to appear, but nothing happened. Any help for me?

    • You can’t get past the splash screen in a VBox boot? How long have you waited? For some reason, it occasionally takes me 5 minutes to boot completely — other times it’s much quicker.

      I recommend “Saving the Machine State” when you quit, rather than shutting down outright — although I don’t know what kind of effect that would have if you saved the machine state and then booted into it normally. I don’t *think* it would be a problem, but I have not experimented with that yet.

      So for now — try booting it and just let it sit for a while — give it 10-15 minutes (go make some coffee or something 🙂 and if nothing changes STILL, we can try something else.

      oh btw — be sure you “Create a new Hardware Profile” — I think it’s in the same area as Device Manager? (Right-click My Computer, select “Properties”, then “Add new hardware profile”). Name one of them “VirtualBoxBoot” and the other “NormalBoot” — set it to default to whichever one you are likely to use more often (I generally select the VBoxBoot one simply for convenience).

      VirtualBox uses some different hardware adapter configurations than a normal boot will, since it has some of its hardware virtualized. Having separate hardware profiles should decrease your boot time substantially, I think. You will need to boot into it successfully once before you can get the VBox configuration made though.

  43. yo, hey, nice tutorial so far, but for me it seems not to be as easy as it is for some guys. i have windows 7 on partitions 1, 2 and 3 and all commands in linux worked without any flaws. still i cant get past the windows-start-manager which appears directly after the mbr-screen.
    @ sandy: how did you repare inside the vb? thx

    • Make no mistake — it’s challenging for everyone. 🙂 Success seems to be a direct function of persistence, in this case.

      IIRC, Sandy got it to work by booting the Virtual Machine and telling it to “Repair the MBR”? If we can get a final verified answer on this, I’ll add it to the original post.

  44. Well, reparing with a virtual cd-image works very well, as long as I stay inside the vb. Have to test starting the system from grub though…

  45. Martin — please post back here if it was successful, and if you remember, the exact steps you took — I’ll add it to the OP and credit you and Sandy for figuring it out. 🙂

  46. Hey Aaron, it’s not the final solution we hoped to find.
    But as long as you only want to migrate it’s what you need. If you still want to use it natively from time to time, then you will have to repair every time you change the way of starting the system.
    The steps:
    Produce an iso-image from your recovery disk or get one in the net.
    Go to the vb settings, storage (I don’t know the exact name, have the german language installed), select the cd symbol, go to the drive dialog and choose your image.
    Start the virtual machine –> a few options pop up, choose the one one top which is the repair option, restart and you are there.

    When I started windows from scratch it updated the 27k entries in the registry and proposed to repair itself.
    The only thing which is left is to skip repairing and see if the virtual way is still working that way.
    Cheers,
    Martin

  47. “Use recovery tools that can help fix problems starting windows” 😀

  48. My persistence is at it’s end.
    It would be good to somehow find the diff between the windows-system before and after repairing, but I dont have the knowledge nor the time to do so atm.
    Greetings,
    Martin

  49. Thanks a lot for your good, plain and so fun explanation, the better is that worked.
    The only one thing I made different was to make me a disk user:
    sudo usermod -a -G disk says me that there wasn’t a user called : disk , but i made through the GUI .
    Well be sure whenever there is an award for better explanation on that subject I will vote you.

  50. Hello

    I tried this tutorial but once I have finished everything and I try to launch my windows 7 into VirtualBox, I only see :
    MBR 1FA:
    What’s wrong ?
    Thanks

    • Pim — Please see the previous comments by both Martin and Sandy — I think those will provide you with the info you need to solve it. 🙂

  51. oops!!!

    Thanx to aaron, i hv been using windows 7 in the virtual box…

    One of the problem with this technique is dat u hv to keep on repairing..

    By repair I mean :suppose if u r using windows 7 in VB and den u plan to use the *actual* windows installed(by rebooting and selecting windows 7 from d grub),
    den ur windows will automatically repair it once u boot it.

    Now one more scenario is dat u r using d *actual* windows and u plan to use win 7 in VB den u hv to manually repair it.This is done by creating an WINDOWS INSTALLER ISO file and boot it in VB and boot windows in VB using dat ISO file and finally repair it.

    queries are welcome…
    can also post screenshot if required…

  52. @pim: just create an iso file of windows installer and boot it in your VB and repair it.This will fix the error… 🙂

  53. ur emal-id…

  54. I tried this with windows 7 and got it working. Only had to repair once.
    Also have successfully created an image from it and can use it as a regular vm image with everything in it. Thanks a lot for this post.

  55. very nice tutorial! Thanks! 🙂

    just a small correction: missing user-name from usermod
    sudo usermod -a -G disk

    then perfect!

  56. First of all this is a great tutorial, the most informative in the web regarding how to boot an already installed windows partition while at the same time being able to boot it in the normal way when you want. I am also trying to implement this,however i get the following

    # VBoxManage internalcommands createrawvmdk -filename ~/.VirtualBox/winxp.vmdk -rawdisk /dev/sda -partitions 1 -mbr ~/.VirtualBox/FAKE.mbr -relative -register

    Oracle VM VirtualBox Command Line Management Interface Version 3.2.8
    (C) 2005-2010 Oracle Corporation
    All rights reserved.

    ERROR: VMDK: could not open raw partition file ‘/dev/sda1’
    Error code VERR_DEV_IO_ERROR at /home/vbox/vbox-3.2.8/src/VBox/Devices/Storage/VmdkHDDCore.cpp(3649) in function int vmdkCreateRawImage(VMDKIMAGE*, VBOXHDDRAW*, uint64_t)
    Error while creating the raw disk VMDK: VERR_DEV_IO_ERROR
    The raw disk vmdk file was not created

    I am running Red Hat Enterprise 5.5, and i am trying to boot my native windows xp partition. (my hard drive is RAID with another hdd in a mirror configuration). Windows are indeed in partition sda1 while i have fixed the permission according to the instructions provided here, however i get the message above. Any ideas?

    thanks a lot

    • Dim, Thanks for stopping by!

      The first thing I would check is to see whether or not you have that partition already mounted. I forget if that makes a difference or not, but it’s worth trying.

      The second thing I would check is to (a) ensure that you have added yourself to the “disk” users group (or the equivalent for RH), and (b) that the “disk” users group (or its RH equivalent) has full access to that particular partition.

      It’s been a few years since I’ve used RH / FC, so the idiosyncratic differences between Deb/RH systems aren’t so fresh in my mind now. Check those things first then come on back. 🙂

  57. To poster #9 ‘dim’

    I had the same error, and it was because I forgot to log out then log back in to reset my permissions. After that everything was good.

  58. WinXP is asking me to activate it again. Do I need to do this, or is there a way to make it see the activation I’ve been using for my physical boot?

    • Are you using the OEM version? I think some other people were having similar versions.

      You can try activating again, I don’t know firsthand what the consequence will be, however.

  59. Aaron thanks a lot for this article.

    Everything went fine, including Windowns 7 32bit Rescue CD iso image.

    But when it goes to starting the Win7 itself, the startup crashes after the initial logo, gives a super fast green screen saing something about the display (wasn’t able to take the screenshot despite tried several times). I’ve tried changing display settings both on VB and Win7, no success 🙁

    The strange thing is the rescue CD flows just fine in X mode

    Using Ubuntu 10.10, VB 3.2.10, Windows 7 Enterprise

    Any idea?

    Cheers!

  60. Hi!

    Thanks for this awesome and very easily readable guide. I have the same problem as pim with the text MBR 1FA, I have no ideal how to create a windows installer .iso or a windows system rescue CD, any help?

    • Karlabob,

      Most CD Burning applications (Nero, Brasero, etc) should allow you to “create a disc image” of an existing CD. This is only really necessary if you are using Windows 7 (or, based on some comments I’ve read, Windows Vista). A Windows XP installation *shouldn’t* need it, but it’s a good idea to have one around just in case anyways.

      Can you be more specific about the error you’re getting?

  61. Your guide was very easy to follow and I received no errors until I tried to load the vmdk file in VirtualBox. I am new to this, so I may have miss something.

    I keep getting the following:

    Failed to open the hard disk
    /home/xxxxxx/.VirtualBox/HardDisks/winxp.vmdk.

    Could not open the medium
    ‘/home/xxxxxx/.VirtualBox/HardDisks/winxp.vmdk’.

    VD: error VERR_ACCESS_DENIED opening image file
    ‘/home/xxxxxx/.VirtualBox/HardDisks/winxp.vmdk’
    (VERR_ACCESS_DENIED).

    I believe my problem is that it appears to be two Virtual directories on my system. (not sure, but that is how it looks to me) if I issue a ~/.VirtualBox it takes me to a directory where the files I created are there. There appears to be a hidden directory under my home/xxxx/.VirtualBox/HardDisks it does not contain the files I created. I then went back to ~/.VirtualBox and under that directory there is not HardDisks directory like the one VirtualBox sees when adding hard drives.

    Am I missing something from you guide? If I do have two different directories, what is the best way to correct?

  62. WOW. It worked!

    Professional Windows 7, 64 bit, existing installation running on Ubuntu Linux 10.04, 64 bit.

    To Aaron and Sandeep: *major MAJOR* props.

  63. Hi guys,

    amazing tutorial!! Got Win7 Home 32bit running within Ubuntu 10.10 ALMOST flawlessly.

    Almost? Here’s why…
    As I’m pretty new to Win7 I didn’t know that it creates it’s boot record on a partition seperate from the actual Windows partition. So what you actually have to do for creating a raw VMDK for a Win7 system is to integrate this pretty small boot partition to the vmdk file as well.

    For me for example the boot record was located on /dev/sda1, the Windows partition on /dev/sda2. When creating a vmdk only for /dev/sda2 I could actually start the virtual machine and everythin with it, but when trying to repair the windows partition, the rescue CD said it wasn’t able to repair.

    Creating a VMDK for both /dev/sda1 and /dev/sda2 everything went fine, I could repair my Windows partition and run my Win7 virtual box.

    Now the only thing I have to do is see what happens if I reboot the whole system… Hopefully the Windows repair didn’t mess things up and destroy my GRUB or something…

    I’ll get back to you as soon as I tried this. Wish me luck and thanks again for the great tutorial!

    • You created two vmdk as two commands or one command?
      On by Netbook partition 1 is the small patition and then partition 2 is the main win7 partition
      I have tried using -partitions 1,2 parameter but no dice. Either I get failure with terminal showing MBR:
      Or I get Win7 repair disk message. Since the netbook does not have internal DVD/CDROM and external USB one is not getting recognised as a boot device I am stuck.

      On positive side Win7 continues to dual boot from grub.

      • IIRC, the -partitions 1,2 flag doesn’t create two VMDKs, it just specifies which partitions the VMDK should have access to. All partitions accessed must NOT be mounted at the time the VMDK is launched.

        Can you paste specifically what your error message was?

        Thanks!

      • Here’s what I did for Win 7 Home Premium (64-bit running on a Lucid 32-bit PAE host) for VirtualBox 4.0.8 from Oracle (on an Asus UL30A, if that matters)

        Follow all steps above, except Instead of creating one VMDK, you create two for Win 7: One with an MBR, one without an MBR.

        For example, if your Win 7 partition is /dev/sda2, you would issue the following commands:

        VBoxManage internalcommands createrawvmdk -filename ~/.VirtualBox/HardDisks/Win7x64-mbr.vmdk -rawdisk /dev/sda -partitions 2 -mbr ~/.VirtualBox/FAKE.mbr -relative

        AND

        VBoxManage internalcommands createrawvmdk -filename ~/.VirtualBox/HardDisks/Win7x64-nombr.vmdk -rawdisk /dev/sda -partitions 2 -relative

        Then, you attach the Win7x64-mbr.vmdk as a primary IDE device, and Win7x64-nombr.vmdk as a primary SATA device (assuming you have a SATA controller, that is).

        Here’s how (potentially) to avoid the issue of needing to reactivate your Windows installation: http://forums.virtualbox.org/viewtopic.php?t=9697

        Follow the DMI decoding steps, then apply the DMI info to your virtual machine using the shell script there. It looked like it worked at first, but now I’m being told that my copy of windows is not genuine 🙁

        It seems that 4.0.8 is painfully slow compared to vbox-ose 3.2.8 using a raw disk partition. It took about 5 minutes for explorer.exe to launch after finally booting. (Then again, what should I expect from running a 64-bit VM on a 32-bit host with a measly SU7300 processor?)

        Of course, if anyone sees problems with using the same partition on two different controllers, please reply – I’m pretty sure that the IDE with an MBR just acts as a stepping stone to get the non-MBR SATA one working.

  64. So, GRUB still there and switching between VirtualBox and DualBoot is fine.

    However there seems to be a problem with booting WIn7 directly from the scratch (=no virtualbox) when the VirtualBox Guest additions are installed. WIndows boots fine, however the mouse seems to stick to the lower left corner and after a minute or so Windows shuts down with a bluescreen of death.
    After booting from VirtualBox and uninstalling the guest additions however I could start Win7 from the scratch as if nothing happened… (apart from repairing of course 😉 )

    Did anyone else try to use the guest additions for such a dual boot configuration and run into similar problems? Not being able to use them seems like a pretty big deal breaker to me, but maybe there’s a way to circumvent this problem… Maybe it is possible to temporarily disable the additions before booting from the scratch or something?

  65. Doing this for Win7

    Okay I get to boot but then Win asks for boot repair disk.

    Problem: I have a netbook as only way I can connect DVD drive is by USB cable. This is not recognised as boot device in BIOS.

  66. Does anybody has windows 7 ultimate recovery iso file?(pls upload the file and post the link)
    I dont want to use my 2.3GB windows installation iso file…

    • Provided it’s not a copyright/license violation to post that ISO online, I would be happy to host it here and put the link in the main blog post.

      Anyone that has it should comment here with an email (put it in the email field) where they can be contacted and we can work out the logistics.

  67. I did all the steps and set up the machine without any hiccups, until I tried running the machine. I am getting a terrible blue screen error on boot within VirtualBox. It’s issuing a stop command, which looks like this: STOP: 0x0000007B (0xF78A6524, 0xC0000034, 0x00000000, 0x00000000)

    I did a google search but couldn’t find anything concrete pertaining to virtualbox.

    • Hi Michael!

      Can you give us some more information about your setup? What’s the host OS (the one that’s running Virtualbox) and which Windows OS are you running as a guest OS? also — Are you using VirtualBox open source edition, or closed-source, and which version? Do you have anything funky with your partition table?

  68. Excellent tutorial!

    I’m trying to configure VB to run windows from ubuntu 10.4

    Initially I had windows installed, then I partitioned my hard drive to run ubuntu.

    I need to run windows software from ubuntu using VB.

    I went through the setup smoothly until I got to the repair phase. Everytime I click repair I get an error telling that my current iso image is not compatible with my windows installation. But I’m using my installation CD!

    Any help will be greatly appreciated 🙂

    I print my list of partitions:

    Oracle VM VirtualBox Command Line Management Interface Version 3.2.12
    (C) 2005-2010 Oracle Corporation
    All rights reserved.

    Number Type StartCHS EndCHS Size (MiB) Start (Sect)
    1 0x07 0 /32 /33 12 /223/19 100 2048
    2 0x07 12 /223/20 1023/254/63 152485 206848

    • What version of Windows are you using? This will matter greatly. Windows XP seems to be, in my experience, far easier (or at least far more cooperative) with this method than Windows 7 has been.

  69. Great post!!! But I tryed everything and the best I acchieved was a Starting Windows screen running forever.. :S
    Any tip? I’m running dualboot with Windows 7 Pro 32bits and Ubuntu 10.04 32bits, with VirtualBox 4.0.4.

    Before you ask me to change the VB version I advice you that I’ve already it done… I tryed 3.12, 3.10 and 3.8 build releases, and OSEs too.

    Thanks,
    Tony
    ——————
    Here are some extra informations:
    $ fdisk -l /dev/sda
    Disk /dev/sda: 500.1 GB, 500107862016 bytes
    255 heads, 63 sectors/track, 60801 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x08000000
    Device Boot Start End Blocks Id System
    /dev/sda1 1 14 112423+ de Dell Utility
    /dev/sda2 * 15 1292 10258432 7 HPFS/NTFS
    /dev/sda3 1292 12118 86961668+ 7 HPFS/NTFS
    /dev/sda4 12118 60802 391053313 5 Extended
    /dev/sda5 12118 59676 382009344 83 Linux
    /dev/sda6 59676 60802 9042944 82 Linux swap / Solaris

    $ VBoxManage internalcommands listpartitions -rawdisk /dev/sda
    Number Type StartCHS EndCHS Size (MiB) Start (Sect)
    1 0xde 0 /1 /1 13 /254/63 109 63
    2 0x07 14 /5 /56 1023/254/63 10018 225280
    3 0x07 1023/254/63 1023/254/63 84923 20742144
    5 0x83 1023/254/63 1023/254/63 373056 194666496
    6 0x82 1023/254/63 1023/254/63 8831 958687232

    About partitions:
    sda2 –> Windows 7 Pro 32bits (RecoveryImage)
    sda3 –> Windows 7 Pro 32bits
    sda5 –> Ubuntu 10.04 LTS 32bits

    • Hi Tony!

      I really can’t make any warranty about this method working with Windows 7, unfortunately. I was able to get it successfully working with Windows XP, and it seems that some others have had luck with getting a Win7/Ubuntu hybrid going, but it’s rather inconsistent. Windows 7 is a bit more greedy w/r/t how it deals with booting virtually/normally.

      Have you tried Sandeep’s fix with the recovery disk?

  70. Hi, I followed up all the instructions and everything looks OK. but right after the Boot window ( the one with the blue bar) I got a black screen and nothing happens.

    I’m using VB 4.0.4 on Ubuntu 10.10 and Windows XP as guest

    Any ideas?

    • How long did you wait? Sometimes it would take me as much as 5 or 10 minutes to boot into Win XP (either normally *OR* vbox). Was there any feedback at all aside from the screen being black?

      • I leave it booting for a couple of hours.
        Checking the logs I found this
        aRC=E_ACCESSDENIED
        aComponent={Console} aText={The virtual machine is being powered down}

      • More information I’ve got from logs

        VBox.log
        00:18:10.223 Changing the VM state from ‘DESTROYING’ to ‘TERMINATED’.
        00:18:10.408 ERROR [COM]: aRC=E_ACCESSDENIED (0x80070005) aIID={515e8e8d-f932-4d8e-9f32-79a52aead882} aComponent={Console} aText={The virtual machine is not powered up}, preserve=false

        VBox.log.1
        00:00:10.047 Guest Log: BIOS: Booting from Hard Disk…
        00:00:16.709 RTC: period=0x200 (512) 64 Hz
        00:00:16.888 Display::handleDisplayResize(): uScreenId = 0, pvVRAM=ae7e2000 w=640 h=480 bpp=0 cbLine=0x140, flags=0x1
        00:00:24.733 PIIX3 ATA: LUN#0: IDLE IMMEDIATE, CmdIf=0xef (-1 usec ago)
        00:00:24.733 PIIX3 ATA: LUN#0: aborting current command
        00:00:29.421 OHCI: Software reset
        00:00:29.421 OHCI: USB Reset
        00:00:29.421 OHCI: USB Operational
        00:00:31.304 OHCI: USB Suspended

        VBox.log.2
        01:52:36.581 Changing the VM state from ‘DESTROYING’ to ‘TERMINATED’.

  71. THANKS! for the great instructions.

    I just installed virtual box 4.0.4 from the Oracle website.

    Make sure your type 7 partitions are not mounted and that the correcponding /dev/sd.. devices have the permissions as specified in the instructions.

    I ran into problem when creating a vmmk file. My C and D drive were partitions 2 and 5, so I thought that I could get away with “-partitions 2,5”. When I got all done I got a “MBR 25FA” that I was not able to get it to boot from. But I also had a restore partition, partition 1, that was also type 7. So I created my vmdk again using “-partitions 1,2,5” and this worked great. So I would suggest using all of your type 7 partitions in the “-partitions” option or at least including the windows restore/diagnostic/whatever_it_is partition usually in partition 1.

    One thing you will notice is that there is no longer a “-register” option to VBoxMange. Just use the command in the instructions and leave this option off. I called my vmdk file “~/.VirtualBox/winxp.vmdk” and noticed that it created this file along with another file “~/.VirtualBox/winxp-pt.vmdk”

    When you get to the “Load your new VDMK” step you will need to use the browse option and select the “winxp.vmdk” file, not the “winxp-pt.wmdk”.

    This resulted in windows booting right into vVrtualBox.

    While booting I got a couple of “installing new hardware” messages and complaints about the video not being 32 bit. I would suggest ignoring all these and install the guest addtitions instead. Selecting “devices->Install guest additions” from the VirtualBox menu. This will install drivers for your video (and something else I don’t remember) and thus clean up your device manager yellow “?” that result from the driver changes that running in VirtualBox requries will cause. It will set your resolution to 800×600, but in windows just right click on the background, choose properties and then settings and set the resolution to what you want it to be.

    If you need a “ctrl-alt-del” to login to windows, use the “Machine->Insert Ctrl-Alt-Del” from the VirtualBox menu.

    I had previously run windows natively before I started the process and set up a second hardware profile for VirutalBox which I selected during boot. You do this by running “sysdm.cpl” from the run menu, selecting “hardware” and then “hardware profiles”. Use the “copy” button and copy your current profile and name the new one “virtualbox” or whatever you want. Then when windows boots in virtualbox, you will get a boot menu where you can chose the old one (which you use when you boot natively) or the “virtualbox” profile when you boot from VirtualBox. This keeps windows from wanting to switch your drivers back and forth. You can order your profiles using the up and down arrows on the “hardware profiles” pop-up and select the “select the first profile listed if I don’t select a profile” if you rarely use one of the profiles. It is safest to chose “Wait until I select a hardware profile” so that you won’t miss the menu and end up booting into the wrong profile and have windows mess with your drivers.

  72. Hi there!

    First of all: great tutorial!

    But then: I followed your steps exactly, including the steps recommended for Windows 7 (as this is what I want to use in my VirtualBox, hosted by Ubuntu 10.10 64 bit), and finally got to boot the system. But right after the “Repair & Restart” part, I got a BSOD (which causes the system to reboot immediately) that won’t disappear (well, it re-appears every time I boot).

    I then tried to boot the system for real (I read somewhere that the MergeIDE-fix offered by VB could help), but the system seems to be broken beyond repair (the recovery won’t do anything).

    Can you please help me with that? Do you need any more info?

    Keep up the great work!

  73. Great tutorial! Worked like a charm.
    Got a Win7 64bit Home Professional, with an ACER Recovery Partition as partition 1, the “boot loader”(?) partition as 2, and the actual win7 partition as 3, so i did a “-partitions 1,2,3”. Had to use the .iso of the win7 recovery disc afterwards.
    Btw: On Kubuntu 10.10 64bit it seems to work with Virtualbox-OSE 3.2.8, no need to use the “non-OSE” .deb from virtualbox.org. Also, I didn’t do the chmod on the device nodes, only added myself to “disk”.

    • Thanks, Heix! I’ve added your comments to the guide, above!

    • when I try to boot appears black window saying: Windows failed to start. A recent hardware or software change might be the cause. To fix the problem: ….

      My system uses 3 partitions, I assume 1 and 3 belongs to the HP recovery system. So I guess I may use the win7 .iso recovery disc as you said. How should I do that?

      Thanks.

      • Thanks for the tutorial

        My system have 3 windows partitions, two of them I guess should be the HP recovery system.

        I did not reach to boot, Windows said:

        “Windows fialed to starts…
        1. INsert your windows installation disc and restart
        2. Choose your language settings
        3. Click “repair your computer”
        If you do not have this disc, contact your system adminstrator or computer manufacturer for assistance.
        File: windwossystem32bootwinload.exe
        Status: 0xc000035a
        Info: Attempting to load a 64-bit application, however this CPU is not compatible with 64-bit mode.”

        Thanks in advance.

        • To do the ISO method, you’ll need an ISO file of the Recovery disc, then specify to Vbox that you want to “load it” in the settings for your virtual machine (before starting the session).

          The “Info:” error at the bottom is puzzling, I’m not sure what that means, exactly, other than that Win7 is 64-bit and for some reason it thinks the virtualmachine is not.

          Bear in mind that when you boot into native Win7 (ie. not in a virtual machine) you will need to do the recovery disc thing again; it seems to require it anytime you switch the means which you boot into win7 with.

  74. i had the same problem… i just restar and the problme it’s solved. Take a look again to your windows partition… and if they are mounted automatically, then unmount it.

    DP: Sorry my english isn’t vey good.

  75. JoseFrancisco

    Hi, I have installed suse 11.4 and vbox 4.0.6 r71344, as i didnt have install-mbr, I did the mbr file with

    sudo dd if=/dev/sda of=/home/myuser/VirtualBox.mbr bs=512 count=1
    sudo chmod 666 /home/myuser/VirtualBox.mbr
    sudo chown myuser:users /home/myuser/VirtualBox.mbr

    then i used it for the vmdk file and everything else, but when i start the winxp in virtualbox i just have black screen with

    Error No operating system
    FATAL: INT18: BOOT FAILURE

    any idea pls?????

    • Hola Jose,

      I’m really not sure how to fix this problem; I haven’t used Suse in a LONG time and haven’t experimented with methods outside of those listed in the original article. Perhaps another commenter will be able to pick that up, though?

    • @jose – Were you able to resolve the mbr issue under SUSE?

  76. John Westerdale

    Awesome tutorial, Aaron. When would you pick Wine vs Virtual box approach?

    Am assuming the VMDK-based OS can’t see the Ubuntu file systems.

    • Wine is preferable, because it doesn’t block out system resources like VM’ing does, but it’s not always an option for certain software apps that require libraries that aren’t well-implemented yet.

      VM’ing Windoze as a guest OS works well when you have (a) an abundance of resources (ie 2 or more CPU cores, although Ideally you want at least 4) and (b) applications that can only natively run in Windows. You can configure most VM programs to make the host OS (Linux, in this case) expose one or more directories to the guest OS, often as “mapped drives” (allowing internal copying, which is much faster) — if you configure the network access for the guest OS to be bridged, the guest appears as its own entity on your network, and can also access any network shares on the guest OS, although it will do that via the router first.

      I’m also working on a tutorial for VMWare Express, which I’ve found to be a *little* better performing than VBox.

  77. Brynley McDonald

    Whenever I try to add the vmdk to a new machine I get this

    Result Code: NS_ERROR_FAILURE (0x80004005)
    Component: Medium
    Interface: IMedium {9edda847-1279-4b0a-9af7-9d66251ccc18}
    Callee: IVirtualBox {d2de270c-1d4b-4c9e-843f-bbb9b47269ff}

    I have no idea what it means. I’m using virtualbox on 11.04 and trying to get a Win 7 x64 image working. I’ve already tried making the image again.

    • I am also getting this error, attempting to load a 64-bit version of windows 7 on 11.04.

    • EDIT: I figured it out. Re-do the whole process from the “chmod 660, 600” step. but make sure you’re not the root user at any point.

      • Howard, can you clarify what you mean by that? I will incorporate it into the original post. Do you mean that you did not use sudo? Or something else?

  78. It says “Invalid parameter ‘-register'”.

    • It also says (when I enter the create vmdk command without -register, forcing me to create a new disk) that “The medium ‘/home/username/.VirtualBox,winxp-pt.vmdk’ can’t be used as the requested device type.” I also get this message for the other vmdk file.

      • Did you use a “,” in the filename? That might be why. Also please paste the full command you typed so i can help 🙂

      • No, that was just a typo in the comment. The whole command I used (to create the VMDK file) was
        VBoxManage internalcommands createrawvmdk -filename ~/.VirtualBox/winxp.vmdk -rawdisk /dev/sda -partitions 1,2,3 -mbr ~/.VirtualBox/FAKE.mbr -relative
        Neither of the two vmdk files created are accepted by vb.

      • hmm…. that’s really weird.

        Are you using a very recent version of VBox? Since Oracle bought out Sun, it’s possibly they’ve changed things around, although that would be really strange.

        You can certainly leave off the -register flag and just register the VMDK with the VBox gui manually — though it looks like you’re still having problems even without that.

        One thing I find strange is that the error message is saying:
        ‘/home/username/.VirtualBox,winxp-pt.vmdk’
        when your command was:
        ~/.VirtualBox/winxp.vmdk

        In the former, there is a “,” between “Box” and “winxp”, and also a “-pt” appended to “winxp”. Was that a typo or was that the actual output?

      • Same problem here

  79. thanks a lot for the post.

  80. I’m using a 64-bit 10.04 Ubuntu host and attempted for two days the process described above for a 32-bit Vista guest, but all I get is a black screen of failure in starting the virtual machine in VirtualBox. Is it possible to virtualize a Vista OS?

  81. Chrystian Townsley

    Im also gettin the FATAL: INT18: BOOT FAILURE error using debian and win7 ult x64

  82. On Ubuntu 11.10 I get:

    $ install-mbr –-force ~/.VirtualBox/FAKE.mbr
    Usage: install-mbr [options]
    Try ‘install-mbr –help’ for more information.

    $ install-mbr –-force /tmp/FAKE.mbr
    Usage: install-mbr [options]
    Try ‘install-mbr –help’ for more information.

    • Be sure that you are using the correct number of dashes for the option flags. If you use the full name “force”, you need 2 dashes. If you use just “f”, you only use one dash.

  83. Hi, tutorial goes well up until i try to create the VMDK, at which point I use the command:

    VBoxManage internalcommands createrawvmdk -filename /home/gamedrift/.VirtualBox/winxp.vmdk -rawdisk /dev/sda1 -partitions 5 -mbr /home/gamedrift/.VirtualBox/FAKE.mbr -relative

    and get the following result:

    VBoxManage: error: VMDK: incorrect partition data area ordering set up by the caller in ‘/home/gamedrift/.VirtualBox/winxp.vmdk’
    VBoxManage: error: Error code VERR_INVALID_PARAMETER at /home/vbox/vbox-4.1.8/src/VBox/Storage/VMDK.cpp(3656) in function int vmdkCreateRawImage(VMDKIMAGE*, VBOXHDDRAW*, uint64_t)
    VBoxManage: error: Cannot create the raw disk VMDK: VERR_INVALID_PARAMETER
    VBoxManage: error: The raw disk vmdk file was not created

    My box is Gamedrift running Ubuntu 10.10
    Closed source version in use.

    i look forward to your comments

    • Rob,
      I haven’t really been keeping up with VBox (see the top of the OP) so I’m not sure how to debug your problem. IIRC, though, you will want to make sure that the numeric argument for -partitions flag is the number of the partition where you have windows installed (ie. “5” corresponds to “/dev/sda5”). I forget whether -rawdisk wants /dev/sda or /dev/sda1 — you may want to try both.

  84. To anyone struggling to get this running with Windows 7, I might be able to save you some time:

    If Windows bombs straight to a blue screen of death on boot, in your VM go to settings->storage. If your .vmdk file is listed under SATA, then remove the attachment, then add a new hard disk under IDE, selecting your vmdk file. Next – and this is the crucial bit, in the storage settings again, select the IDE controller, then change its type to ICH6.

    Save your settings, and your Windows 7 partition should boot – given you’ve followed all the previous instructions (particularly the windows 7 disc repair option part, which will get you past the ‘MBR 1FA’ problem.)

    Many thanks for this article and to everyone who has also contributed – all this plus a bit of fiddling finally got me there!

  85. jesus fucking christ. everyone posts instructions for LINUX even though I searched WINDOWS. I want to mount a physical drive in virtual box running on windows in windows but there is no such thing as /dev/drive bullshit in windows. GOD DAMNIT

    • Hi there!
      Figure it out, piece together the instructions, and write your own how-to guide for windows users. Before this post, there really wasn’t any comprehensive instructions detailing all aspects of the process. I have no idea what is required to get it to work in windows, but I will assume that the process is roughly similar. I would probably start by looking through the VirtualBox application for something that lets you create a VMDK — you may need to do this at the command line, which surely has documentation somewhere.

      Good luck! If you do end up writing a post, please send me the link and I will link to you from this post. Thanks!

  86. Maximiliano Carrizo

    Very important issue:

    If you’re receiving this error message in boot:

    MBR
    A disk read error occurred
    Press Ctrl+Alt+Del to restart

    You should edit your generated file in step “Create a VDMK file” and change line:

    ddb.geometry.biosHeads=”255″ to ddb.geometry.biosHeads=”240″

    Regards !

  87. im hitting this error..
    The boot selection failed because required device is inaccesible

    I followed the steps mentioned above
    let me know if there is any workaround for this problem

  88. You da man! This worked for me. I’m now running a WinXP VM (booted from an existing NTFS partition) in VBox on Linux. I have read and tried many other methods posted in Ubuntu and VBox forums, but this is by far the simplest.

    I did have to uninstall Symantec Endpoint Protection (SEP) to allow XP to boot in Normal mode. With SEP, it would boot in Safe mode, but would fail in Normal mode with exceptions in services.exe and lsass.exe. (Now to find Windows AV that is compatible with VBox!)

    My setup:
    Toshiba Tecra M3 2Ghz single-core processor & 2 GB RAM
    VMDK created with 2 NTFS partitions: C: & D:
    Ubuntu Lucid Lynx 10.04 LTS
    VirtualBox 4.1.8 r75467
    Guest settings: 768 MB RAM, 64 MB video memory
    – Motherboard Chipset: PIIX3, IO APIC enabled
    – IDE Controller Type: PIIX3, Use host I/O cache
    Guest OS: Windows XP Pro SP3

    • Rick

      Thanks for stopping by! Glad it was helpful for you — apologies for not keeping it current, but thankfully there are other VBox enthusiasts who are gracious enough to post their progress and hacks on here. 🙂 If you had to overcome any difficulties or situations with any clever hacks or discoveries, please feel free to post here and I will add it (with attribution) to the OP above if I can fit it in.

      cheers!

  89. Aaron: A million thanks to you and to everyone who contributed to these instructions as I finally got my VM up and running! These were the first instructions I found that were clear and didn’t leave pertinent details out.

    Gratefully,
    Greg

    • Glad to hear it’s still working for people 🙂

      If you run into any other problems or difficulties, please feel free to post here and I will incorporate the changes into the document.

  90. Excellent tutorial! Thank you Aaron. I found this late, and it clarified some of the finer points I was missing from another explanatiion.

    • Excellent! Glad you found it useful. If you discover anything I overlooked, please comment here and I will integrate it into the article.

  91. I created the VMDK but when I goto create the virtual disk and point virtualbox to the VMDK, I get the following error:
    Failed to open the hard disk /home/myusername/.VirtualBox/win7.vmdk
    Permission problem accessing the file for the medium ‘/home/myusername/.VirtualBox/win7.vmdk’ (VERR_ACCESS_DENIED)

  92. You should update this so that, after adding the ‘disk’ group to the user, that they should log out and back in so that this change takes effect.

  93. […] Someone else has already done a great job of documenting this process, so I'll just link you to it. I also found this resource helpful.Tagged with: linux, tricksCategorised as: Linux Hackery Leave a […]

  94. Aaron, I love you. I haven’t hammered out all the problems yet, (e.g awful awful booting speeds) but I’ve managed to get Windows 8 Pro (64bit) to boot in my 64bit version of Ubuntu 12.04.

    I had a few issues getting it booting to start with, but using the windows 8 installation disk to get into command prompt and run bootrec.exe /fixboot, /fixmbr and /rebuildBCD got this working. I couldn’t access my other SATA HDD that carries all my media, (And adding this as a separate vmdk in my virtual machine’s options made it borky and not detect the original Windows installation), but I’ll try and work it out.

    Thanks again!

    • Julian, that’s excellent!

      I will add your bootrec.exe command to the post — please post here with anything else you might find and I’ll incorporate it into the post.

      Thanks! 🙂

      • Aye of course, I shall. At the moment it’s completely broken it seems but I’m working on it. Also, just a heads up, the commands you quoted from me are to be executed seperately, e.g;

        bootrec.exe /fixmbr
        bootrec.exe /fixboot
        bootrec.exe /rebuildBCD

        Just to avoid any confusion!

        • OK, thanks for the clarification — I haven’t used windows in a couple years now. 🙂

          I went through and updated the post with some newer info, providing PPA details instead of binary-only, and re-formatted the text to highlight the terminal commands better.

          Thanks for helping to keep this post alive. 🙂

          • No problem. Happy to help, and I hope this page stays exactly where it is because it’s been a lot of help to me too.

            On a related note, I managed to completely murder my bootsector and grub so much to the extent that I ended up reinstalling windows and ubuntu. I’m gonna play it much safer this time, though.

            Any ideas on how to give the initial .vmdk access to an additional SATA drive?

        • Sajjad Heydari

          Thanks for this really, although when I try to run bootrec.exe/rebuildBCD I get this error:

          The requested system device cannot be found.

          Any ideas?

  95. Oh, and one more thing, you MUST also include the ‘System Reserved’ partition in the vmdk file for win8 to boot.

  96. Right, sorry about the spam, (wish I could edit comments!), but I’m pretty much done with this for now I think. I followed exactly the same steps as before, created the fake mbr, and the vmdk image, but also created an additional vmdk image for my shared drive. My windows image contained both the main body and the system reserved partition, and I executed the bootrec.exe commands to repair the mbr and managed to boot successfully and also access my shared drive. I cannot however boot natively into windows 8, as expected, but I hope some time in the future someone will be able to find a workaround for this, since repairing the installation and then also repairing grub every single time is not a valid option for me.

    And again, sorry about the spam!

    • Hi Aaron,

      Thanks for this great tutorial. I have been struggling for the last days and I got to a very bizarre point.

      So I got a new laptop with Windows 8 and Ubuntu installed with dual boot. I followed the instructions, included the recover partition as Julian said, and I was stuck with the MBR FA error. I tried running my Win recovery CD in the virtualbox, but I does not recognize the data (to be precise, I ask virtualbox to boot from there and it says there are no boot files. It runs ok from raw outside any OS).
      I also tried mounting the recovery files in a USB pendrive, and creating a VDMK for this partition and adding it to the fake.mbr. This actually DID work, and I could start the repair mode, went to the command prompt option and run the three options for bootre.exe. After that, I could boot into Windows, but only is the VDMK for the USB exists (if I remove the USB or the VDMK drive I created onVB I get again the MBR FA error).
      I also trying creating a partition with the content of the USB pendrive and a VDMK, but it does not work.

      So, Do you have any idea how can I run Win without the USB? The weird thing is that I have no way of getting again into the recovery mode in the USB. Besides, the dual boot still works perfectly (without any other change).

      Thanks,

      • Gustavo,

        I wish I could be more helpful with this, but honestly, the last version of windows I used (and own a legit copy of) was XP. I know MS has changed a lot of things with how the FS works, particularly with regard to the MBR and booting process.

        As I essentially use Linux full time now, save for those extremely rare times when I boot into a pure VM to debug a web app in IE, I’m not sure I can be much help. 🙁 perhaps other commenters might be more helpful?

    • Hi Julian, how did you finally manage to access the shared drive? I am booting win7. When booting nativelly, it can access the shared partition.
      But when booting in VirtualBox, it says the disk is RAW, cannot access it (and neither can format it).
      Any clue on how to make it see the shared partition?
      thanks!

  97. Hi i’ve got BSOD with my win7 on ubuntu 12.10

    http://imgur.com/6NpkU

    00:00:03.379450 Display::handleDisplayResize(): uScreenId = 0, pvVRAM=0000000000000000 w=720 h=400 bpp=0 cbLine=0x0, flags=0x1
    00:00:08.499302 Display::handleDisplayResize(): uScreenId = 0, pvVRAM=00007f0de4000000 w=1024 h=768 bpp=24 cbLine=0xC00, flags=0x1
    00:00:14.695398 RTC: period=0x200 (512) 64 Hz
    00:00:16.140139 AHCI#0: Reset the HBA
    00:00:16.220738 Display::handleDisplayResize(): uScreenId = 0, pvVRAM=00007f0de4000000 w=640 h=480 bpp=0 cbLine=0x140, flags=0x1
    00:00:16.859567 Reset initiated by ACPI
    00:00:16.859671 Changing the VM state from 'RUNNING' to 'RESETTING'.
    00:00:16.922379 CPUMSetGuestCpuIdFeature: Enabled APIC
    00:00:16.922473 CPUMClearGuestCpuIdFeature: Disabled x2APIC
    00:00:16.922532 PIT: mode=3 count=0x10000 (65536) - 18.20 Hz (ch=0)
    00:00:16.970444 AHCI#0: Reset the HBA
    00:00:16.970530 PIIX3 ATA: Ctl#1: finished processing RESET
    00:00:16.970637 PIIX3 ATA: Ctl#0: finished processing RESET
    00:00:16.970803 PDMR3Reset: after 48 ms, 1 loops: 1 async tasks - piix3ide/0
    00:00:16.971010 TM: Aborting catch-up attempt on reset with a 89 839 813 ns lag on reset; new total: 89 839 813 ns
    00:00:16.971065 Changing the VM state from 'RESETTING' to 'RUNNING'.
    00:00:16.975508 Guest Log: BIOS: VirtualBox 4.2.4
    00:00:16.975688 PIT: mode=2 count=0x10000 (65536) - 18.20 Hz (ch=0)
    00:00:16.986508 PIIX3 ATA: Ctl#0: RESET, DevSel=0 AIOIf=0 CmdIf0=0x34 (-1 usec ago) CmdIf1=0x00 (-1 usec ago)

    • Hi Kowalikus,
      Win7 is kind of pioneer territory with this. I just had some new comments come in with info, I’m going to integrate it into the main guide. Perhaps that will help?

  98. Hi Aaron,

    I am wondering – if I boot virtual and have to do the rescue disk option it is probably safe to assume that I will need to do the rescue disk *again* if I boot raw, correct? You seem to make that implication in your post but I just want to be 100% clear before I go this route. I don’t boot in to windows often but when I do it is for gaming and I also do not want it corrupting grub every single time either. Can you tell me the possible overhead for someone who would boot consistently between virtual and raw? Would it be worth doing this or no because you have to effectively repair it each time?

    Also, I would like to be clear – if I have to only do the rescue option on *only* virtual boots then I am ok with that but I want to understand the impacts it may have on a raw boot (eg: conflict with grub, have to do a repair each raw boot as well as each virtual boot, etc…)

    Thanks again for the tutorial!

  99. (Use at your own risk.)
    http://wiki.ubuntuusers.de/Dualboot-Windows_virtualisieren (translated: http://translate.google.de/translate?sl=auto&tl=en&js=n&prev=_t&hl=en&ie=UTF-8&layout=2&eotf=1&u=http%3A%2F%2Fwiki.ubuntuusers.de%2FDualboot-Windows_virtualisieren&act=url) describes a solution for Windows 7 so that you won’t need to do a “Repair Installation” each time you want to switch from native to the VM and vice versa (you won’t need any Windows 7 Installation Disk at all):

    Solution #1 (though that didn’t work for me):
    Right after install-mbr, but before VBoxManage:
    Run sudo fdisk -l, you’ll need the value behind “Disk identifier:” of the hard drive your Windows 7 is on.
    Then:
    echo YOURDISKIDENTIFIER | xxd -r | dd of=~/.VirtualBox/FAKE.mbr bs=1 seek=440 conv=notrunc
    Then continue with VBoxManage etc.

    Solution #2 (should work for everyone):
    First, run sudo fdisk -l on your host system, you’ll need the value behind “Disk identifier:” of the hard drive your Windows 7 is on.
    After you’ve created the VM (leave out the step telling you to boot from the Windows 7 Installation Disk), attach a Ubuntu (or any other Linux) live CD image to the VM:
    Settings -> Storage -> Controller: IDE -> Add CD Device (first icon) -> Choose Disk -> select the image of your live CD
    Then boot the VM, it should boot the live CD image. Once you’re in there, run
    sudo fdisk /dev/sda to start fdisk’s interactive mode (replace /dev/sda with the hard drive your Windows 7 is on).
    Enter x, then enter i
    Put in the disk identifier you’ve gathered in the first step, then press w to rewrite the MBR and quit fdisk.

    EDIT (added by admin): After this, shut down the VM and remove the live CD image from the VM’s storage devices.
    And note that the device name (e.g. /dev/sda) you have to use on the guest system might differ from its name on the host system.

    Now you should be able to boot Windows 7 both natively and through the VM without Windows complaining.
    Feel free to update the article with this information.
    To everyone else that has problems, I suggest you to read the wiki article linked at the top of my comment, it’s very comprehensive and has many troubleshooting tips at the end.

    Something else that took me a few hours to find out:
    I also have a Windows XP partition on my hard drive, and I didn’t realize that the “Boot” folder (which is needed for Windows’ bootloader) was only on that partition but not on the Windows 7 partition (I, naturally, installed Windows 7 after I installed WinXP).
    So I didn’t add WinXP’s partition number to VBoxManage’s “-partitions” list, which prevented the VM from booting.

    This wiki article also describes how to prevent Windows from asking you to activate again (translated [see section “Align virtual hardware of the physical hardware”; yes, that’s Google Translator’s English :P])

    • Thanks for the info! I’ve integrated it into the guide. 🙂

    • just a precision : after entering the new disk identifier, you have to press ENTER, then “m” to return to FDISK’s main menu, and then press “w” to rewrite MBR.
      My win guest doesn’t repair anything anymore when I reboot it in “real/host” mode.
      But it goes BSOD in guest mode, no matter what I do (and I did respect ALL instructions here). I just can’t figure out what’s happening 🙁

    • theres’ a slight error here : after entering the new disk identifier + ENTER, you have to press “m” (back to main menu) before being able to press “w”

  100. Very helpful tutorial. Everything worked till booting windows on VM.

    But on boot, windows boots till “Windows is loading..” stage and progress bar loads twice and restarts and gets in this loop forever. Anyone know what could be the issue.? I have been trying with different settings but still no solution.

  101. Followed this recipe and it seemed to work out. Question: I would ALSO like to be able to run the Ubuntu when I boot up in the windows partition (raw disk method). How might one do this?

    • Shane — I haven’t tried to do that yet — I’m not sure if Windows is capable of doing this. The tutorial was intended mainly for people that use Ubuntu as their primary OS but need to occasionally switch to Windows (anymore, I just do VM’ing only).

      If you use Windows primarily, you could use Wubi or Cygwin to run Ubuntu in parallel.

  102. Great Howto. Got my W7 install working perfectly thru VB 4.2. It boots natively as well without a hitch.

  103. […] less, a search of the Web does show evidence that people have made it work this way (1, 2, 3, 4, 5, 6, […]

  104. […] proceeding with extra caution. We aren’t going to get into the nitty gritty here, but this article should help you get […]

  105. […] Visszafelé ( ami engem jobban érdekelne ) már nem ilyen könnyű a helyzet. Van ahhoz is egy link, de […]

  106. vboxmanage not VBoxManage, and I think it needs root access too

  107. I’ve managed to get Win7 working (though it complains the copy of windows isn’t valid, and uses generic display drivers). I kept getting the BSoD on boot, even though I’d tried changing the hard drive chipset to several combinations of settings. What finally worked was taken partially from http://sanbarrow.com/p2v2008r2.html. The steps were as follows:
    1. In virtualbox, go to Settings.
    2. Go to Storage.
    3. Replace all controllers with one SAS controller (I don’t know if it’s necessary to remove all the others or what).
    4. Add your vmdk under that controller, and hit ok.
    5. Now open a terminal. (This is assuming installation under Ubuntu; if not, try analagous steps in whatever OS you’re using).
    6. Install the registry-tools package, either with apt-get or whatever.
    7. Mount your windows partition, say /mnt/WIN/.
    8. Navigate to /mnt/WIN/Windows/System32/config/.
    9. regshell -F SYSTEM
    10. cd ControlSet001
    11. cd services
    12. cd LSI_SAS
    13. set “Start” REG_DWORD 0x00000000
    14. exit
    15. Then unmount the partition and try booting up. Hopefully it will work.

    I guess the idea is to get windows to use the right drivers for however virtualbox is letting it access the drive.

    Please note that I haven’t tried actually booting my computer into Win7 yet (after the registry change), so it’s possible that I borked it for normal booting up.

  108. One problem I ran into was access denied when I did “$ VBoxManage internalcommands listpartitions -rawdisk /dev/sda” command, so I did the next step whis is “$ sudo chmod 666 /dev/sda” and then executed that command and it fixed the problem.

  109. I have been searching for this kind of solution for a long time now. Every site I visited always suggests creating a Hardware Profile and goes on to say, HPs are not present from Vista on onwards and thus native partiton boot in VM is not possible.
    But, your soultion worked like a charm, upto the details of each and every error message that you had mentioned we might get. followed your instructions and every step worked as expected. Now able to boot my Windows partition from VirtualBox. Thanks a lot.

    • great tutorial, it all worked well.
      On problem: when I boot Win7 within virtualbox, it cannot access the primary partition I use for documents, it says it’s RAW and needs to be formated (but if I try formatting it, it’d fail).
      The same partition is accessible when booting win7 natively.
      Any clue?

  110. I was constantly getting VERR_ACCESS_DENIED error. If all esle fails follow the following procedure.
    1) Do sudo chmod 666 /dev/sda before the start of all commands
    2) For /dev/sda1 do chmod 666 instead of 660

  111. HI, all configured as above but i get stuck when i run the VB. a new, black emulation window gets open with and a sec later one word appears: “MBR”. any ideas why?

  112. I did this on another harddrive rather than the same harddrive but different partition. If you get a uuid mismatch, you could just open the .vmdk and change it to match the expected uuid.

  113. Question: If you have a Windows 7 recovery disc, but not an install disc, can you still repair the installation once you’ve done this?

    • Leo, As far as I know, the VM treats the guest OS pretty transparently, so if you use the recovery disc it *should* work in whatever way the recovery disc was intended to work. (ie. if the recovery disc repairs installations on a normal computer, it should also repair the installation on a VM, I *think*.)

      No guarantees, though.

  114. Hi,
    nice job !!!
    I manage to launch my win seven 7 Pro N (natively installed) in my CrunchBang (wheezy) with the last stable version of virtualbox v4.3.6

    thanks

  115. So I used WUBI to install my ubuntu alongside windows. I am now trying to use this to access my windows while in ubuntu.

    Will this still work? I think my windows is on /dev/sda2 because when I use fdisk -l it is the only bootable drive, and when I use df -h it says /host/ which contains my windows files is mounted from /dev/sda2.

    However when I run the createrawvmdk it says cannot read partition information from ‘/dev/sda2’

    Am I doing something wrong here? Also I cannot unmount /host/ apparently because thats also where my linux files are cause thats apparently how wubi works.

    PLEASE HELP.

  116. Hi, just passing through; curious: as to why you’ve switched-over to the VMWare Player.
    Any particular reason, to do so?!??

    • I’ve actually switched *BACK* to VirtualBox, now that Canonical finally updated their repos to use the more current version.

      The repo version is pretty solid and there is now even a package for guest additions. 🙂

  117. Thanks so much for maintaining this document! I am now able to run Windows 7 Pro (64-bit) on Debian jessie/testing in VirtualBox 4.3.10. I did have to repair the installation (ok by me because I am planning never to boot Windows raw again).

    I also found that Windows would not give back the mouse after capturing it. This was exceedingly frustrating since VirtualBox displayed a couple of popups to me that obscured my view of Windows and that I couldn’t dismiss. I had to SSH into my machine and kill the VM a couple of times before I got it sorted.

    The mouse capture issues were resolved by installing the Windows additions. Add /usr/share/virtualbox/VBoxGuesAdditions.iso as a CD drive before starting the VM, and then run VBoxWindowsAdditions.exe from the CD/DVD drive inside the guest. Extra points for navigating Windows with the keyboard so you don’t get your mouse captured.

  118. Thanks to Aaron and to all who posted this excellent tutorial!

    I got everything to work fine (in terms of accessing the partition through VB), but I have a couple VB problems:
    1)Guest Additions CD doesn’t install properly
    2) Host Key and Disable/Enable Capture Mouse function not working.

    I realize these are more about VB than about virtualizing a windows partition, but can anyone help me out?

    I’m still very happy that it works, though! 🙂

  119. Excuse me,
    I would like to ask the way to modify disk identifier, if applicable windows8.1?

  120. Hi,

    Great post … but it did not completely work for me.
    I am running Lubuntu 14.04 on a Asus EeePC 1215B with Windows 7 pre-installed.
    I followed the given instructions including the instructions for Windows 7. The instructions with fdisk (User-submitted Walkthrough for Windows 7) did not work for me. I had to download a repair disk ISO and to boot with it (and rebooted a couple of time) … to eventually get a Blue Screen of Death with an error message quickly disappearing !
    Then I remembered I started with another post that gave a solution for that: running a registry fix.
    I give you the post (the registry fix is at the end):
    http://in-the-attic.com/2010/06/05/booting-windows-7-from-an-existing-partition-inside-ubuntu-virtual-box/

    And now, it works: I can run Windows from my Lubuntu … all of that on a small netbook !
    Thanks again for all your work !

    • Thanks for your contribution!

      The original guide was for winXP with Ubunti, so I make no warranty about it working with any other configuration. Glad you were able to figure it out:)

  121. I have created a post, on my blog (in French ) summarizing all of this
    http://computing.travellingfroggy.info/article171/double-boot
    In the English version, I will just point out to your post (and a few others), if that’s ok with you.

  122. Strangely, I had my partition table garbled: my first Ubuntu partition has been moved from sda7 to sda9. Thankfully, that was a Ubuntu 12.02 that I am not using any more. I am running from a Lubuntu 14.04 (on sda8) where I have installed VirtualBox.
    Anyway, that’s just a note in case, someone is interested.

    But I have now a problem, on my VirtualBox I have no network, when it worked before ! Any ideas on how to fix it ?

  123. Thanks a lot!!

  124. I successfully followed the steps to open my Win7 partition in VirtualBox — thanks for the brilliant walkthrough — but when I try to load a Netflix video in my browser in the Win7 VM, I get an error: “Whoops something went wrong… Digital Rights Management (DRM) Error. Error Code: N8156-6013.”

    Do you (does anyone) have any idea how I can get around that? (Using Silverlight was the only reason I wanted to access my Win7 installation from my Linux installation.) “Repairing” Silverlight doesn’t seem to help.

  125. On Ubuntu 14.04, I have reached the “install mbr” stage with
    $ install-mbr -e1 –force ~/.VirtualBox/FAKE.mbr
    but I get a “Not a directory” error. I have tried several variations (no “-e1”, no “–force” &c, but I always get the same result. My XP is in the sda1 partition.
    Am I doing something wrong, or have commands changed their behaviour in the last 5 years?

  126. I am trying to do the same with my windows8 partition. I don’t have an installation disk. Any idea?
    Later i might try something wit the windows recovery partition

  127. I got it working with windows 10 on ubuntu. first you need to specify all partitions that are needed by windows so in my case VboxManage [..] -partitions 1,2,3,4 Then just need to enable efi in virtual machine settings.
    Big thenks

  128. Windows 10 in VM from Ubuntu 15
    I didnt create mbr I just found with “$ fdisk -l” EFI System partition and Microsoft basic data partition (it was 2,4)
    I then run “$ VBoxManage internalcommands createrawvmdk -filename win10.vmdk -rawdisk /dev/sda -partitions 2,4 -relative”
    in VirtualBox I created VM with option “use an existing virtual drive” and select win10.vmdk
    after that i change settings for this VM – in System I checked in “Extended features” – Enable EFI
    Thats all

  129. Hi there,

    Thank-you very much for this post. It has been immensely informative and helped me rescue my Windows install!

Leave a Reply