How to Run ChkDsk and Defrag on Cluster Shared Volumes in Windows Server 2012 R2

How to Run ChkDsk and Defrag on Cluster Shared Volumes in Windows Server 2012 R2

Rate This
  • Comments 26

Cluster Shared Volumes (CSV) is a layer of abstraction on either the ReFS or NTFS file system (which is used to format the underlying private cloud storage). Just as with a non-CSV volume, at times it may be necessary to run ChkDsk and Defrag on the file system. In this blog, I am going to first address the recommended procedure to run Defrag on your CSV, in Windows Server 2012 R2. I will then discuss how ChkDsk is run on your CSVs.

Procedure to run Defrag on your CSV:

Fragmentation of files on a CSV can impact the perceived file system performance by increasing the seek time to retrieve file system metadata. It is therefore recommended to periodically run Defrag on your CSV volume. Fragmentation is primarily a concern when running dynamic VHDs and less prevalent with static VHDs. On a stand-alone server defrag runs as part of the “Maintenance Task”, so it runs automatically. However, on a CSV volume it will never run automatically, so you need to run it manually or script it to run (potentially using a Clustered Scheduled Task). It is recommended to conduct this process during non-peak production times, as performance may be impacted.  The following are the steps to defragment your CSV:

1.       Determine if defragmentation is required for your CSV by running the following on an elevated command prompt:                                                                                

Defrag.exe <CSV Mount Point> /A /U /V

/A           Perform analysis on the specified volumes

/U           Print the progress of the operation on the screen                  

/V           Print verbose output containing the fragmentation statistics



  • If your CSV is backed by thinly provisioned storage, slab consolidation analysis (not the actual slab consolidation) is run during defrag analysis. Slab consolidation analysis requires the CSV to be placed in redirected mode before execution. Please refer to step 2, for instructions on how to place your CSV into redirected mode.


2.       If defragmentation is required for your CSV, put the CSV into redirected mode.  This can be achieve in either of the following ways:

a.       Using Windows PowerShell© open a new elevated Windows PowerShell console and run the following:

Suspend-ClusterResource <Cluster Disk Name> -RedirectedAccess


b.      Using the Failover Cluster Manager right-click on the CSV and select “Turn On Redirected Access”:


  • If you attempt to run Defrag on a CSV without first putting it in redirected mode, it will fail with the following error:

CSVFS failed operation as volume is not in redirected mode. (0x8007174F)


3.       Run defrag on your CSV by running the following on an elevated command prompt:

Defrag.exe <CSV Mount Point>


4.       Once defrag has completed, revert the CSV back into direct mode by using either of the follow methods:

a.       Using Windows PowerShell© open a new elevated Windows PowerShell console and run the following:

Resume-ClusterResource <Cluster Disk Name>


b.      Using the Failover Cluster Manager right-click on the CSV and select “Turn Off Redirected Access”:


How is ChkDsk run on your CSV:

During the lifecycle of your file system corruptions may occur which require resolution through ChkDsk. As you are aware, CSVs in Windows Server 2012 R2 also supports the ReFS file system. However, the ReFS filesystem achieves self-healing through integrity checks on metadata. As a consequence, ChkDsk does not need to be run for CSV volumes with the ReFS file system. Thus, this discussion is scoped to corruptions in CSV with the NTFS file system. Also, note the redesigned ChkDsk operation introduced with Windows Server 2012, which separates the ChkDsk scan for errors (online operation) and the ChkDsk fix (offline operation). This results in higher availability for your Private Cloud storage since you only need to take your storage offline to fix corruptions in your storage (which is a significantly faster process than the scan for corruptions). In Windows Server 2012, we integrated ChkDsk /SpotFix into the cluster IsAlive health check for the Physical Disk Resource corresponding to the CSV. As a consequence we will now attempt to fix corruptions in your CSV without any perceptible downtime for your application. 

Detection of Corruptions – ChkDsk /Scan:

The following is the workflow on Windows Server 2012 R2 systems to scan for NTFS corruptions:



  • If the system is never idle it is possible that the ChkDsk scan will never be run. In this case the administrator will need to invoke this operation manually. To invoke this operation manually, on an elevated command prompt run the following:

chkdsk.exe <CSV mount point name> /scan

Resolution of CSV corruptions during Physical Disk Resource IsAlive Checks:

The following is the CSV workflow in Windows Server 2012 R2 to fix corruptions:



  • In the rare event that a single CSV corruption takes greater than 15 seconds to fix, the above workflow will not resolve the error.  In this case the administrator will need to manually fix this error.  A CSV does not need to be place in maintenance or redirected mode before invoking chkdsk. The CSV will re-establish its state automatically once the chkdsk run has completed. To invoke this operation manually, on an elevated command prompt run the following:

              chkdsk.exe <CSV mount point name> /SpotFix

Running Defrag or ChkDsk through Repair-ClusterSharedVolume cmdlet:

Running Defrag or ChkDsk on your CSV, through the Repair-ClusterSharedVolume, is deprecated. It is instead highly encouraged to directly use either Defrag.exe or ChkDsk.exe for your CSV, using the procedure indicated in the preceding sections. The use of the Repair-ClusterSharedVolume cmdlet, however is still supported by Microsoft. To use this cmdlet to run chkdsk or defrag, run the following on a new elevated Windows PowerShell console:

Repair-ClusterSharedVolume <Cluster Disk Name> -ChkDsk –Parameters <ChkDsk parameters>

Repair-ClusterSharedVolume <Cluster Disk Name> –Defrag –Parameters <Defrag parameters> 

