Windows Disk and Storage Cheat Sheet

Windows disk and storage commands in one place: diskpart, chkdsk online scan, fsutil, chkntfs, vssadmin and the PowerShell storage cmdlets, with the failure signals that matter.

Start here

Check a volume without downtime
chkdsk C: /scan
Is the volume flagged dirty
fsutil dirty query C:
Where did the space go
vssadmin list shadowstorage
Disk is read-only or offline
diskpart, attributes disk
Cluster size and MFT layout
fsutil fsinfo ntfsinfo C:
Is the disk dying
Events 7, 51, 153
Modern chkdsk is two steps, not one. Since Windows 8 and Server 2012 the scan runs online while the volume is in use, and only the repair needs the volume offline. The old habit of scheduling a full /f at boot is rarely the right move on a server.

chkdsk

SwitchEffect
/scanOnline scan, volume stays in use. NTFS only.
/spotfixFix the queued problems, needs a brief dismount. NTFS only.
/perfScan as fast as possible, at the cost of everything else. Use with /scan.
/forceofflinefixSkip online repair, queue everything for offline. Use with /scan.
/offlinescanandfixFull offline scan and repair
/fFix errors, requires an exclusive lock on the volume
/rFind bad sectors and recover what is readable. Implies /f and takes hours.
/bClear the bad cluster list and re-test every cluster. Implies /r. NTFS only.
/xForce a dismount first, invalidating open handles. Implies /f.
/iLighter index check, faster. NTFS only.
/cSkip folder cycle checking, faster. NTFS only.
/sdcleanupCollect unused security descriptor data. Implies /f. NTFS only.
SituationCommand
Routine health check on a live serverchkdsk C: /scan
Same, and you want it over quicklychkdsk C: /scan /perf
Apply the fixes found by the scanchkdsk C: /spotfix
Data volume you can dismount nowchkdsk E: /f /x
Suspected bad sectorschkdsk E: /r /x
PowerShell equivalent of the online scanRepair-Volume -DriveLetter C -Scan
PowerShell spot fixRepair-Volume -DriveLetter C -SpotFix
PowerShell full offline repairRepair-Volume -DriveLetter E -OfflineScanAndFix
/r on a failing disk can finish the job. Reading every sector of a disk that is already throwing event 7 or 153 puts it under exactly the load it cannot take. Image the disk first, then repair the image, not the original.

chkntfs and the dirty bit

TaskCommand
Is this volume marked dirtychkntfs C:
Same answer, different toolfsutil dirty query C:
Stop a volume being checked at bootchkntfs /x C:
Put it back in the boot checkchkntfs /d
Schedule a check at next bootchkntfs /c D:
Change the countdown before autochk runschkntfs /t:15
The dirty bit is a flag, not a diagnosis. It means the volume was not dismounted cleanly or that NTFS saw something it wants checked. Excluding the volume with /x silences the boot check but leaves the flag set, so use it to control a maintenance window, never to make the message go away.

diskpart

StepCommand
See the diskslist disk
Pick one, everything after this acts on itselect disk 1
Confirm you picked the right onedetail disk
Bring an offline disk uponline disk
Clear the read-only flagattributes disk clear readonly
Re-scan after a LUN changerescan
Partitions on the selected disklist partition
Volumes, with letters and labelslist volume
Wipe the disk, partition table includedclean
Convert an empty diskconvert gpt or convert mbr
Create a partition using all the spacecreate partition primary
Create a sized partition, in MBcreate partition primary size=51200
Format itformat fs=ntfs quick label="Data"
Give it a letterassign letter=E
Grow into free space that follows itextend
Shrink by an amount, in MBshrink desired=10240
Delete a protected partitiondelete partition override
clean does not ask twice. It destroys the partition table of whatever select disk last pointed at, and diskpart keeps that selection between commands. Run detail disk and read the size and model out loud before anything destructive. There is no undo and no recycle bin.

The PowerShell equivalents

TaskCommand
Disks, with health and partition styleGet-Disk
Volumes, with free spaceGet-Volume
Partitions on one diskGet-Partition -DiskNumber 1
Bring a disk online and writableSet-Disk -Number 1 -IsOffline $false then -IsReadOnly $false
Initialise a new diskInitialize-Disk -Number 1 -PartitionStyle GPT
Create and letter a partitionNew-Partition -DiskNumber 1 -UseMaximumSize -AssignDriveLetter
Format itFormat-Volume -DriveLetter E -FileSystem NTFS -NewFileSystemLabel "Data"
Grow a partition to the maximumResize-Partition -DriveLetter E -Size (Get-PartitionSupportedSize -DriveLetter E).SizeMax
Physical disks and media typeGet-PhysicalDisk | Select FriendlyName,MediaType,HealthStatus
Wear and error countersGet-PhysicalDisk -Number 0 | Get-StorageReliabilityCounter
Rescan after presenting a new LUNUpdate-HostStorageCache
Use the cmdlets in scripts, diskpart at the console. The cmdlets return objects you can test before acting, which matters when a script is about to format something. diskpart has no such safety net, which is exactly why it is still the faster tool when a human is watching.

fsutil

