Tech: How to defrag a Hyper-V R2 Cluster Shared Volume

Hans Vredevoort, a Microsoft Most Valuable Professional with the expertise Clustering wrote an article about fragmentation of a Cluster Shared Volume (CSV).

Cluster Shared Volumes is an enhancement, implemented as a file system filter driver introduced in Windows Server 2008 R2 which allows multiple virtual hard disk (VHD) images to be mounted on a single logical volume, allowing migration of virtual machines from one physical host server to another with minimal downtime, called Live Migration within Hyper-V environments.

Hans explains that especially dynamic VHDs are more susceptible to fragmentation because initially only a header and a few control blocks are written to the physical disk. As more data is written to the file that the VHD represents, this data written fragmented on the physical disk. Defragmenting a CSV requires it to be placed in maintenance mode, therefore careful planning is needed.

clip_image001

In the article Hans explains how to use Windows PowerShell to put the CSV in maintenance mode, then how to analyze if fragmentation is needed and in the end how to start the defragmentation process.