Failover Clustering and Network Load Balancing Team Blog
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.
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
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”:
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>
Defrag.exe <CSV Mount Point>
4. Once defrag has completed, revert the CSV back into direct mode by using either of the follow methods:
Resume-ClusterResource <Cluster Disk Name>
b. Using the Failover Cluster Manager right-click on the CSV and select “Turn Off Redirected Access”:
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.
The following is the workflow on Windows Server 2012 R2 systems to scan for NTFS corruptions:
chkdsk.exe <CSV mount point name> /scan
chkdsk.exe <CSV mount point name> /scan
The following is the CSV workflow in Windows Server 2012 R2 to fix corruptions:
chkdsk.exe <CSV mount point name> /SpotFix
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 BhattacharyaProgram ManagerClustering and High AvailabilityMicrosoft
Defrag.exe C:\ClusterStorage\Volume4 /A /U /V outputs:
Invoking slab consolidation on CSV_Data (C:\ClusterStorage\Volume4)...
Slab Analysis: 0% complete...
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.
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.
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.
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.
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.