Search This Blog

Saturday, April 12, 2014

Defrag Cluster Shared Volume in Hyper-V Host

 

Fragmentation is the most common word that we heard. How do you know when fragmentation has occur in your virtualization infrastructure. This often happened when your virtual machine performance start to degraded and occurred when using dynamic disk in production environment.

For fixed disk deployment in production environment, you won’t likely have this issue as the disk has pre-allocated earlier during provisioning.

Last time, we used to use “Repair-ClusterSharedVolume” cmdlet to defrag CSV. But this cmdlet has deprecated. Now it is recommended to run using the command “defrag”

defrag (csv mount point name)
Example
defrag C:\ClusterStorage\Volume1

To check your disk fragmentation status, run

defrag C:\ClusterStorage\Volume1 /A /U /V

  • /A = Perform analysis
  • /U =print progress on the screen
  • /V = print verbose output

Below is the sample of two volumes that we are going to run defrag and check for fragmentation.

Volume 1

Displayed a result indicated that volume 1, do not require to defrag. So no fragmentation issue.

image

Volume 2

But volume 2 indicated that got fragmentation and we need to defrag the mount point.

image

To defrag the mount point we need to turn on redirect access first. Go to Powershell and execute command Suspend-ClusterResource.

About Suspend-ClusterResource Help:-

image

Suspend-ClusterResource (Cluster disk name) –RedirectedAccess

SNAGHTML199b0cc

Begin to solve fragmentation by run defrag command after set disk to redirect access mode
defrag C:\ClusterStorage\CSV2

image

This process will run for quite a long period depend on how much your fragmented disk . Just wait till it complete.

While performing this operation, your production virtual machine is still up and running. However we still recommend that you run during non peak period as it will slightly impact your VM performance and this is similar when you performing VM backup using DPM.

End result:- Total fragmented =0

image

Once the defrag process has completed, you need to turn off redirect access by using this command

Resume-ClusterResource (cluster disk name)
Result-ClusterResource CSV2

SNAGHTML1d9fd4f

Now your have solved your fragmentation issue, virtual machine should run in top condition.

Lastly before we sign off, do choose wisely on when to use dynamic disk and plan carefully your deployment to avoid fragmentation,