Windows 10: How to release unused space in VHDX disks?

Discus and support How to release unused space in VHDX disks? in Windows 10 Virtualization to solve the problem; Before I learned that VHDX expanding disks do not release space, many of these have swelled way beyond what is used of needed because I did a defrag.... Discussion in 'Windows 10 Virtualization' started by mfaklis, Aug 26, 2015.

  1. mfaklis Win User

    How to release unused space in VHDX disks?


    Before I learned that VHDX expanding disks do not release space, many of these have swelled way beyond what is used of needed because I did a defrag. Defrag will use temporary space to store files parts being defragged. I expected defrag to make fragmented files use contiguous space and to move all of the files to the beginning of the VHDX disk. To emphasize my ignorance I expected defrag to truncate to unused space at the end of the disk.

    What really happens is that defrag extends expanding VHDX disks as a temporary area to make files contiguous and as temporary space to squeeze out embedded free space. The new extensions are never released to the host physical disk. Defragging a VHDX extended space disk will result in allocating significant more unused physical space. As an example a 100gb fragmented expanding VHDX disk once defragged may end up actually expanding to over 300gb of real space.

    A old version of Virtual PC came with a compactor.ISO utility that when run against a VHD, would squeeze all unused space to the end of the VHD disk. You could then truncate the trailing free space leaving your VHD file physically smaller. Microsoft provides no tool (I know of) that will accomplish the physical shrinking of VHDX disks. The problem may apply to VHD disks as well, but I am now using VHDX virtual disks.

    Does anyone have the necessary expertise of PowerShell to script making VHDX disk files contiguous, squeezing all the unused space to the end of the VHDX disk, and then truncating the trailing free space to physically shrink virtual disks.

    :)
     
    mfaklis, Aug 26, 2015
    #1

  2. windows 10 upgrade from vhdx

    Hello,

    Hopping to post a question for which the answer not exist yet.

    As some people I am using windows with native vhdx boot. As I discovered, the os upgrade is not allowed from vhdx.

    How about using the final release of Windows 10?

    My first idea was to make an ISO from the install.esd file located under $Windows.~BT and then perform a classic setup to a new vhdx. But at the end windows request a new key.

    Is someone able to help me on that topic?

    Thank for the help

    Alfonso
     
    AlfonsoSciascia, Aug 26, 2015
    #2
  3. lacrumb Win User
    windows 10 update fail

    One of the partitions is (CHow to release unused space in VHDX disks? :) This is the System drive. It may be labelled as Windows 10. How big is it and how much unused space is there?
     
    lacrumb, Aug 26, 2015
    #3
  4. lx07 Win User

    How to release unused space in VHDX disks?

    Just take the edit disk option from the Hyper-V management console, select your disk and then the option compact.


    How to release unused space in VHDX disks? [​IMG]


    If you want to use powershell instead of the UI you could do this:
    Code: Mount-VHD <enter path to vhdx file> -ReadOnly Optimize-VHD <enter path to vhdx file> -Mode full Dismount-VHD <enter path to vhdx file>[/quote] If your vhdx is not NTFS (Linux for example) you need to zero out free space first. With NTFS (Windows) you need not.
     
  5. Rudy Mas Win User
    Before you do the above, use sdelete (SDelete) to zero out all the unused bits on the virtual disk. This will give you a smaller file than when you just do a compact straight away.

    sdelete has to be run inside the guest OS, of course. *Wink
     
    Rudy Mas, Aug 29, 2015
    #5
  6. lx07 Win User
  7. Rudy Mas Win User
    Thanks for the information!

    I now use VMware player, and I still need to do this there, even when using NTFS.

    A while back, when I did use Hyper-V, I noticed that running sdelete inside the guest OS still did a better job than when I only ran compact on it. Maybe it's gotten better? At least, thanks for mentioning this! It's again one thing less to do. *Wink
     
    Rudy Mas, Aug 29, 2015
    #7
  8. lx07 Win User

    How to release unused space in VHDX disks?

    I have 2 VM's running Windows 10 Pro (both 10240 and both compacted and minimised as best I could)

    Hyper-V VM running on Windows 10 host without Office is 5.45GB according to Windows file explorer and the vhdx is 8.16GB

    VMware Fusion (latest version) VM running on OSX host with Office 2016 is 8.35GB according to Windows file explorer and the vmdk is 11.1 GB

    To be honest I don't really trust any of these numbers as whenever I look in a different place I get a different answer...How much disk am I using? - Windows 10 Forums

    I didn't run sdelete on VMware (actually I forgot, thanks for reminding me). I will do and see if it helps any.
     
  9. Kyhi Win User
    mount and defrag (optimize) vhd
    then type
    diskpart
    select vdisk file="X:\NAME.vhd"
    Compact vdisk
    exit
     
  10. mfaklis Win User
    The solution from Rudy Mas worked as I expected.

    I have not test kuhi's solution yet.
     
    mfaklis, Aug 30, 2015
    #10
  11. Everything except for the outdated Sdelete step. That is everywhere on the net but is not necessary now if it was before. It would take more than 24 hours on my setup to complete sdelete. Using the hypervisor administrator in 2016 server, I skipped the sdelete step, or zeroing free space. I just ran disk compact after deleting 150gb without zeroing anything and the size on disk was compacted by Hypervisor administrator to the 38GB's stored on disk and the virtual disk size unchanged.
     
    sticker592, Sep 27, 2017
    #11
  12. lx07 Win User
    Still need to zero free space if it isn't NTFS though.
     
