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
Suncatcher
  • 594
  • 2
  • 7
  • 22
  • 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 05 '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 05 '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 06 '17 at 08: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 06 '17 at 08:50
  • @BenScott, nothing new. Here are the screens from Event Viewer relevant to cmdlet: [1](https://imgur.com/Qbh79Ar), [2](https://imgur.com/scmbjBk). 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 06 '17 at 09:06
  • @Suncatcher - I can offer this much: 0xC03A001B is ERROR_SECTOR_NOT_FOUND. I was assuming that had to be bogus, since it is a VHD. But now you mention the VHD was created by a third-party tool. That makes me suspect a bug in that third-party tool. I would suggest contacting the provider of said third-party tool. – Ben Scott Dec 06 '17 at 13:44
  • but why `VHD is perfectly opened/attached by Disk Management applet` as I stated before? Doesn't it use the same API as diskpart or PS? – Suncatcher Dec 06 '17 at 15:37

1 Answers1

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.

Bob Hyman
  • 51
  • 2
  • 6
  • 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 06:48