Error: specifying non-vhd SourcePath for CreateVirtualDisk


  • according to,
    the SoucePath in the CREATE_VIRTUAL_DISK_PARAMETERS structure is
    "Optional fully qualified path to pre-populate the new virtual disk object with block data from an existing disk.
    This path may refer to a virtual disk or a physical disk."

    I was able to specify SourcePath as an existing .vhd file and it works fine.
    However, I was not able to specify SourcePath as any of the followings (vss shadowcopy):
    1. \\\\?\\GLOBALROOT\Device\\HarddiskVolumeShadowCopy31
    CreateVirtualDisk returns error 0x57, the parameter is incorrect
    The shadowcopy was created by using vshadow.exe

    2. \\Device\\HarddiskVolumeShadowCopy31
    CreateVirtualDisk returns error 0x57, the parameter is incorrect
    The shadowcopy was created by using vshadow.exe

    3. \\\\?\Volume{71591178-04af-11e1-9ebf-806e6f6e6963}\\
    CreateVirtualDisk returns either error 0x5, access denied when mount point has been created, or
    error 0x15, device is not ready when no mount point has ever been created.
    This volume is either a volume on physical disk, or an exposed shadow copy volume.

    My question is how to specify SourcePath to a VSS snapshot? or to a physical disk?
    or anything other than .vhd? 
    If SourcePath only supports .vhd (or .vhdx), should the manual be revised accordingly?

    Found similar posts with identical question without answers.


    env: VS2010 + sp1, Windows SDK 7.1 and 7.0a, on Windows 7 professional x64 + sp1,
    running with elevated privileges
    source code: assign the fully qualified path to "params.Version1.SourcePath" in the following code.

    BOOL CreateVHD_Fixed(PCWSTR pszVhdPath, ULONG sizeInMB)
        BOOL bRet = FALSE;
        HANDLE hvhd = NULL;
        VIRTUAL_DISK_ACCESS_MASK        mask;
        VIRTUAL_STORAGE_TYPE            vst =

        wprintf(L"CreateVHD_Fixed %s, size (MB) %d\n", pszVhdPath, sizeInMB);

        params.Version1.UniqueId            = GUID_NULL;
        params.Version1.BlockSizeInBytes    = CREATE_VIRTUAL_DISK_PARAMETERS_DEFAULT_BLOCK_SIZE;
        params.Version1.MaximumSize  = sizeInMB * 1024 * 1024;
        params.Version1.ParentPath  = NULL;
        params.Version1.SourcePath          = NULL;
        params.Version         = CREATE_VIRTUAL_DISK_VERSION_1;
        mask                                = VIRTUAL_DISK_ACCESS_CREATE;

        DWORD ret = CreateVirtualDisk(&vst,
            // To create a dynamic disk, use CREATE_VIRTUAL_DISK_FLAG_NONE instead.

        if (ret == ERROR_SUCCESS)
            bRet = TRUE;
      if (INVALID_HANDLE_VALUE != hvhd)
            bRet = FALSE;
            printf("failed to create vdisk...err 0x%x\n", ret);

        return bRet;

    26 апреля 2012 г. 22:55


  • Hi,

    According to the description, it seems that you want to develop some application. If so, it is recommend you to get further support in the corresponding community so that you can get the most qualified pool of respondents. Thanks for your understanding.
    For your convenience, I have list the related link as followed.
    MSDN Forums

    27 апреля 2012 г. 2:51
  • This works: \\\\.\\PHYSICALDRIVE1

    (Note it is drive, not disk.)

    The other part I am working on is to create VHD from a VSS snapshot.  It seems SourcePath cannot be a VSS snapshot (which is at volume level).  In order to create a VHD from a VSS snapshot, one needs to copy directory tree and meta data (ACLs, NTFS streams, etc.) from VSS snapshot to VHD.  Is there any efficient way to do this?  Any pointers are welcome.


    30 апреля 2012 г. 19:59

Все ответы