Q: Why can't I shrink a Virtual Hard Disk file to my desired size?
Shrinking a VHD file to the size you want might not be possible, even when using the proper cmdlet. Here's why.
October 20, 2012
A: A Virtual Hard Disk (VHD) or VHDX file can be shrunk to reduce its size (or possible size, if dynamic) by using the Resize-VHD cmdlet.
However, you might hit a problem where the VHD can't be shrunk by as much as expected, even though in the case of a dynamic VHD, the actual physical size of the VHD on disk is far less than the size you are trying to resize to.
The important part isn't the VHD's size on disk but rather the size of volumes that have been created inside the VHD. You can't shrink a VHD size below the size of created volumes. This can be seen with the Get-VHD command:
PS D:> get-vhd d:temptemp2tb.vhdx
Which returns the output below:
ComputerName : SAVDALHV01
Path : D:temptemp2tb.vhdx
VhdFormat : VHDX
VhdType : Dynamic
FileSize : 339738624
Size : 2199023255552
MinimumSize : 220023767552
LogicalSectorSize : 512
PhysicalSectorSize : 4096
BlockSize : 33554432
ParentPath :
FragmentationPercentage : 6
Alignment : 1
Attached : True
DiskNumber : 7
IsDeleted : False
Number : 7
The MinimumSize value shows the smallest size the VHD can be shrunk to. In this case, the size is 200GB because I have a 200GB volume created inside the VHD. If I shrink the size of the volume inside the VHD file (or remove it) that would reduce the size I can shrink the VHD to.
About the Author
You May Also Like