5331 private links
Lots of people confuse “shrink” with “compact” for virtual hard disks. The “compact” operation squeezes the empty bits out of a dynamically expanding hard disk to reduce the amount of space that it consumes on physical disk. Compacting does not alter the maximum size of the disk, nor does it report anything different to the guest operating system. Furthermore, “compact” does not work on fixed VHDX at all. The “shrink” operation, the topic of this article, reduces the physical consumption of a VHDX and reduces the disk size reported to the guest OS. //
What to remember: A compact operation reclaims the space from empty blocks. A shrink operation reclaims the space from unallocated blocks. We will make the distinction more obvious when we look at the shrink operation. //
You Cannot Shrink a VHDX that Contains a Dynamic Logical Disk
If the logical disk inside the VHDX that you’re working with is Dynamic, then you can’t shrink it. Do not confuse the Dynamic logical disk with dynamically expanding VHDX, as they are dramatically different things. //
The moral of the story: don’t use Dynamic logical disks. Hyper-V isn’t the only thing that doesn’t know what to do with them. Unfortunately, some products out there require Dynamic disks. Even at Microsoft, at least one team hasn’t yet gotten the memo to stop using Dynamic disks. So, the secondary moral: if you must use Dynamic logical disks, provision small because you can always grow them.