VMware Communities
MacsRule
Hot Shot
Hot Shot

Reclaim disk space vs Disk Shrink

Fusion offers the option to reclaim disk space at the bottom of the VM Library window and in Settings>General>Clean Up Virtual Machine, and the process is both quick and often productive on Windows VM's.

Disk Shrink is run as a VMwareToolboxCmd within a running Windows (or other) VM, can take quite a while and doesn't seem to do much on a Windows VM (it's great on Linux or Mac OS X).

For Windows, what is each VM size reduction process actually doing and is there any circumstance when Disk Shrink is beneficial? And does either do any of what Windows' Disk Cleanup does?

0 Kudos
8 Replies
wila
Immortal
Immortal

Hi MacsRule,

I'm not aware of differences between the "Reclaim disk space" option at guest Fusion menu level and "Disk Shrink" in vmware-cmd-toolbox.

From Fusion help (Type "shrink" in the Help menu option, choose "Clean Up a Virtual Hard Disk" from the list of options)

Clean Up a Virtual Hard Disk

You can shrink and defragment certain virtual hard disks to free up space on your Mac.

When you delete files from your virtual machine, Fusion does not return the space to your Mac. Shrinking the virtual machine by cleaning up the hard disk returns that freed space to your Mac.

Prerequisites

Shut down or power off the virtual machine. You cannot change the setting while the virtual machine is powered on or suspended.

Procedure

1 From the VMware Fusion menu bar, select Window > Virtual Machine Library.

2 Select a virtual machine and click Settings.

3 Under System Settings, select General.

4 Click Clean Up Virtual Machine.

VMware Fusion displays a progress dialog as it cleans up the virtual disk. This process can take up to two minutes.

Disk Cleanup in Windows is a completely different animal as it is Windows operating system aware and cleans up specific parts of the OS.

It does things like, empty your recycle bin, empty your temp folders, empty internet explorer temporary files, remove old windows dump files. On Windows 7 or higher it can even remove old obsolete updates. VMware's "reclaim disk space" or "shrink" doesn't do any of that for obvious reasons.

Eg. For optimal results you would first run Disk Cleanup from within windows, then shut down your VM and "Reclaim disk space" on your VM.

Hope this helps,

--

Wil

| Author of Vimalin. The virtual machine Backup app for VMware Fusion, VMware Workstation and Player |
| More info at vimalin.com | Twitter @wilva
0 Kudos
MacsRule
Hot Shot
Hot Shot

wila wrote:

Hi MacsRule,

I'm not aware of differences between the "Reclaim disk space" option at guest Fusion menu level and "Disk Shrink" in vmware-cmd-toolbox...

...Eg. For optimal results you would first run Disk Cleanup from within windows, then shut down your VM and "Reclaim disk space" on your VM...

The sequence you describe is the one that I use, and Disk Cleanup has given remarkable results after a Windows OS upgrade or lots of updates.

The reason I raised the question of what might be going on under the hood with Disk Shrink vs Reclaim disk space is that Disk Shrink takes a lot longer to run than Reclaim does yet doesn't seem to have any appreciable effect on a Windows VM, yet it does on Mac and Linux VM's while Reclaim isn't available at all. Since Reclaim appears ready to do its thing as soon as the VM is shut down and already knows how much space can be reclaimed, is whatever is preparing the space reclamation running while the VM is running (perhaps an automatic Disk Shrink) so that a command line Disk Shrink is actually redundant in Windows?

0 Kudos
wila
Immortal
Immortal

Hello,

MacsRule wrote:

The reason I raised the question of what might be going on under the hood with Disk Shrink vs Reclaim disk space is that Disk Shrink takes a lot longer to run than Reclaim does yet doesn't seem to have any appreciable effect on a Windows VM, yet it does on Mac and Linux VM's while Reclaim isn't available at all. Since Reclaim appears ready to do its thing as soon as the VM is shut down and already knows how much space can be reclaimed, is whatever is preparing the space reclamation running while the VM is running (perhaps an automatic Disk Shrink) so that a command line Disk Shrink is actually redundant in Windows?

