Mounting VHD files with VHDMount - Microsoft Virtual Server

Virtual Server 2005 R2 SP1 includes a tool called VHDmount that allows you to mount a virtual hard disk (which in fact is a .VHD file) directly on your host operating system. You can get Virtual Server R2 SP1 for free right here: “Virtual Server 2005 R2 SP1 now available“.
VHDMount is provided as a command line tool. You can perform various tasks by either running it directly from the Command Line, or by using simple batch files that do what you need to do. Some of the capabilities of VHDMount are:

/p – Plugs in the specified VHD as a virtual disk device without mounting the volume.

/m – Plugs in the specified VHD as a virtual disk device and mounts the volume.

/f – Performs the specified operation without creating an Undo Disk. This parameter is applicable for /p and /m. All changes to the mounted disk are directly written to the specified VHD.

/u – Unplugs the virtual disk device for the specified VHDFileName.

/c – Updates the original VHD with all changes that were stored in the Undo Disk anddeletes the Undo Disk after unplugging the disk. This parameter is only applicable if the VHD was mounted without using /f.

/d – Discards all changes to the mounted disk and deletes the Undo Disk after unplugging the disk. This parameter is only applicable if the VHD was mounted without using /f.

/q – Displays the disk name of the mounted virtual disk device for the specified VHDFileName.

VHDFileName – VHD name including full path.

DriveLetter – Optional parameter for /m option. If drive letter is specified the volumes are mounted starting at the specified drive letter. If drive letter is not specifiedit is automatically assigned.

All – Applies the operation on all mounted virtual disk devices. This parameter is applicable for /u and /q.

By default, VHDMount creates an Undo Disk in current user‘s temporary folder. All changes to the mounted disk are written to this Undo Disk. Use /c to commit or /d to discard these changes at the time of unplugging the disk device. Use /f option to mount a VHD without an Undo Disk.

Integrating VHDMount in the Explorer context menu

Ben Armstrong, a Program manager on the core virtualization team at Microsoft, has published a neat registry trick that allows you to mount VHDs by just double clicking on them. By creating a .reg file with the following contents:

Double click on the .reg file (to load it into your registry) you will be able to double click a VHD to mount it, and right click on it to dismount it.

Windows will auto-install the correct driver and allow you to see the .VHD file as a new hard drive.

Issues with Windows Vista

Two notes about using this trick with Windows Vista:

For some reason ‘double click‘ does not work in Windows Vista. The only way around it is to right-click on the .VHD file and select “Plug in”.

VHDMount needs to run ‘As Administrator‘. You can either disable UAC (read my “Disable UAC in Vista” article), or, to get this to work with UAC enabled, you will need to configure VHDMount.exe, go to the Compatibility Mode tab, and check “Run this program as an administrator”.

When you‘re done working with the mounted .VHD file you can right-click it and either choose to commit changes, or not.

Get the functionality of VHDMount without installing Virtual Server

If you need VHDMount but you don’t need or want to install Virtual Server you can install only the VHDMount components, use the Custom option in the Virtual Server R2 SP1 installer and clear all components except VHDMount.

MEMBER LOGIN:

BECOME A PETRI MEMBER:

About the Contributor

Daniel Petri is a world-known IT professional, technical trainer and creator of one of the world’s largest IT knowledge bases – www.petri.com. Daniel consults to leading global Fortune 1000 companies in Microsoft IT Infrastructure and Engineering strategies.

For his contribution to the IT Pro community Daniel has received the Microsoft Most Valuable Professional (MVP) award for the 14th time. Daniel’s professional certifications include Microsoft Certified Technology Specialist, Microsoft Certified Systems Engineer, Microsoft Certified System Administrator and Microsoft Certified Trainer.

While working for Microsoft, Daniel serves as a Senior Premier Field Engineer (PFE) specializing in Windows Server OS and Active Directory.
Daniel now works for ObserveIT, makers of the Insider Threat Detection software, where he holds the role of Senior Solutions Architect, where he manages large deployment projects and partner and customer training programs.

In his spare time, Daniel rides a 1200cc 2015 model Ducati Multistrada 1200S bike and manages the Israeli Bikers forum.