I'm trying to create, mount and format VHDX using Powershell in VM. The first step works without any problems:
New-VHD -Path $path -Dynamic -SizeBytes 20GB
But now, when I try to mount it:
Mount-VHD -Path $path
Powershell raises this error:
Mount-VHD : Failed to mount the virtual disk.
The system failed to mount <my_path>.
The operation cannot be performed while the object is in use.
At line:1 char:2
+ Mount-VHD -Path <my_path>
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceBusy: (Microsoft.Hyper...l.VMStorageTask:VMStorageTask) [Mount-VHD], Virtualizat
ionOperationFailedException
+ FullyQualifiedErrorId : ObjectInUse,Microsoft.Vhd.PowerShell.MountVhdCommand
Why does it says that it's in use? What should I do to be able to mount it?
EDIT:
If I try to mount it through context menu, it raises this error: