The final type of defragmentation is performing a defragmentation within the actual
virtual machine for its filesystem that is contained in the virtual hard disk. There is no
definite answer here. My thinking on this is that fragmentation within the virtual hard
disk is another level of fragmentation, but its effect will depend on the underlying
storage. If the underlying storage is SSD or a SAN, I would not defragment. If the
underlying storage is local HDD, a defragmentation within the VM would optimize the
data within the virtual hard disk and therefore improve storage performance, which
means that I would defragment when necessary. Obviously, if you defragment within
the virtual machine but not on the actual filesystem containing the virtual hard disk,
you are likely not achieving any optimization, because the virtual hard disk could still
be fragmented on the physical drives.
Defragmentation can be performed by using the Optimize Drives utility or the
defrag.exe utility. Detailed information can be viewed about a volume by using the /a
and /v switches, as shown in this example:
PS C:> defrag d: /A /V
Microsoft Drive Optimizer
Copyright (c) 2013 Microsoft Corp.
Invoking analysis on Data (D:)...
The operation completed successfully.
Post Defragmentation Report:
Volume Information:
Volume size = 1.81 TB
Cluster size = 4 KB
Used space = 470.11 GB
Free space = 1.35 TB
Fragmentation:
Total fragmented space = 6%
Average fragments per file = 1.05
Movable files and folders = 100184
Unmovable files and folders = 4
Files:
Fragmented files = 742
Total file fragments = 3155
Folders:
Total folders = 5552
Fragmented folders = 53
Total folder fragments = 248