UPDATE, 2013-07-01: I’ve had people coming back saying they can’t see some drives using this method. There is an explanation for this. The tl;dr is that Microsoft placed a hard limit of 4 drives/partitions, because Windows NT (!!) could theoretically only boot from a maximum of 4 partitions it can get reports back from a system’s BIOS. read the KB article at http://support.microsoft.com/kb/102873 .
I recently updated one of my systems to multiboot Windows 7 64-bit and Linux Mint 64-bit, on a spare 500GB hard drive.
On the old hard drive I had Windows XP and Ubuntu 11.04, and I wanted access mainly to the old Ubuntu Installation, in case there was information on there that I needed for the fresh OS installs, so that was attached to a spare SATA interface as well, and I had set up Virtualbox 4.1 on WIndows 7 with raw disk access, to boot straight up into the old Ubuntu installation at my leisure.
It all worked great, until I booted into Win7, fired up VirtualBox and tried to start the “OldSystem” VM…
“What on earth is going on!?”, I wondered – note that that’s the polite version of what I said ;)
Eventually I figured out that there’s nothing wrong with the old system disk, and that it must be something to do with the way the raw disk was configured in the Virtualbox VM settings. So I took a peek at the Disk Management utility of Windows 7…
There we go… upon bootup, Windows 7 has enumerated the hard disks in my machine differently from when I first set up Virtualbox!
The new 500GB system disk has been designated as “Disc 1” and the old disk as “Disk 0” – argh!
[As an aside, note that the old disk ( now known as Disc 0) is also marked as “Offline” – you need that to be that way if you want Virtualbox to be able to access the disk as a raw partition and have read/write permission. If the disk is Online in Windows, you’ll only get read access.]
So. “How Can This Be!?!?!?” was the next question asked. A lot of googling and it turns out that Windows 7 does in fact change Disc number assignments, seemingly at random during each boot. This is Not A Good Thing, because of the way Virtualbox Raw Disk Access needs to be configured, at the time of writing this article.
What I need to do is to tell Virtualbox to look specifically for the target hard drive, no matter what Windows decides to do that morning as I boot my machine up, so, here’s how I did it…
1) Obtain a utility called WinObj
Then after you’ve unzipped it somewhere (and scanned for viruses I might add) , run it as Administrator – you’ll need to otherwise you won’t have permission to see the data you’re looking for.
Go to where you see “GLOBAL??” in the tree view on the left, and click on that. You’ll see lots of entries appear on the right hand side.
Scroll down a bit and you’ll see entries for your HDD’s – depending on how many physical hard drives you have installed and the order in which Windows randomly enumerated them.
Now mosey on over to the left hand side again and click on the tree view where it says “Device”…
This shows the list of partitions for each hard disc enumerated during boot (or presumably added after boot if someone has done so). In this case, though, it only shows a “Partition 0” – probably because I have set the disk as being Offline.
This corresponds to the new 500GB hard drive I put in and installed Win7 & Ubuntu onto.
So, looks like I need to keep “Harddisk0” in mind when looking for the ARCNAME entry which we’re coming to in a moment.
Go back to the tree view on the left hand side again and click on the entry called “ArcName”…
As you can see there are 3 headings on the right hand pane; Name , Type, and Symlink, followed by loads of entries for each of the enumerated hard drives on your system.
For example multi(0)disk(0)rdisk(0) corresponds to a symlink of DeviceHarddisk1Partition0 on my system at least – yours will be different.
It is these entries ( multi(blah)disk(blah)rdisk(blah) ) that we’re interested in, as we’re going to use the one or ones that we want, to give to Virtualbox as a persistent entry to use and look for, no matter how many times you reboot Windows.
Before we do that, allow me to visually sum up the relationship between the Disk Management utility, and GLOBAL??, Device, and ArcName in the Windows objects database, of course relevant for my particular hardware setup…
I hope I’ve made the relationships clear enough for you, and that the diagram makes sense.
As you can see from what I’ve said above and the screenshots of Disk Manager and the diagram to the left, the Disk my “old system” resides in, is currently known as “Disc 0” to Windows 7.
Subsequent to that, using the SysInternals WinObj utility, I can now trace the Object name right back to;
So, what do we do after that?
2) Configure your VirtualBox VM so that from now on, even if Windows randomly changes the Disc # designation upon reboot, VirtualBox knows where to look!
A) For an existing VM configuration with an already configured VMDK file for Raw Disk Access…
On Windows, my VirtualBox VM configurations are stored in C:\Users\kcave\.VirtualBox . Of course your username will be different.
My VMDK file, OldSystem.vmdk, describes to VBox where to go and look for my hard drive.
Currently, the file contains the following…
# Disk DescriptorFile version=1 CID=8f361a5a parentCID=ffffffff createType="fullDevice" # Extent description RW 625142448 FLAT "\\.\PhysicalDrive1" 0 # The disk Data Base #DDB ddb.virtualHWVersion = "4" ddb.adapterType="ide" ddb.geometry.cylinders="16383" ddb.geometry.heads="16" ddb.geometry.sectors="63" ddb.uuid.image="ccafde72-8d92-462e-b70d-897ce8e1641e" ddb.uuid.parent="00000000-0000-0000-0000-000000000000" ddb.uuid.modification="0b229951-5750-4e2e-a606-41d10be37dac" ddb.uuid.parentmodification="00000000-0000-0000-0000-000000000000" ddb.geometry.biosCylinders="1024" ddb.geometry.biosHeads="255" ddb.geometry.biosSectors="63"
NOTE : Make a backup copy of this VMDK file before editing it!
What needs to be changed, is the parameter under the comment “#Extent Description”;
# Extent description RW 625142448 FLAT "\\.\PhysicalDrive1" 0
Specifically, what I have highlighted above.
Edit your VMDK file so that it specifies the Object we discovered earlier, it needs to be like this… once again this is for my specific hardware configuration, yours will be different, depending on the number of hard disks you have installed, among other things;
# Extent descriptionRW 625142448 FLAT "\\.\GLOBALROOT\ArcName\multi(0)disk(0)rdisk(1)" 0
You can obviously see what is going on here. “GLOBALROOT” is how VirtualBox will reference entries under the tree of Objects we examined using WinObj, and the enumerated hard drive will be referenced by “multi…” under “ArcName”. It’s actually very simple when you get the hang of it.
Save your file, and load up VirtualBox…
Looking at the “Storage” section on this screen for my “OldSystem” virtual machine, there are no error messages, so it seems we can fire up the Virtual Machine. It should be okay, so………
And seemingly successfully reading the hard drive. Lets boot up Linux to test further…
And it successfully boots up and works.
And that’s it for changing an existing VM configuration. From now on, no matter what Windows 7 does to the Disc # designation, Virtualbox should always know where to find it :)
B) Setting a VM up from scratch…
I won’t go into the fine details of how to set up a Windows 7-hosted virtual machine with full raw disk access – there are countless places which show you how to do that (okay, I will, if and when someone specifically requests this).
Basically, go through all the Disk identification steps I outlined above, and once you have your disk Object identified, and are about create a VMDK file using the VBoxManage internalcommands createrawvmdk command, instead of giving “PhysicalDrive1” as your argument, use the “\\.\GLOBALROOT\ArcName\multi(0)disk(0)rdisk(1)” string instead.
Thus the VBoxManage command should look something like this…
VBoxManage internalcommands createrawvmdk -filename “C:\Users\kcave\.VirtualBox\SomeRawDiskNameOfYourChoice.vmdk” -rawdisk “\\.\GLOBALROOT\ArcName\multi(0)disk(0)rdisk(1)”
Well, it’s now 0019hrs and I’m sleepy :)
I do hope this article has been of help.
Edit: I have in fact tested this by switching the 2 hard drives onto different SATA ports and booting back up… no matter what order Windows enumerates the drives, the Virtualbox configuration still accesses the correct disk :)