Sponsored Links

VirtualBox on Windows 7 Host with Raw Disk Access – Solution to Randomly Changing Disc Assignment Numbers

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…

Ruh-Roh!

 

 

 

“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…

 

Something fishy going on here…

 

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

Search google for “Windows 7 WinObj” and download it from whichever source you trust/ are comfortable with. It’s part of the SysInternals utilties at http://technet.microsoft.com/en-us/sysinternals  .

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.

WinObj showing the “GLOBAL??” part of the Windows Object Tree

 

 

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.

 

 

I highlighted the part about my old system disk.

 

 

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”…

Shows the entry for “Harddisk0”

 

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.

 

 

The entry for “Harddisk1”

 

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”…

Entries in the ArcName tree view

 

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…

Diagram starts from the middle, top half for one disc, bottom half for the other.

 

 

 

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;

multi(0)disk(0)rdisk(1)

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 description
RW 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…

No complaints…looks good so far.

 

 

 

 

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………

 

 

 

 

 

 

Hurrah!

 

 

 

And seemingly successfully reading the hard drive. Lets boot up Linux to test further…

 

 

 

 

 

 

Lookin good!

 

 

 

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 :)

 

VN:F [1.9.22_1171]
Rate This Article
Rating: 10.0/10 (45 votes cast)
VirtualBox on Windows 7 Host with Raw Disk Access - Solution to Randomly Changing Disc Assignment Numbers, 10.0 out of 10 based on 45 ratings
Share the knowledge :
Facebook Twitter Pinterest Linkedin Digg Delicious Reddit Stumbleupon Posterous Email Snailmail