You can determine the Cluster Disk Name corresponding to your CSV using the Get-ClusterSharedVolume cmdlet by running the following:

Get-ClusterSharedVolume | fl *



Subhasish Bhattacharya
Program Manager
Clustering and High Availability

Leave a Comment
  • Please add 4 and 2 and type the answer here:
  • Post
  • Defrag.exe C:\ClusterStorage\Volume4 /A /U /V outputs:

    Invoking slab consolidation on CSV_Data (C:\ClusterStorage\Volume4)...

           Slab Analysis:  0% complete...

    CSVFS failed operation as volume is not in redirected mode. (0x8007174F)

    The host I ran this on is the CSV owner. Should I put our CSVs into redirected mode to determine if defragmentation is required (it doesn't say so in the article) as well?

  • Analysis does not require the volume to be in redirected mode.

    The output you have pasted does not appear to be consistent with analysis. It says "Invoking slab consolidation" and not "Invoking analysis"... Are you sure you don't have a typo and the /K flag...

    /K      Perform slab consolidation on the specified volumes.

    Best regards,


  • I am running Defrag.exe C:\ClusterStorage\Volume4 /A /U /V , I copy/pasted and also typed it manually. Same error.

    I cheched the event log and the Event ID is 257, with the same error message.

    This is a thin provisioned drive (does it matter?) on NetApp storage.

  • Hi;

    Instead of using chkdsk command directly, using Repair-ClusterSharedVolume is also supported?


  • Great information - thanks.

    So we don't need to enable redirected mode to run chkdsk?

  • @Miha, Thanks for the details. I consulted the defrag folks and it appears that for thinly provisioned storage, slab consolidation analysis (not the actual consolidation) is run during defrag. This unfortunately, at the moment hits the code path which checks if CSV is in redirected mode and fails defrag if it isn't. So this implies that as of now for thinly provisioned storage for defrag analysis you will need to be in redirected mode. We will work to fix this with with a future change. I will also update the blog to reflect this.

    @... Repair-ClusterSharedVolume is deprecated but supported. We encourage you to use both defrag and chkdsk directly as they support CSVs. If you do intend to continue using Repair-ClusterSharedVolume note that you need to supply the Cluster Disk corresponding to the CSV. You can determine the information for the latter using the Get-ClusterSharedVolume cmdlet.

    @Atul - No you don't need to put your CSV in redirected or maintenance more to run chkdsk. We will take care of restoring the state of your CSV after the chkdsk run.  

  • @Subhasish: thank you for the feedback and a possible fix.

  • Hi Guys\Rob-MSFT

    i have one task at Task Scheduler created from Microsoft Corporation

    i don´t know why this was created

    "Task Scheduler launch task "\Microsoft\Windows\Defrag\ScheduledDefrag" , instance "%windir%\system32\defrag.exe"  with process ID 5316." by User System

    i have been this error everyday

    i know that is not supported operation, because the volume is not in Redirect mode

    "The volume Volume name (C:\ClusterStorage\4-VMDATA-MED-01) was not optimized because an error was encountered: This operation is not supported on this filesystem. (0x89000020)"

    what can i do?

    Remove the task? and no worry me?

  • You can modify the task to put the volume into redirected mode before running the operation and get it our of redirected mode once the defrag is complete (using the PowerShell cmdlets referenced in the blog). Of course you can disable the task but the first option would be preferable...

  • Thanks for your reply Subhasish Bhattacharya

    my question is

    there is some  parameter to add the CSV in redirect mode at Task?

    or i will need put manually?

    the manually is not the best way, in this case i will remove this task created from MS Corporation

  • If you want to go that route you should modify the task being executed to run Suspend-ClusterResource <Cluster Disk Name> -RedirectedAccess before the defrag call and Resume-ClusterResource <Cluster Disk Name> after the defrag call.

  • Hello,

    I read this article with attention but how long does it take to run chkdsk on a 2 TB drive? the last time it ran 2 weeks and I am not ready to block a drive for 2 weeks anymore... how do you handle high availability with chkdsk?

    Operating System: Windows Server 2008

    File Server cluster



  • There is no magical formula to tell you exactly how long chkdsk will take to run.  Chkdsk times are dependent on the number of files and the extent of the corruption.  Chkdsk time is not relevant to the volume size... although the number of files does commonly increase with volume size.

    The best recommendation is to upgrade to Win2012 or higher, there has been significant improvements to chkdsk and your downtime will go from weeks to seconds to run chkdsk.



  • Hi !

    I have a CSV on a cluster  (NetApp iscsi  storage , thin provisioning on the NetApp).

    When i try defrag c:\ClusterStorage\Volume2 -a -u -v i have this error :

    The slab consolidation / trim operation cannot be performed because the volume alignment is invalid. (0x89000029)

    Found nothnig about this error ...

  • Hi,

    I consulted the defrag team and here's what is going on... You might need to contact NetApp to help you fix this.

    Reference this: and tell them the violation is that OptimalUnmapGranularity or UnmapGranularityAlignment aren’t multiples of cluster size.

    Your cluster size isn’t a multiple of slab size (OptimalUnmapGranularity) and slab alignment (UnmapGranularityAlignment). If you know the slab size, you can choose a cluster size that meets these requirements.

    So the options for you might be to

    1) Contact NetApp, find out the values of the slab size and slab alignment change your cluster size to be a multiple of this.

    2) Contact NetApp to change the value of your slab size and slab alignment to be conformant.

    Hope this helps!


Page 1 of 2 (26 items) 12