Q. How do I manually and cleanly perform a disk defragmentation or use Chkdsk on a Cluster Shared Volume (CSV)?

A. CSVs introduce challenges because they access multiple nodes in a cluster directly through the use of direct access (direct IO), which allows all the nodes to read and write from a LUN simultaneously.

Because CSVs lock at a file level and not a LUN level, if you try to defragment a disk or use Chkdsk on a CSV with nodes performing direct access, files will be "pinned," or locked, by other nodes and the operations will fail. You therefore have two choices, and which you should pick depends on the maintenance action you want to perform. You can run on redirected access for the CSV, which means only the coordinator node accesses the LUN and all other nodes pass their IO using SMB2 to the coordinator. Or you can or turn on maintenance, which means the CSV is actually removed from the ClusterStorage namespace and any virtual machines (VMs) that use the CSV are stopped by their default actions.

Below is the minimum level you need the CSV in to perform various actions. Redirected access is preferable to maintenance, which takes resources offline.

  • ChkDsk - Reporting only requires redirected access

  • ChkDsk /f - Fixing requires maintenance

  • Defrag /a - Analysis only requires redirected access

  • Defrag /d - Defragmentation only requires redirected access

The interesting point is that ChkDsk and Defrag want to operate on a disk and not a reparse point under %systemdrive%\ClusterStorage, so you need to know the GUID of the disk to pass to the commands. In fact, using a GUID is your only option if you're in maintenance mode, because the LUN is no longer visible in the ClusterStorage namespace. If you try to pass a path such as C:\ClusterStorage\VolumeX, the command will run the action on the C drive, which isn't what you want. We therefore need to perform a number of actions:

  1. Move the CSV to the node you're running the commands on.

  2. Get the GUID of the CSV.

  3. Place the CSV in redirected access or maintenance mode, depending on the action you're taking.

  4. Perform the action using the GUID of the disk.

  5. Bring the disk out of maintenance mode and enable direct access.

While you can do items 1, 3, and 5 from the Failover Cluster Management interface, here I'll show how do perform all the steps from PowerShell. First, load the Failover Cluster library into PowerShell, running with an elevated PowerShell instance. The Get-Module isn't required but it shows the module has been loaded.

PS C:\Users\savadmin> Import-Module failoverclusters
PS C:\Users\savadmin> Get-Module
Name : failoverclusters
Path : C:\Windows\System32\WindowsPowerShell\v1.0\Modules

To move the CSV to the local node, use the Move-ClusterSharedVolume cmdlet, as shown here.

PS C:\Users\savadmin> Move-ClusterSharedVolume "Cluster Disk 3"
-Node $env:computername

Name State Node
---- ----- ----
Cluster Disk 3 Online savdalvs01

To obtain the GUID of the disk, use the Get-ClusterSharedVolume cmdlet and pipe the output to fc *, command to get all parameters. You want the Name attribute under the ClusterDiskpartitionInfo class, as shown here. Piping to Fc* performs a custom format using the Format-Custom cmdlet.

PS C:\Users\savadmin> Get-ClusterSharedVolume "Cluster Disk 3" | fc *

class ClusterSharedVolume
Name = Cluster Disk 3
State = Online
OwnerNode =
class ClusterNode
Name = savdalvs01
State = Up
SharedVolumeInfo =
class ClusterSharedVolumeInfo
FaultState = NoFaults
FriendlyVolumeName = C:\ClusterStorage\Volume2
Partition =
class ClusterDiskPartitionInfo
Name = \\?\Volume\{3803bb0f-05b0-11de-bb45-001fbc00f79d\}
DriveLetter =

Now put the CSV in redirect or maintenance mode using the Suspend-ClusterResource cmdlet. The commands are shown below, first for redirected mode then for maintenance mode. Obviously, you use only one of the commands.

PS C:\Users\savadmin> Get-ClusterSharedVolume "Cluster Disk 3" | 
Suspend-ClusterResource -RedirectedIO

Are you sure that you want to enable redirected IO
for Cluster Shared Volume 'Cluster Disk 3'?
\[Y\] Yes \[N\] No \[S\] Suspend \[?\] Help (default is "Y"): Y

Name State Node
---- ----- ----
Cluster Disk 3 Online savdalvs01
PS C:\Users\savadmin> Get-ClusterSharedVolume "Cluster Disk 3" | Suspend-ClusterResource

Are you sure you want to enable maintenance for Cluster Shared
Volume 'Cluster Disk 3'? Putting this shared volume into
maintenance will take all services or applications using
this volume offline and interrupt client access.
\[Y\] Yes \[N\] No \[S\] Suspend \[?\] Help (default is "Y"): Y

Name State Node
---- ----- ----
Cluster Disk 3 Online savdalvs01

Now you can run commands such as chkdsk or defrag using the GUID of the disk from a cmd.exe prompt.

C:\Users\savadmin>chkdsk /f \\?\Volume\{3803bb0f-05b0-11de-bb45-001fbc00f79d\}
The type of the file system is NTFS.
Volume label is Test.

Once you're done, put the CSV back in direct access mode using the Resume-ClusterResource cmdlet.

PS C:\Users\savadmin> Get-ClusterSharedVolume "Cluster Disk 3" |

Name State Node
---- ----- ----
Cluster Disk 3 Online savdalvs01

Finally, if you used maintenance mode you need to manually start any VMs that were using the CSV. Use the Start-ClusterResource cmdlet to do this.

PS C:\Users\savadmin> Start-ClusterResource "Virtual Machine savdalxpvrt"

Name State Group ResourceType
---- ----- ----- ------------
Virtual Machine savdalxpvrt Online savdalxpvrt Virtual Machine

The good news is that in the final release of Server 2008 R2, a PowerShell cmdlet will be available to do all this for you, and I'll cover this nearer R2's release when the nondisclosure agreement has lifted. But it's still good to know how to do it manually.

Watch this video to learn more about Windows Server 2008 R2 clustering and virtualization

Related Reading:

Check out hundreds more useful Q&As like this in John Savill's FAQ for Windows. Also, watch instructional videos made by John at ITTV.net.
Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.