21 comments to VirtualBox on Windows 7 Host with Raw Disk Access – Solution to Randomly Changing Disc Assignment Numbers

  • Chas

    OMG this saved me from a major headache!

    Thanks!

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • I am testing your post now to solve that problem… I suggest you to edit your post to point to the current sysinternals website. They were aquired by Microsoft, http://technet.microsoft.com/en-us/sysinternals. This could prevent others to download modified (malwared) versions of WinObj.

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • Guest

    Thanks for this guide, I use an external eSATA drive as raw disk and the drive order is rearranged by Windows constantly, so it was a lifesaver.
    The online/offline issue was a bit different for me though.
    If I keep the drive online I can always write to it.
    If I deleted the existing partitions in diskmgmt.msc and then set the drive offline, I was able to write to while offline. I then created a partition in the guest OS and tested write access. As long as I kept it offline and Windows didn’t discover what was happening to the drive, everything worked. But if I switch the status to online again (which would happen if I reconnect the external drive anway), Windows discovers the new partition. Write access was still working. When I set it to offline while there was a partition visible to Windows, VirtualBox terminated with an VERR_WRITE_PROTECT error when attempting to use write to this drive in the guest OS. When I set it to online again, I was once again able to write to the drive.

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • chepe263

    I have a USB Thumb Drive and there is nothing listed on ARCNAME.
     
    Is there somewhere else i can look for a persistent symlink?

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • thank's for this guide.
    On a windows 7 HOST, I want to start a Windows 7 guest from an e-SATA drive.
    I allways get a VERR_WRITE_PROTECT after a few seconds. I mean the guest system starts but stop after a few seconds with this error.
    I tried to set the e-SATA offline but it remain's the same. Any Idea ?
     
    regards

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • Virtual Zach

    Your tutorial was helpful, but I have a strange request.  So I don't want the VM to "boot" from the hard disk, I just want the VM to have full access to information from a hard disk.  For example
    Virtual C:\  <—Normal VM drive nothing special
    Virtual D:\  <—-I want to "mount" an extral hard drive I use for my host system here, so that i have full "direct" access to the Hard Drive.
    I do NOT want to just map the drive
    —The reason?
    I want a VM that I can use to point all my media streaming hardware to, without anyone browsing my host PC.  And if I map the drive, I can't share a shared directory.
    Just to recap, I do not want to stream from my host pc
    Any information is greatly appreciated.  Thanks!

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • hi  Kevin Cave,
    "I recently updated one of my systems to multiboot Windows 7 64-bit and Linux Mint 64-bit, on a spare 500GB hard drive."
    If I don't misunderstand, you mean you have installed a Linux OS 64-bit in virtual box running in Windows 7 64-bit, moreover, you grant the Linux OS raw disk access of the physical harddisk running Windows 7 ? How can that be possible? Windows 7 64-bits forbids raw access of current system disks. My ubuntu install CD (mounted ISO) won't boot up in the first place, the virtual box paused/locked up at the Ubuntu screen as long as I use entire raw disk which contains current running Win7.
    Please reply to xuancong84@gmail.com
    Thanks!

    VN:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • Adam

    Thanks for the info; I tried this with success with one VM.  There has been one issue, however, on the second VM.  I have attached 6 HDs to the system and only 4 of them are showing up in winobj under arcname.  I can see the drives in windows explorer and format and use them, but I can't see their arcname.  Any ideas?

    Note: These are all SATA drives some plugged into the motherboard controller and others plugged into a PCIexpress card. I have tried the missing drives in both configurations. It doesn’t seem to matter where they are plugged in.

    VA:F [1.9.22_1171]
    Rating: +3 (from 3 votes)
  • Stefan

    Unfortunately my three 1.5 TB, which are already configured with Linux software RAID 5, are shown anywhere but not ArcName, therefore I can’t use this approach. I hope the linux doesn’t care when it mounts the RAID if disks order change … I need to dig more …
    I suspect is the same issue “Adam” encountered with it’s two disks. My raid have a GPT based ext4 partition. Possible that windows registers ArcName IDs only if it recognize the disk structure or something.

    Thanks

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
    • Stefan

      After investigating more on this issue it seems that Windows always mounts the system disk as 0 and Ubuntu as sdaso the other remaining disks are part of raid 5 setup. I had built my raid using persistent bloc v1.2, therfore the disk order does not matter. My raid it’s working fine in guest OS like in the original host. The only drawback is that I cannot check SMARt from guest but I’m doing it from host.

      Thanks!

      VA:F [1.9.22_1171]
      Rating: 0 (from 0 votes)
    • Mave

      Stefan,

      I have same problem. I have 3 disk (1x160gb, 2x3TB). In ArcName only is listed the 160gb disk (as rdisk(0)).
      I think that the 3TB disks are not listed because are GPT.
      I have try to point the VirtualBox .vmdk to rdisk(1) or rdisk(2), and VirutalBox says “VERR_FILE_NOT_FOUND”.
      Using the original name (“\\.\PhysicalDrive1”) work (except when windows reboot and change disk order).

      How do you solve it?

      Thanks!!!

      VA:F [1.9.22_1171]
      Rating: 0 (from 0 votes)
  • Mave

    I have a problem with GPT disks. I have 3 disk (1x160gb, 2x3TB). In ArcName only is listed the 160gb disk (as rdisk(0)).
    I think that the 3TB disks are not listed because are GPT.
    I have try to point the VirtualBox .vmdk to rdisk(1) or rdisk(2), and VirutalBox says “VERR_FILE_NOT_FOUND”.
    Using the original name (“\\.\PhysicalDrive1”) work (except when windows reboot and change disk order).

    Any ideas?

    Thanks!!!

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • Thomas

    Thanks for the tutorial, I was really excited to get this working. However, I ran into the same issue that most everyone else did. I could only get up to 4 drives listed in ArcName. Those drives I was able to use as physical disks just fine. But I have a 5th drive I wanted to use, and Windows does not list an ArcName for it even though it shows up under devices. I’m stumped and really disappointed. Any pointers would be great.

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
    • I have looked into this. According to Microsoft:

      Theoretically, this syntax could be used to start Windows NT on any drive in the system. However, this would require that all drives are correctly identified through the standard INT 13 interface; since support for this varies from disk controller to disk controller and most system BIOS only identify a single disk controller through INT 13, in practice it is only safe to use this syntax to start Windows NT from the first two drives connected to the primary disk controller, or the first four drives in the case of a dual-channel EIDE controller.

      In a pure IDE system, the MULTI() syntax will work for up to the four drives maximum on the primary and secondary channels of a dual-channel controller.

      In a pure SCSI system, the MULTI() syntax will work for the first two drives on the first SCSI controller (that is, the controller whose BIOS loads first).

      In a mixed SCSI and IDE system, the MULTI() syntax will work only for the IDE drives on the first controller.

      I found this at : http://support.microsoft.com/kb/102873

      So basically there is a limit of 4 partitions or drives. Blame Microsoft ;)

      VN:F [1.9.22_1171]
      Rating: 0 (from 0 votes)
  • Optionator

    Thank you so much for this HOWTO. I just got bitten by this behaviour when I booted my machine today and thanks to your detailed rundown I was able to resolve it in a matter of minutes.

    Cheers

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • Dave

    I ahve downloaded winObj and when I look into device>HardriveX there is nothing there. Did I miss something?

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • vagy

    Pretty witty catch, thank you!
    Your text should be copy/pasted into the VirtualBox documentation to save us some more grey hair :-)
    Cheers

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • Jim

    “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).”

    —————
    I am now specifically requesting instructions on how to set up a Windows 7 hosted virtual machine with full raw disk access. I have searched the web and cannot resolve the “VERR_SHARING_VIOLATION” error message.

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • CHEN

    It works amazing!!! Thanks a lot and i will post this to virtualbox forum.
    Regards.

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • […] disk vmdk file to make sure you don’t use it accidentally. 3) Follow the instructions on this post by Kevin Cave to create a raw virtual disk file that will always point to the correct […]

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

  

  

  

This site uses Akismet to reduce spam. Learn how your comment data is processed.