Defragment an Existing Disk
VixDiskLib_Defragment() defragments an existing virtual disk. Defragmentation is effective with SPARSE type files, but might not do anything with FLAT type. In either case, the function returns VIX_OK. This function supports hosted disk, but not managed disk.
vixError = VixDiskLib_Defragment(disk.Handle(), DefragProgressFunc, NULL);
Defragment consolidates data in the 2GB extents, moving data to lower-numbered extents, and is independent of defragmentation tools in the guest OS, such as Disk > Properties > Tools > Defragmentation in Windows, or the defrag command for the Linux Ext2 file system.
VMware recommends defragmentation from the inside out: first within the virtual machine, then using this function or a VMware defragmentation tool, and finally within the host operating system.