Does virtual hard disk fragmentation reported by a guest machine matter?
Solution 1:
If your VM is on local raid 5 storage, go ahead and defragment. But if it is on shared storage of any sophistication (SAN or NAS), talk to your storage guys first. There may be thin provisioning or deduplication going on at a layer VMware doesn't know about, and defragmenting can make the VM use a lot more space or even perform worse.
Also, if this is ESXi version 4, and the virtual disk is thin provisioned at the VMware layer (even on local storage), defragmenting will make the VMDK use more space as new blocks are written. This could also permanently slow things down by fragmenting the VMDK file on the VMFS layer as newly written blocks are allocated by VMFS out-of-order from the guest's perspective. A clone or convert operation would be needed to put things right again.
Solution 2:
Yes. It also matters at the host.
Like physical disk drives, virtual disks can become fragmented. Performance is weakened by fragmentation on the physical disk holding the virtual machine's working directory or virtual disk files.
First defragment inside the virtual machine. Then power off the machine, and run a defragmentation utility on the host computer.
Note that defragmenting does not reclaim unused space on a virtual disk; to reclaim unused space, shrink the disk.
It is strongly recommended that you defragment using a guest operating system mechanism before taking the first snapshot (or linked clone).
Workstation makes all its changes to the redo log, not to the original disk, when you run a defragmenting program on the guest after a snapshot. You lose the ability to defragment inside the original disk forever.
Every sector that moves is copied to the redo log, making the virtual machine redo log extremely large when the disk is heavily fragmented and you run defragmentation after a snapshot.