Resize Vmware vmdk

1. Shut down the virtual machine you want to reduce disk size;
2. Using SSH, connect to the console of the ESXi host the VM is registered on;
3. Go the directory the VMDK file of your VM is located in:
cd /vmfs/volumes/datastore/test-VM
4. Display the contents of the virtual disk configuration file (*.vmdk) using the cat command:
cat test_vm_3.vmdk
5. The size of the vmdk disk is shown in the #Extent description section (after the RW characters).
In this case, it is 167772160 (80 GB *1024*1024*1024 / 512);
I want to reduce my VMDK disk from 80 to 40 GB. It means that I have to specify 83886080 (40 GB*1024*1024*1024 / 512) in the Extent description section. Set a new size of your virtual disk using a text editor (vi or nano);
I am using vi:
vi test_vm_3.vmdk
Using the down arrow key, go to the line containing the disk size and press i (to edit it). Specify the new size of the virtual
disk. Press ESC to exit the edit mode and then type :wq -> Enter to save the changes; shrink vmdk file size on vmware datastore
6. Then just clone or migrate (using Storage vMotion) the virtual machine to another datastore. After moving the virtual machine
files, the new size of its virtual disk will be displayed in its properties.

Tip. If you have only one ESXi host, one VMFS datastore, you won’t be able to use the Storage vMotion. Then you can clone vmdk using this command:vmkfstools -i test_vm_3.vmdk test_vm_3_newsize.vmdkvmkfstools – clone file with reducing file size
Remove the source VMDK disk, clone the reaming VMDK disk again and rename it by specifying its original name:
rm test_vm_3.vmdk
rm test_vm_3-flat.vmdk
vmkfstools -i test_vm_3_newsize.vmdk test_vm_3.vmdk