none
dynamicly expanding vhdx strange behaviour

    Question

  • Hi,

    look please at a screenshot...

    D: partition is on dedicated vhdx and set as dynamically expanding.

    The strange thing I cannot explain:

    1.The VHDX size is 100 GB

    2. in Windows I have 39GB of free space

    3. When in Hyper-V manager the Current file size is about whole 100GB

    For example for partition C: on dedicated VHDX it correctly matches Windows free space and current file size.

    The final result is that total VM folder size is influenced by 100GB current file size. So I am loosing 40GB.

    Why it could happen? Should I convert the drive to gain back 40GB. It is not a static drive...

    Thanks.


    --- When you hit a wrong note its the next note that makes it good or bad. --- Miles Davis

    Saturday, January 28, 2017 3:04 AM

Answers

All replies

  • Hi.

    You should not convert the disk you should shrink it!

    As the name insist it is a dynamically expanding disk, not a dynamically shrinking ;-)

    It has grown sometimes in the past to the full size and files inside of it was then deleted, at this point the vhdx will not shrink to the size of only the allocated space.

    Have a look into these blogs...

    https://charbelnemnom.com/2014/10/how-to-reclaim-unused-space-in-dynamic-vhdx-in-windows-server-2012-r2-hyper-v-hyperv-ws2012r2-ws2012/

    http://www.altaro.com/hyper-v/shrink-hyper-v-virtual-disk-vhd-vhdx/


    Regards
    Olaf

    • Marked as answer by pob579 Tuesday, January 31, 2017 7:36 PM
    Saturday, January 28, 2017 9:42 AM
  • make sense :)

    Probably it was filled up once. Will double check...

    Thanks.


    --- When you hit a wrong note its the next note that makes it good or bad. --- Miles Davis

    Tuesday, January 31, 2017 7:36 PM
  • I did run pshell command.

    Was really happy :) to see the output...

    But after checking vhdx info in HV manager and real vhdx size on host it shows that nothing changed.

    Of course I did restart the VM. Then rerun the command. And restarted the HOST.

    No positive result.

    Any idea?

    Thanks.


    --- When you hit a wrong note its the next note that makes it good or bad. --- Miles Davis

    Wednesday, February 01, 2017 4:18 PM
  • So you did the optime-volume powershell command inside the vm. This is for shrinking the volume, or lets say the preparation phase inside the vm.

    If you had TRIM/UNMAP compatible hardware the the rest would have happened automatically, but it looks like that you haven't.

    I would assumue that you have to trigger the shrink of the vhdx manually as described in the second blog I mentioned above. Either via edit disk from within the hyperv manager or via powershell resize-vhd.

    Have a look into the altaro blog for further details....

    If you have 2012R2 and vhdx you don't have to boot anything!


    Regards
    Olaf

    Saturday, February 04, 2017 8:48 PM
  • finally I just Compacted vhdx (dynamically expanding) and got:

    Current File Size in Virtual Hard Disk Properties = to used space on Windows partition.

    Yes it was a bunch of files removed on the partition... So nothing to shrink :)

    *****************

    Compacting a dynamically expanding virtual hard disk reduces the size of the virtual hard disk (.vhd) file as much as possible. Typically you would compact a virtual hard disk in situations such as the following:

    • After you install the guest operating system (which uses many temporary files)
    • After you delete large amounts of data
    • When you are preparing the virtual hard disk for archiving, for deployment to another computer or CD-ROM, or for distribution
    ***************************************

    Thanks.


    --- When you hit a wrong note its the next note that makes it good or bad. --- Miles Davis


    • Edited by pob579 Tuesday, April 11, 2017 5:56 PM
    Tuesday, April 11, 2017 5:55 PM