Thema:

How to release unused space in VHDX disks?

Loading...
  1. How to release unused space in VHDX disks? - Similar Threads - release unused space

  2. Disk Drive is unusable

    in Windows 10 Network and Sharing
    Disk Drive is unusable: Ive had to install a drive from an old laptop to get the data off it. I did this by taking the hard drive out of the laptop and putting it into my computer. After I booted my system once I had finished with the other drive, the files on my D drive were unusable. D drive is my...
  3. Disk unusable

    in Windows 10 Network and Sharing
    Disk unusable: Hello, I've been using my 1TB Seagate barracuda HDD for over two years now. Today when I wanted to create a new partition on Disk Management, the disk showed no volume, but I was able to access my files just fine. I made backups before starting to mess with things, checked...
  4. Unused space on c:drive changing

    in Windows 10 Network and Sharing
    Unused space on c:drive changing: Hi I purchased a new pc with only a 128gig ssd hard drive. After installing certain things it showed I only had 13 gig left which had me worried. I got rid of temp files etc and it stayed at 13gig. Yesterday I looked and I see I am now at 25gig Just a question of...
  5. How can we mount vhdx disks in the Windows Sandbox?

    in Windows 10 Drivers and Hardware
    How can we mount vhdx disks in the Windows Sandbox?: I am unable to mount a vhdx inside my sandbox. Doubleclicking the .vhdx file gives me an error popup "Problem beim Bereitstsellen der Datei". The powershell Mount-VHD cmdlet gives me a "The term 'Mount-VHD' is not recognized as the name of a cmdlet, function, script...
  6. Clear up unused space?

    in Windows 10 Ask Insider
    Clear up unused space?: I've got a laptop that's down to just a few GBs of storage left on a good day, anywhere from 6gb to less than half a gig. I have an external drive that I put everything I can on but it hasn't opened up much space. Anyone know of something I could use or do to remove junk and...
  7. how to Boot into a vhdx file

    in Windows 10 Virtualization
    how to Boot into a vhdx file: Hi I have created a VHDX file attached it and cloned a copy of widows onto it ( which includes the boot sector)? What I want to do is add this to my boot menu and see if it works. I've read lots of tutorials but they mostly concentrate on making the VHDX file. I am a bit...
  8. Windows 10 licence for VHDX differencing disks

    in Windows 10 Updates and Activation
    Windows 10 licence for VHDX differencing disks: Hi I have question about licencing. I have Windows 10 Pro installed on my main disk. As far I know, if I want to install another Windows 10 Pro, on different disk/partition, on the same PC I need to buy second licence....
  9. How Is There Little Disk Space

    in Windows 10 Network and Sharing
    How Is There Little Disk Space: Dear MSCS I am in a dilemma concerning the amount of PC Disk Space that has been used up on this laptop. This is the data I have compiled using the properties utility available. This is my old laptop which was a WinXP, by changing the hard-drive, it was upgraded to a...
  10. Format unused space on primary disk

    in Windows 10 Drivers and Hardware
    Format unused space on primary disk: Some time ago I had to format my hard drive (a nominal 1 TB spinner) and re-install Windows 10. At the time I was considering setting up a dual-boot configuration, so I left about 290 GB unallocated for later use by the alternative OS. Since then I have changed my mind, and...

Users found this page by searching for:

  1. how to zeroize vhdx unused space