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.
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 [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Virtual.Machine.HD] [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Virtual.Machine.HD\shell] @="Mount" [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Virtual.Machine.HD\shell\Dismount] [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Virtual.Machine.HD\shell\Dismount\comma nd] @="\"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:
- 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”.
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!
More in Virtualization
Microsoft Adds SSO and Passwordless Authentication Support to Azure Virtual Desktop
Sep 27, 2022 | Rabia Noureen
VMware to Launch New vCenter Converter Tool in Beta
Sep 14, 2022 | Rabia Noureen
Microsoft's Arm-based Azure VMs with Ampere Altra Chips Are Now Generally Available
Aug 31, 2022 | Rabia Noureen
VMware Fusion 22H2 Tech Preview Adds Windows 11 Support to Apple Silicon Macs
Jul 29, 2022 | Rabia Noureen
Microsoft Announces Ephemeral OS Disk Support for Confidential Azure VMs
Jul 6, 2022 | Rabia Noureen
Is VMware Doomed After Broadcom's $61B Takeover Bid?
Jul 1, 2022 | Russell Smith
Most popular on petri