"Could not create virtual disk" ... "The process cannot access the file because it is being used by another process"
Published 20 June 2018
This error may occur when creating a clone. It has been seen when a clone is made of an image where the image destination folder path has a forward slash ( / ) in it, instead of the Windows backslash ( \ ).
For example, this error may occur with this path:
But would not occur with this equivalent path:
Try recreating the image with no forward slashes in its paths.
If you have difficulty deleting the malfunctioning image, you can either restart the machine that is storing the image, restart the machine that created the image, or follow this procedure to detach the image:
- Identify which machine created the image.
- For a live database copy, this will be the machine that contains the original database. For an image from backup, this will be the machine that hosts the temporary instance that was used to create the image.
- A SQL Clone agent will have been installed on this machine.
- On that machine, open Disk Management.
- In the lower section, for each row named 'Database VHD', right-click on the left-hand section of the row and select Detach VHD (but don't click OK yet). See image below.
- Disk Management will then confirm the virtual hard disk location with you.
- Use this information to find the Database VHD row for the image VHD. This will be identifiable by the following:
- It will be in the image destination folder.
- It will contain a sanitized version of the full image name.
- It will end with just 'vhd', not 'disk.vhd'.
- If the VHD is not the image VHD, then cancel out and move to the next.
- Detach the located image VHD.
Now retry deleting the image.
An example of detaching a VHD.