How to Shrink a Thin VMDK on ESXi 5.0

I always like to keep my template small.  This means the files inside the VM, but the size of the VMDK as well.  The reason for this is that I often need to download the VM to USB storage of whatever and transfer it to remote sites.

So I wanted to shrink my VMDK size as much as possible.  After cleaning up the VM itself and running sdelete, it’s time to shrink the VMDK.

First let’s review the actual usage of it:
The virtual disk size can be seen with ls –lh *.vmdk.  In my example, I have a 40 GB virtual size.

To see the ‘real’ size of the vmdk, run du –h *.vmdk.  This gives us a 36 GB size (while the VM itself actually uses about 10 GB).

Issue the command vmkfstools –punchzero VM.vmdk.  This will take a while so be patient (and oh yes, you VM must be powered off).

On a 40 GB VMDK it took me about 10 minutes, but this will depend mostly on your SAN speed.
After it’s done, let’s re-issue du –h *.vmdk.


Nice, now it’s actually 10.8 GB.  Makes it a lot easy to transfer anywhere.

Comments

Popular Posts