Having learned a new trick today, I feel the need to share. I needed to get some files off a virtual hard disk image created in Microsoft VirtualPC, and I did not want to have to create a new guest VM or attach the drive to an existing guest. As it turns out, Windows 7 and Windows 2008 can both mount a VHD file as a disk and access it like a regular drive, or in read-only mode if you are trying to be careful. This is pretty handy, and both faster and easier than trying to do it any other way.
Of course, like so many other things from Microsoft that are version 1.0, it’s not the most intuitive, you might never notice it is even there, and you have to go two different places to accomplish the task. But that’s okay, we can deal with that in exchange for a pretty nice feature.
This is how we do it.
- Launch Computer Management using either Administrative Tools, or by right-clicking Computer, Manage.
- Browse down to Disk Management, and then go get coffee while you wait for it to connect to the Virtual Disk Service (no relation.) Mmmm…coffee.
- From the Action menu, click Attach VHD
Or you could right-click Disk Managment and do the same thing…it looks like this…
- Fill in or browse to the location of the VHD file. Note the option here to mount the drive read-only.
- Click OK to mount the drive. You will see this.
followed by a message that the driver was installed successfully. If you encounter an error about "the system cannot locate the parent virtual hard disk for the differencing disk" it means that you have a differencing disk. You’ll need to boot the VM that owns this and commit changes, or choose the parent disk instead. - Your VHD is now mounted as a basic disk. The system will assign it a letter automagickally, but you can choose a different letter if you wish, just like any other drive.
- When you are done, you will want to dismount the drive. To do that, come down to the disk, right-click it and select Detach VHD. Be careful not to select the box to delete the VHD unless that is what you really want to do! It’s not selected by default, but we all know how click-happy we can get at times.
You might have noticed that you also have the option to create a VHD. This is pretty straight forward, and is useful if you need to prestage VMs, create data drives for VMs, etc. without having to launch a guest first. Just provide the path and file name, the size in MB, and whether you want it to expand as needed up to the maximum, or preallocate all the space up front.
And speaking of how we do it, here’s a classic from 1995 by Montell Jordan. Damn, 1995? Really? I think I am missing about a decade of my life somewhere…anyone seen ten years laying around somewhere? </shuffles off muttering something about damn kids and staying off the lawn>
Direct link for RSS and email subscribers…http://www.youtube.com/watch?v=0hiUuL5uTKc
Have any other tricks for dealing with virtual disks you’d like to share?
You might also enjoy:





