VMware Communities
mfelker
Expert
Expert

Shrinking vs Compacting

What  are the differences if any between shrinking a vdmk using Vmware tools within the guest or compacting the the disk using the VMware program disk utilities when the guest is not running?  Any advantages or advantages between the two processes?.  I have both shrunk a Windows 2008 R2 guest and then compacted it within any problem but I can't tell if the was more host disk space  released with either.  If memory serves VMware tools used to estimate the amount of disk space freed by shrinkage and now (WS 8.0`1) it doesn't.

Thanks

Marty Felker

0 Kudos
9 Replies
WoodyZ
Immortal
Immortal

Shrink and Compact are two different things.  When using VMware Tools to shrink a disk the free space on the Guest's Filesystem is first zeroed out and then it is compacted on the Host's Filesystem.

Compact frees up space on the Host's Filesystem but does not first zero out the free space on the Guest's Filesystem so that should be done first.  If you've run Shrink from VMware Tools then you do not need to also run Compact from the GUI.

One of the reasons both exist is because one may not be able to use Shrink from VMware Tools however can manually zero out the free space on the Guest's Filesystem first and then shutdown the VM and then use the Compact command via the GUI regain space on the Host's Filesystem.

0 Kudos
mfelker
Expert
Expert

Naturally this raises at least two issues:

    1) The only filesystem you mention is glusterfs.  What arbout ext4 etc etc - even btrf I suppose (haven't tried installing a VM on that - might or m ight not be interestiong.

    2)  I ran shrink from  VMware tools within the VM - and then ran compact  the  virtual HD with the VM shutdown.  Both showed a progress bar.  This is counteriintuititive if they essentially do the same on the host.   I will try compacting and then shrinking  when I'm back to the OS host I used - Ubuntu 12.-04 (Precsie) with the  3.20.x kernel (installed  by using the excellent pacth  which recompiles the modules) and see if either or both finish more or less immediately. 

    and also

  3) Begs the question of why the the "real disk" free sp[ace hs increased without any estiamte of how much.

0 Kudos
WoodyZ
Immortal
Immortal

    1) The only filesystem you mention is glusterfs.

I never mentioned the GlusterFS and the only filesystems I mentioned were generic as in whatever filesystem the Guest and or Host is using.  Not all Guest Filesystems are supported by Shrink from the VMware Tools GUI.

I will try compacting and then shrinking

That is backwards!  Either run Shrink from VMware Tools or zero out the free space on the Guests Filesystem and the use Compact if you had to manually zero out the free space on the Guests Filesystem.  You do not need to do both Shrink and Compact.

It is my understanding the Compact does not zero out the free space on the Guests Filesystem so it's almost senseless to first compact and then run shrink.  If shrink is not supported on the Guest then manually zero it out then use Compact.

3) Begs the question of why the the "real disk" free sp[ace hs increased without any estiamte of how much.

Not sure what you're trying to say.

0 Kudos
abbie11
Enthusiast
Enthusiast

Hi mfelker

In single line

To reduce the size of the vmdk-files you want to use shrink.

Compact only sorts the graintables but has no effect on size.

Yours, Abbie

Winning!
0 Kudos
WoodyZ
Immortal
Immortal

abbie11 wrote: Compact only sorts the graintables but has no effect on size.

From the User's Manual... "Compacting a virtual hard disk reclaims unused space in the virtual disk. If a disk has empty space, this process reduces the amount of space the virtual disk occupies on the host drive."

0 Kudos
mfelker
Expert
Expert

OK.  Thanks for clariyfing.  I misunderstood.  Perhaps I misremered about the estimate of disk space saved by shrinking.  Can't remember whether early relase of WS actually had a compact optiion.

Marty

0 Kudos
mfelker
Expert
Expert

This might be a dupllicate - I used the reply from email client (T bird in this case_) - it didn't show up

----------------------------------------------------------------------------------------------------------------------

Sorryi to prolong this but inquiring minds really want to know - its a matter of dictiionary words as well!

From the User's Manual

"Shrinking a virtual disk reclaims unused space in the virtual disk.     If there is empty space in the disk, this process reduces the amount     of space the virtual disk occupies on the host drive.

-----------------------------------------------------------------------------------------------------
From the User's Manual... "Compacting a virtual hard disk reclaims     unused space in the virtual disk. If a disk has empty space, this     process reduces the amount of space the virtual disk occupies on the     host drive."

Please tell me what's the difference!

Marty
:
  But!


Interesting fact I didn't know

  If you allocate all the disk space immediately, you cannot
use the shrink disk feature
.

r to be the same situation with a physical disk       (duh)Obviously
0 Kudos
WoodyZ
Immortal
Immortal

Martin Felker wrote:

This might be a dupllicate - I used the reply from email client (T bird in this case_) - it didn't show up

----------------------------------------------------------------------------------------------------------------------

Sorryi to prolong this but inquiring minds really want to know - its a matter of dictiionary words as well!

From the User's Manual

"Shrinking a virtual disk reclaims unused space in the virtual disk.     If there is empty space in the disk, this process reduces the amount     of space the virtual disk occupies on the host drive.

-----------------------------------------------------------------------------------------------------
From the User's Manual... "Compacting a virtual hard disk reclaims     unused space in the virtual disk. If a disk has empty space, this     process reduces the amount of space the virtual disk occupies on the     host drive."

Please tell me what's the difference!

I've already told you what the difference was and a use case scenario, so reread my original reply! Smiley Wink  If you can't grasp the conceptual difference let me know and I'll try rewording it. Smiley Happy

0 Kudos
mfelker
Expert
Expert

I found this from a prvious post of yours on this subject .  Shoud have done a more thorugh search - sorry - this thread answers my question

dd if=/dev/zero of=wipefile bs=1024x1024; rm wipefile
0 Kudos