TaskCommand
Cluster size, MFT size and zonefsutil fsinfo ntfsinfo C:
Every drive and its typefsutil fsinfo drives
Volume label, serial and file systemfsutil fsinfo volumeinfo C:
Free space in bytesfsutil volume diskfree C:
Which file owns a given clusterfsutil volume querycluster C: 12345
Dirty bitfsutil dirty query C:
NTFS self-healing statefsutil repair query C:
Create a file of an exact size for testingfsutil file createnew C:\temp\test.dat 1073741824
Hard links pointing at a filefsutil hardlink list C:\data\file.txt
Is this a junction or a symlinkfsutil reparsepoint query C:\data\link
Change journal size and statefsutil usn queryjournal C:
Is TRIM enabled, 0 means yesfsutil behavior query DisableDeleteNotify
8.3 name creation on a volumefsutil 8dot3name query C:
ntfsinfo answers the question behind most “the disk is full” tickets on a file server. A 4 KB cluster with millions of tiny files wastes a surprising amount, and the MFT zone shows how much of the volume the file system itself has reserved.

Shadow copies

TaskCommand
Existing snapshotsvssadmin list shadows
How much space they are allowed and usingvssadmin list shadowstorage
Writers and their state, before blaming the backupvssadmin list writers
Installed providersvssadmin list providers
Cap the space usedvssadmin resize shadowstorage /for=C: /on=C: /maxsize=10%
Delete the oldest snapshotvssadmin delete shadows /for=C: /oldest
Create a snapshot, Windows Server onlyvssadmin create shadow /for=C:
Failed writers are not fixed by rerunning the backup. A writer in a failed or timed-out state stays that way until its service restarts, and on a busy server that usually means a reboot. Check list writers before you spend an evening on the backup software.
Deleting shadows deletes restore points. It frees space immediately and it also removes previous versions users can self-serve, and any application-consistent snapshot a backup depends on. Resize the storage instead when the problem is space.

Space, trim and fragmentation

TaskCommand
Analyse without changing anythingdefrag C: /A
Same, PowerShellOptimize-Volume -DriveLetter C -Analyze -Verbose
Send TRIM to an SSD, no defragmentationOptimize-Volume -DriveLetter C -ReTrim
Defragment a spinning diskOptimize-Volume -DriveLetter D -Defrag
Consolidate free space before shrinkingdefrag D: /X
Clean up component store growthdism /online /cleanup-image /startcomponentcleanup
What WinSxS is actually costingdism /online /cleanup-image /analyzecomponentstore

Where the space actually went, without installing anything:

Get-ChildItem C:\ -Directory | ForEach-Object {
  [PSCustomObject]@{
    Path = $_.FullName
    GB   = [math]::Round((Get-ChildItem $_ -Recurse -File -EA 0 | Measure-Object Length -Sum).Sum / 1GB, 1)
  }
} | Sort-Object GB -Descending
Do not defragment an SSD. Optimize-Volume already picks the right operation per media type, which is why it is the safe command to script. Forcing -Defrag on flash only burns write cycles.

Is the hardware failing

SignalWhere
Bad block reported by the driverSystem log, event 7
Error during a paging operationSystem log, event 51
IO retried on a pathSystem log, event 153
Device reset, the disk stopped answeringSystem log, event 129
File system structure corruptSystem log, event 55 from Ntfs
Predictive failure, SMARTSystem log, event 52
Health as Windows sees itGet-PhysicalDisk | Select FriendlyName,HealthStatus,OperationalStatus
Read and write error countersGet-PhysicalDisk | Get-StorageReliabilityCounter | Select DeviceId,ReadErrorsTotal,WriteErrorsTotal,Wear
Rough SMART statusGet-CimInstance -Namespace root\wmi -ClassName MSStorageDriver_FailurePredictStatus
On a VM, look one layer down. Events 129 and 153 inside a guest usually mean the storage path or the array underneath is struggling, not the virtual disk. Check the ESXi host and the datastore before touching the guest.

FAQ

Do I still need to schedule chkdsk /f at boot?
Rarely. On NTFS, chkdsk /scan runs online and queues what it finds, and /spotfix then applies the fixes in seconds rather than hours. A full offline check is for a volume that is already refusing to mount or that /scan says needs it.
Shrink volume will not go below half the disk. Why?
Immovable files, typically the page file, hibernation file or a shadow copy, sit near the end of the volume. Disable the page file and hibernation, delete shadow copies, reboot, shrink, then turn them back on. defrag D: /X helps consolidate the rest.
A new LUN is presented but Windows does not see it.
rescan in diskpart, or Update-HostStorageCache. If it appears offline or read-only, that is the SAN policy: san in diskpart shows it, and attributes disk clear readonly plus online disk fixes the disk itself.
The volume shows far less free space than the files add up to.
Usually shadow copy storage, the component store, or user profiles nobody counted. Check vssadmin list shadowstorage first, then dism /online /cleanup-image /analyzecomponentstore, then measure folders. Quotas and the recycle bin per user account for most of the rest.
Is it safe to run these on a VMware virtual disk?
Yes, they operate at the guest level. Be aware that shrinking inside the guest does not shrink the VMDK, and that -ReTrim is what tells thin-provisioned storage the blocks are free, which is how you actually reclaim space on the datastore.