I wouldn't call it redundant, but it uses a different approach. The best link I could find is this old one Shrinking Virtual Disks which I think still is how it works today. This article also helps a bit: vSphere Documentation Center - Shrink a Virtual Disk

Basically "Reclaim disk space" is file system aware, it understands NTFS and thus it knows what blocks are empty and can be discarded, it doesn't need assistance from the guest OS for that.

The "Disk Shrink" process uses the guest operating system to clear out empty space by overwriting it with zero's and then discard the free space.

So while it seems that shrink is redundant, as soon as you are using another filesystem as NTFS, it is your only way to shrink disks.

--

Wil

| Author of Vimalin. The virtual machine Backup app for VMware Fusion, VMware Workstation and Player |
| More info at vimalin.com | Twitter @wilva
MacsRule
Hot Shot
Hot Shot

Thank you for the very helpful information.

The fact that Fusion understands NTFS suggests that it's monitoring the use of its virtual storage space on the fly and so can know, upon shutdown, how much (if any) space is now free and can be reclaimed. It would also explain why Disk Shrink doesn't appear to accomplish anything extra since both functions appear to do essentially the same thing. The fact that earlier Windows VM's (e.g., Win 95 and ME) which use FAT32 instead explains why Reclaim isn't available.

Another thing that's interesting is this in Workstation 5 link:

"Shrinking requires free disk space on the host equal to the size of the virtual disk you are shrinking."

That would suggest that the Disk Shrink process writes just the in-use portions of the virtual HD to a new portion of the host HD and then erases the original VM copy. I've noticed that during Disk Shrink the free space on the host slowly goes down before it jumps back up, but not always by very much.

0 Kudos
a_p_
Leadership
Leadership

That would suggest that the Disk Shrink process writes just the in-use portions of the virtual HD to a new portion of the host HD and then erases the original VM copy. I've noticed that during Disk Shrink the free space on the host slowly goes down before it jumps back up, but not always by very much.

The final step in shrinking a virtual disk is to compact the .vmdk file(s). The amount of temporary host disk space that's required for this depends on the virtual disk format. For a monolithic virtual disk (i.e. one large ,vmdk file) all non-zero blocks are copied o a new file before the original .vmdk file gets deleted, i.e. this could require a huge amount of disk space. However, the default virtual disk format for VMware Fusion is the "twoGbMaxExtentSparse" format, where the VM consists of a number of ...-s00x.vmdk files which can grow up to 2GB. With this disk format each .vmdk is compacted separately, one after the other, so the maximum temporary host disk space is ~2GB.

André

MacsRule
Hot Shot
Hot Shot

a.p. wrote:

...The final step in shrinking a virtual disk is to compact the .vmdk file(s)...

... With this disk format each .vmdk is compacted separately, one after the other, so the maximum temporary host disk space is ~2GB.

Thank you. It's good to be learning what goes on behind the curtain. Smiley Wink

Since Fusion running a Windows guest is NTFS-aware, is the graphic we're seeing during the Reclaim disk space process showing that compacting, one 2GB segment at a time? And does that mean guest free space defragmentation isn't really necessary because that's actually what the compacting process does?

0 Kudos
a_p_
Leadership
Leadership

As mentioned before by Wil, defragmentation is not done by Fusion and/or the shrinking process. What the cleanup process does is just to to zero out unused disk space from within the guest OS itself, and then compact the files on the host.

André

0 Kudos
MacsRule
Hot Shot
Hot Shot

a.p. wrote:

As mentioned before by Wil, defragmentation is not done by Fusion and/or the shrinking process. What the cleanup process does is just to to zero out unused disk space from within the guest OS itself, and then compact the files on the host.

André

I think we may actually be saying the same thing. In looking at the fragmentation analysis run by the Windows 7 guest before defragmentation is initiated, one of the items was the percent fragmentation of just free space. If the free space is left out when the files are compacted during Disk Shrink, then, in effect, the guest's free space is being "defragmented" by being left behind. The guest's files themselves are still fragmented (something we no longer worry about when using an SSD), but the free space is basically eliminated, with Fusion adding space as necessary on the fly when more is needed.

0 Kudos