I’ve been putting together a VMware image based on RedHat over the past couple of weeks and the last step was to try and reduce it in size from a massive 18Gb (28Gb if you included the snapshots). Given that 5Gb of this was free space, this should have been relatively easy to achieve. The original disk wasn’t created at a fixed size and, having removed any snapshots and set the disk to be independent-persistent the Shrink panel of VMware tools finally became active. Unfortunately, it only showed the boot partition.
The next step was to try and use vmware-vdiskmanager to shrink the image from the outside. The instructions suggest that you need to mount each volume individually first and prepare them before shrinking. Unfortunately the DiskMount utility only supports FAT and NTFS partitions. After a bit of searching around on the VMware forums I eventually found a thread with the solution. You need to zero out the unused disk space first before performing the shrink. They recommended the command dd if=/dev/zero of=/empty_file; rm empty_file although I never got as far as the remove because the disk was full! Still, it did the trick and the image is now down to 13Gb. It’s still going to take me 9 hours to upload the 8Gb zip to the US though!