dynamically expanding disk increases
- Hi.
I have a virtual machine (Windows 2003 SP2, P2V) running on Windows 2008 SP1 Hyper-V with a dynamically expanding system disk (max. size 130 GB). The disk is expanding over and over, although there is plenty of free space available inside the VM. I tried a defrag inside the VM which increased the vhd too, so I stopped the defrag.
Is this normal? Do I have to run the defrag completely an compact the VHD after that to get rid of the used space?
I experimented with another VHD, copied 2 GB onto the VM, deleted and copied again -> free space was used and VHD was not expanded.
Thanks in advance.
Andreas- Moved byMathias SchifferMSFTTuesday, June 30, 2009 10:15 AMEnglish Language Post (From:Virtualisierung)
Answers
- Inside the virtual machine, did you convert the disk type to dynamic.?I'm not asking about the vhd, I'm asking about what the virtual machine's operating system thinks it is using.
If you have time, go ahead and try compacting the disk and let us know what happens.
Open Hyper-v management console -> Action -> Edit Disk -> Locate Disk -> Select the source VHD by "Browse…" -> Compact -> Finish.- Marked As Answer byVincent HuMSFT, ModeratorMonday, July 06, 2009 2:43 AM
- As John is pointing out. What you are experienceing is the behavior of the operating system that runs within the VM itself.
With a dynamic disk a few things happen: 1) it grows but does not shrink 2) when you look at the file on the host file system and compare that to the operating system within the VM they will rarely be equal.
The growth of a dynamic disk happens in 2 MB chunks. And high degrees of fragmentation within the OS of the virtual machine can cause a virtual disk to grow un-necessarily.
Defragmentation can happen in two places - within the VM and on the Host file system.
First, defragment within the OS of the VM. Until you have it as clean as you would want hardware to be.
Then you could defragment at the host level.
Then you might get a gain out of the compact.
As a general rule of thumb, the VHD will never be shrunk - however, it can be made to be more efficient.
BTW - does this VM have any snapshots?
Brian Ehlert (hopefully you have found this useful)- Marked As Answer byVincent HuMSFT, ModeratorMonday, July 06, 2009 2:43 AM
All Replies
- Inside the virtual machine, did you convert the disk type to dynamic.?I'm not asking about the vhd, I'm asking about what the virtual machine's operating system thinks it is using.
If you have time, go ahead and try compacting the disk and let us know what happens.
Open Hyper-v management console -> Action -> Edit Disk -> Locate Disk -> Select the source VHD by "Browse…" -> Compact -> Finish.- Marked As Answer byVincent HuMSFT, ModeratorMonday, July 06, 2009 2:43 AM
- As John is pointing out. What you are experienceing is the behavior of the operating system that runs within the VM itself.
With a dynamic disk a few things happen: 1) it grows but does not shrink 2) when you look at the file on the host file system and compare that to the operating system within the VM they will rarely be equal.
The growth of a dynamic disk happens in 2 MB chunks. And high degrees of fragmentation within the OS of the virtual machine can cause a virtual disk to grow un-necessarily.
Defragmentation can happen in two places - within the VM and on the Host file system.
First, defragment within the OS of the VM. Until you have it as clean as you would want hardware to be.
Then you could defragment at the host level.
Then you might get a gain out of the compact.
As a general rule of thumb, the VHD will never be shrunk - however, it can be made to be more efficient.
BTW - does this VM have any snapshots?
Brian Ehlert (hopefully you have found this useful)- Marked As Answer byVincent HuMSFT, ModeratorMonday, July 06, 2009 2:43 AM
Hi,
I want to see if the information they provided was helpful. Your feedback is very useful for the further research. Please feel free to let me know if you have addition questions.
Best regards,
Vincent Hu
- Hi.
Thanks for the help and sorry for the late feedback.
Inside the VM no dynamic disk.
I gave the machine enough space on the physical disk and ran the defrag inside the VM. The dynamic disk expanded some gigabytes. After the successfull defrag, the dynamic disk does not expand anymore when copying data to the free space inside the virtual machine. Perhaps I will do a compact of the VHD later.
Thanks again.
Andreas - I also encoutered the similar issue, and my method is just to comact the VHD.
Hi,
Have you tried to compact the VHD? Have you resloved the issue? Your feedback is very useful for the further research. Please feel free to let me know if you have addition questions.
Best regards,
Vincent Hu

