I started with a Windows Server 2003 R2 VHD which had 2 partitions, C: (40GB) and D: (960GB), which originally came from a physical 1 TB hard drive. The ACTUAL size of the VHD file was 50GB, as a dynamically expanding disk.
I'm running this virtual machine in Windows Server 2008 Hyper-V (R1, not R2).
I had made several snapshots in Hyper-V of the VHD and decided to merge them, so I did a Delete Subtree (which does a merge to the current state). This oddly created a 107GB VHD file -- it went from 50GB to 107GB. Strange...
So I moved all the files off the D: partition of the VHD to an external physical hard drive and deleted the D: partition. The C: partition was still 40GB, and the space after it is Unallocated.
The VHD file is still showing as 107GB, yet the C: partition in the VHD is 40GB and there is no other partition before or after it. I've tried defragmenting, compacting, but I cannot get the VHD file to shrink from 107GB to 40GB. How can I do it?