Recently I was asked to describe the correct procedure for defragmenting Cluster Shared Volumes on a Hyper-V R2 cluster. This is not really a very complicated task but if you have never had the opportunity to give it a try, this blog post will offer you the exact steps using PowerShell.
Case
Let’s start with a case description: the System Center Operations Manager Windows Management Pack is reporting “Logical Disk Fragmentation Level is high” for your Hyper-V R2 servers.
A Cluster Shared Volume (CSV) contains the configuration, virtual hard disk and snapshot files of multiple Hyper-V guests. Notably fragmentation of the large VHD files deserve your attention.
Fragmentation of these files can become a problem because the disk head needs to use an increasing number of seeks, lowering the throughput and thus the perceived performance of the guest as a whole.
On the other hand, NTFS has become more and more efficient in recent OS versions and fragmentation need not always have a severe impact on performance.
Analysis
CSV is a distributed orchestration layer on top of NTFS (implemented as a file system filter driver) and for fragmentation it takes advantage of all the NTFS techniques. The advantage of this design is that all disk management tools which have been written for NTFS continue to work, including a variety of defrag tools.
[image not preserved in the archive]