Compartilhar via


Mounting virtual hard disks at the command line

Virtual Server includes a utility called VHD Mount that provides the ability to mount a virtual hard disk file (.vhd file) as a virtual disk device on the host operating system. You can access this functionality manually by using the command-line tool or programmatically through APIs. The following sections describe the command-line tool. For more information about the VHD Mount APIs, see the Virtual Server Programmer's Guide.

Note

   You must have administrative credentials to run VHD Mount. When User Access Control (UAC) is enabled in Windows Vista®, you need to run VHD Mount as an administrator.

Note

By default, VHDMount mounts the virtual hard disk by creating a temporary Undo disk in the user's %TEMP% folder, and all changes are made to this Undo disk. This behavior can be overridden by the /f option as described below.

Installing VHD Mount

VHD Mount components are installed as part of Virtual Server default installation at \Program Files\Microsoft Virtual Server\VHDMount. To install only the VHD Mount components, use the Custom option in the Virtual Server installer and clear all components except VHD Mount.

To perform an unattended installation of the VHD Mount components

  1. Extract Virtual Server 2005 Install.msi from Setup.exe by typing the following command:**setup.exe /c /t <drive letter>:\<path to the .msi file>**For example, to extract "Virtual Server 2005 Install.msi" to C:\SetupFiles, type:setup.exe /c /t c:\SetupFiles

  2. Start an unattended installation of VHD Mount by typing the following command:msiexec /i "Virtual Server 2005 Install.msi" /qn ADDLOCAL=VHDMount

Using the VHD Mount command-line tool

The VHD Mount command-line tool mounts a virtual hard disk file (.vhd file) as a virtual disk device.

Syntax

vhdmount {/p <VHDFileName> | /m <VHDFileName> [<DriveLetter>] | /f /u {<VHDFileName> [/c | /d] | All} | /q {<VHDFileName> | All}}

Parameters

Parameter Description

/p

Plugs in the specified .vhd file as a virtual disk device without mounting the volume.

/m

Plugs in the specified .vhd file as a virtual disk device and mounts the volume. DriveLetter is optional. If drive letter is specified, the volumes are mounted starting at the specified drive letter. If drive letter is not specified, it is automatically assigned.

Note   The /m option uses Windows Virtual Disk Service (VDS) APIs to mount volumes on the disk. VDS APIs are only available in Windows Server 2003, Windows Server 2008, and Windows Vista. This means that /m does not mount the volumes when the host operating system is Windows XP. However, you can mount volumes manually in Windows XP by using Disk Manager.

/u

Unplugs the virtual disk device for the specified VHDFileName or on all mounted virtual disk devices. VHDFileName is the fully qualified path of the .vhd file.

/q

Returns the disk identifier of the mounted virtual disk device for the specified VHDFileName, or on all mounted virtual disk devices. VHDFileName is the fully qualified path of the .vhd file.

/f

Mounts the virtual hard disk without an undo disk. All changes are made to the original virtual hard disk. By default, VHDMount mounts the virtual hard disk by creating a temporary undo disk, and changes are made to the undo disk.

/c

Updates the original .vhd file with all changes that were stored in the undo disk file and deletes the undo disk file before unplugging the disk.

/d

Discards all changes to the mounted disk and deletes the undo disk file before unplugging the disk.

Note

Options /c and /d are only applicable if the .vhd file was mounted without using /f.