1

What can be the reason of such error? I tried to compact both via DISKPART and Optimize-Vhd commandlet.

Via DISKPART I get following error:

DISKPART> compact vdisk

DiskPart has encountered an error: The requested operation cannot be performed on a virtual disk of this type.
See the System Event Log for more information.

Via Hyper-V commandlet I get such exception:

 Optimize-Vhd : Failed to compact the virtual disk.
 The system failed to compact 'd:\boot.vhd'.
 Failed to compact the virtual disk.
 The system failed to compact 'd:\boot.vhd': The requested operation cannot be performed on a virtual disk of this
 type. (0xC03A001B).
 At line:1 char:1
 + Optimize-Vhd -path D:\boot.vhd -Mode Full
 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     + CategoryInfo          : NotSpecified: (:) [Optimize-VHD], VirtualizationException
     + FullyQualifiedErrorId : OperationFailed,Microsoft.Vhd.PowerShell.Cmdlets.OptimizeVhd

I reviewed similar questions here (e.g. this) and they are not relevant to me. My VHD is not the VM (it wasn't created by Hyper-V), and I have no file system limitation error.

VHD can be perfectly attached in Disk Management applet, which is weird, 'cause this applet should use the same APIs as PS cmdlets or DISKPART.

P.S. I run Win10 x64 Pro, DiskPart version 10.0.16299.15 and PS version

Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      16299  64
  • 1
    My VHD is not the VM (it wasn't created by Hyper-V), and I have no file system limitation error. - I don't understand what you mean. Can you clarify this statement? – joeqwerty Dec 5 '17 at 21:00
  • The DISKPART error says See the System Event Log for more information.. If you check Event Viewer, what do you find? – Ben Scott Dec 5 '17 at 22:29
  • @joeqwerty, this just mean that I have another error (as stated above) and therefore those question is not related to my problem. By My VHD is not the VM I mean that this VHD is not a virtual Hyper-V machine, but a dump of SD-Card, created by third-party app. – Suncatcher Dec 6 '17 at 8:49
  • Moreover, the VHD is perfectly opened/attached by Disk Management applet, which is weird, 'cause it should use the same APIs as PS cmdlets or diskpart. – Suncatcher Dec 6 '17 at 8:50
  • @BenScott, nothing new. Here are the screens from Event Viewer relevant to cmdlet: 1, 2. Also I tried to search eventwvr for diskpart events (e.g. by userpnp source) but found nothing relevant. Maybe you suggest another search strategy? – Suncatcher Dec 6 '17 at 9:06
0

Have you checked that the 3rd party tool you're using creates dynamically expanding VHDs? According to this article, compact operation is only supported on dynamically expanding VHDs.

  • There is little to zero info in this tool about VHD it creates. Is there any way to check if my VHD is dynamically expanding? – Suncatcher Dec 25 '17 at 6:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.