How to Shrink/Resize a VMDK file in ESXi

** Use this technique at your own risk. I do not and will not take responsibility for your corrupted vmdk’s as a result of following this process, whether correctly or incorrectly **

If you have ever taken a look at the descriptor file for a vmdk file, you will the “Extent description” section:

# Extent description
RW 52428800 VMFS “foo-flat.vmdk”

The value between ‘RW’ and ‘VMFS’ is the size of disk when divided by 512 and is in bytes:

52428800 * 512 = 26843545600 (25G)

-rw——- 1 root root 26843545600 Sep 18 19:10 foo-flat.vmdk
-rw——- 1 root root 370 Sep 18 19:11 foo.vmdk

If you want to shrink (or increase) the size of your vmdk file, alter this value in the descriptor file to reflect your new desired size*. You can do with this ‘vi’ or ‘nano’:

* For this example we will to shrink the disk to 12.5G

# Extent description
RW 26214400 VMFS “foo-flat.vmdk”

After making this change you can use ‘vmkfstools -i’ to clone this disk:

# vmkfstools -i foo.vmdk -d thin foo_1.vmdk
Destination disk format: VMFS thick
Cloning disk ‘foo.vmdk’…
Clone: 100% done.

You will discover that the cloned disk now reflects the new size of 12.5G:

-rw——- 1 root root 13421772800 Sep 18 19:13 foo_1-flat.vmdk
-rw——- 1 root root 372 Sep 18 19:13 foo_1.vmdk
-rw——- 1 root root 26843545600 Sep 18 19:10 foo-flat.vmdk
-rw——- 1 root root 370 Sep 18 19:11 foo.vmdk

the -d parameter defines the disk type: zerothick, thin etc.

source: http://professionalvmware.com/2009/09/how-to-shrink-a-vmdk-file-in-esx/