Here is my case, I usually put all the guest OS in an external SSD to speed up the development and testing. With limited disk space of SSD, I have to clean up the space regularly to prevent SSD from full. So I share the procedure with you and hope it useful.
Here are three steps to shrink the disk space.
1. Delete all the snapshots.
Snapshots could be the best tool to backup the status of the entire virtual machines, but before using vmware-tool to shrink the virtual files, you must delete all the snapshots to make the shrinking possible. Of course, you can clone or backup the virtual machine before removing all snapshots.
2. Clean Up guest OS INTERNALLY.
Needless to say, you have to do this by yourself. Please enter the guest OS and remove unused files, especially the largest files. After that, we can reclaim the space by internal VMware Tool.
Windows Guest OS:
Get into elevated (run as administrator) mode of cmd.
List all the virtual disks
C:\Windows\system32>VMwareToolboxCmd disk list
C:
Shrink disks
You can either shrink c: only
C:\Windows\system32>VMwareToolboxCmd disk shrink c:
Or shrink all virtual disks without indicating specific disk.
C:\Windows\system32>VMwareToolboxCmd disk shrinkonly
Please disregard any warnings about disk space for the duration of shrink process.
Progress: 100 [===========>]
Disk shrinking complete.
If you got this error message below:
Shrink disk is disabled for this virtual machine.
Shrinking is disabled for linked clones, parents of linked clones,
pre-allocated disks, snapshots, or due to other factors.
See the User's manual for more information.
Please remove all snapshots before shrinking vmdk disk by VMwareToolboxCmd.
Linux Guest OS
It's quite similar with the windows.
[root@test ~]# cd /usr/sbin
[root@test sbin]# vmware-toolbox-cmd disk list
/
/boot
[root@test sbin]# vmware-toolbox-cmd disk shrinkonly
For more information about VMWare Tool commands, please refer to the official document: vSphere Documentation Center.
3. Reclaim the space by VMware manage EXTERNALLY.
Click on the menu VM > Manage > Clean Up Disk.
Click "Clean up now" button.
Now, we are done.