Saturday, April 28, 2012

Windows 7 Attach VHD (Virtual Hard Disk)

One of the feature that I like in Windows 7 is the ability to attach VHD file format in Windows 7 and assign it a drive letter. It is a very simple process. To do that, you can do the following (you will need Administrator privilege to do this):

  • Go to the Start menu, then right click on Computer. On the context menu, select Manage. This should open up the Computer Management window.
  • In the Computer Management window, go to StorageDisk Management.

image

  • Then on the top menu, select Action Attach VHD. It should then ask you the location of the VHD file that you have. And also it has the option to attach the VHD as a read-only drive. Once you have select the location and whether or not you want to open the VHD as a read-only drive, click on the OK button.

image

  • It should then attached the VHD to your system and assigned it a drive letter. You can then access that VHD content by opening up your Windows Explorer and going to the assigned drive letter. In my case, it is drive L.

image

This is very useful for me because, occasionally I want to grab some files out of one of my virtual box guest system quickly without firing on the guest system. I can just attached the virtual box VHD and copy the file that I need.

There are some limitations when it comes to attaching VHD to Windows 7. One of those limitations is that you can only attach VHD file that is local to you system. If you try to attach VHD file from a network share, you will most likely get the following error message:

image

The version does not support this version of the file format.

There are some other limitations that you need to be aware of, such as you can only attach VHD that is on NTFS file system and the VHD could not be compressed or encrypted. For more details on the limitations, please refer to this TechNet article.

Additional Notes:

  • Speaking of VHD, one tool that I found pretty handy is Disk2VHD. The tool allows us to create VHD from the physical disk that we have. It is sort of creating a snapshot of your physical disk.