locked
VHD drive , auto mount ? RRS feed

  • Question

  • Hello,

    How can I mount VHD file to drive at System startup ?

    Like:
      Create E.VHD file,
      Mount E.VHD to E drive.
      But, After reboot, E drive dose not mount.

    Regards,
    MVP for SQL Server / PASSJ board / COZAX Co, Ltd.
    Wednesday, February 25, 2009 6:08 AM

Answers

  • hi there,


    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.

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


    hope this helps


    sainath Windows Driver Development
    Wednesday, February 25, 2009 7:03 AM
    Moderator

All replies

  • hi there,


    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.

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


    hope this helps


    sainath Windows Driver Development
    Wednesday, February 25, 2009 7:03 AM
    Moderator
  • I think the simpliest resolution of this problem in Windows Server 2008 R2 (and in Windows 7) is to use Microsoft DISKPART utility (that is being a part of Windows):

    First, you need to create a script file for diskpart containing commands to mount desired images. Create a text file (e.g. in notepad) and insert folowing lines here replacing %path to vhd% with full path to the vhd image (e.g. c:\work\Virtual Disk.vhd):
    SELECT VDISK FILE="%path to vhd%"
    ATTACH VDISK

    You can duplicate these lines for every vhd image you need to have been mounted.
    Save this file on your local disk with any name (e.g. c:\work\vhdmount.s).
    Then create a text file containing folowing line (replacing %path to script% with the full path to the script from previous step):
    diskpart -s "%path to script%"
    And save this file as .cmd file (e.g. vhdmount.cmd).
    Place this file in the windows startup folder (e.g. C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup).
    Reboot your pc and specified image file(s) will be automatically mounted.

    b.r., ap3rus
    • Proposed as answer by Vlad Nagorny Sunday, March 15, 2009 10:48 AM
    Sunday, March 15, 2009 10:48 AM