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.

Sponsored Content

Passwords Haven’t Disappeared Yet

123456. Qwerty. Iloveyou. No, these are not exercises for people who are brand new to typing. Shockingly, they are among the most common passwords that end users choose in 2021. Research has found that the average business user must manually type out, or copy/paste, the credentials to 154 websites per month. We repeatedly got one question that surprised us: “Why would I ever trust a third party with control of my network?

/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 users 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.

VHDMOUNT /p [/f] VHDFileName
VHDMOUNT /m [/f] VHDFileName [DriveLetter]
VHDMOUNT /u [/c | /d] VHDFileName | All
VHDMOUNT /q VHDFileName | All

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:

Windows Registry Editor Version 5.00 




@="\"C:\Program Files\Microsoft Virtual Server\Vhdmount\vhdmount.exe\" /u \"%1\"" 


[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Virtual.Machine.HD\shell\Mount] [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Virtual.Machine.HD\shell\Mount\command] @="\"C:\Program Files\Microsoft Virtual Server\Vhdmount\vhdmount.exe\" /p \"%1\"" [HKEY_CLASSES_ROOT\.vhd] @="Virtual.Machine.HD"

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:

  1. 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”.
  2. 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 youre 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.

Got a question? Post it on our Virtual Server & Virtual PC Forum!

Related Topics:

Live Webinar - Thursday, December 2nd! Active Directory Masterclass: AD Configuration Strategies for Stronger SecurityREGISTER NOW - Thursday, December 2, 2021 @ 1 pm ET

Active Directory (AD) is leveraged by over 90% of enterprises worldwide as the authentication and authorization hub of their IT infrastructure—but its inherent complexity leaves it prone to misconfigurations that can allow attackers to slip into your network and wreak havoc. 

Join this session with Microsoft MVP and MCT Sander Berkouwer, who will explore:

  • Whether you should upgrade your domain controllers to Windows Server
    2019 and beyond
  • Achieving mission impossible: updating DCs within 48 hours
  • How to disable legacy protocols and outdated compatibility options in
    Active Directory

Sponsored by: