VMware offers spare disk images which only allocate space as they are used as one option. This allows for future growth of the disks on a VM without requiring all of the storage be available immediately. The problem with spares disk images is that in systems with high IO levels that generate a large amount of transient data they will grow even though the total amount of VM storage is not increasing. To combat this you must occasionally compact the disk image.
Disk images may only be compacted while the VM is shut down so that the compact tool has exclusive access to the VMDK file.
The following steps are the recommended method to compact a VM:
- Shutdown the guest operating system
- Verify the shutdown in vCenter
- Check the amount of used storage in vCenter as a reference for comparison
- ssh as root to an esx host (for example for esx1 use the command “ssh email@example.com”)
- Change into the VM folder (for example for AFS06 use the command ” cd /vmfs/volumes/AFS\ Server\ Storage/AFS06/”)
- Use the command vmkfstools -K” on each VMDK file one at a time (for example for AFS06 the commands would be “vmkfstools -K AFS06.vmdk ; vmkfstools -K AFS06_1.vmdk”)
- Once the hole punching operation is complete compare the storage usage to the original value in vCenter. It should have decreased.
- Start the guest operating system back