chkdsk - Check and Repair Disk Errors

Maintained on

Files won’t open, folders look corrupted, or a USB drive keeps asking “Do you want to format it?” When that happens, chkdsk (Check Disk) is the tool to try. It scans a drive for errors and repairs them.

What chkdsk does depends heavily on its options. With no options it only scans; /f repairs errors; /r also looks for bad sectors. This article explains how to choose between them and how to handle the messages you are likely to see.

Prerequisite: Run as Administrator

chkdsk must be run from a Command Prompt opened as administrator. Without elevated rights the scan is refused, even a read-only one.

See

for how to open an elevated Command Prompt.

Cheat Sheet by Goal

GoalCommand
Check the state only (no repair)chkdsk C:
Scan and repair errorschkdsk C: /f
Also scan for bad sectors (slow)chkdsk C: /r
Dismount a busy drive first, then repairchkdsk D: /x
Scan an NTFS volume while it is in usechkdsk C: /scan
Quickly fix only the problems found (NTFS)chkdsk C: /spotfix
Don't forget the drive letter

Running chkdsk alone does a read-only check of the current drive (usually C:). To target another drive, specify its letter, as in chkdsk D:.

Basic Syntax of chkdsk

chkdsk [<drive>:] [/f] [/r] [/x] [/scan] [/spotfix] [/v]
OptionDescription
(none)Scans only; reports errors but does not fix them
/fFixes errors on the disk. The drive must be locked
/rLocates bad sectors and recovers readable data. Includes everything /f does
/xDismounts the drive first if necessary. Includes everything /f does
/scanScans an NTFS volume online (while in use)
/spotfixQuickly repairs only the problems found, offline (NTFS volumes)
/vShows detailed information (the path of each file checked on FAT volumes; cleanup messages on NTFS)

/f vs /r

These two are the ones people mix up.

Item/f/r
What it repairsFile system inconsistenciesFile system inconsistencies + bad sectors
Time requiredRelatively shortLong (can take hours on a large HDD)
Best usedAs the first thing to tryWhen physical problems with the disk are suspected

/r includes /f, so you never need to write both. A common approach is to try /f first, then use /r if problems persist or reads are extremely slow.

/r is slow. Don't cut the power

/r examines the whole disk, which can take a long time on large HDDs. Plug in a laptop and do not shut down or lose power during the scan. Bad sectors work differently on SSDs than on HDDs, so there is little reason to run /r routinely on an SSD.

Scan a Disk

First, check the state without repairing anything.

chkdsk C:

If there are no problems, you will see something like this at the end (for NTFS):

Windows has scanned the file system and found no problems.
No further action is required.

If errors are found, you will see a message saying the file system has errors and telling you to run CHKDSK with the /f option. Repair them as described next.

Repair Errors

chkdsk D: /f

/f locks the drive so it can repair it. If no other program is using the drive, the scan and repair proceed immediately.

If You See “Cannot lock current drive”

If you use /f on a drive in use, such as the C: drive that holds Windows, you will see:

Cannot lock current drive.
Chkdsk cannot run because the volume is in use by another process.
Would you like to schedule this volume to be checked the next time the system restarts? (Y/N)

Type Y and press Enter to have the scan and repair run automatically at the next restart (before Windows starts). Restart the PC and wait for it to finish.

For external drives, /x also works

For non-system drives such as USB drives, closing open windows and apps often lets you run the scan without restarting. If it still reports the drive as in use, chkdsk D: /x dismounts the drive first (any open handles to that drive become invalid). For a busy non-system drive, chkdsk /f may first ask “Would you like to force a dismount on this volume? (Y/N)”; answering Y does the same thing, so save your work first.

Cancel a Scheduled Check

To cancel a check you scheduled, exclude the drive from the startup check:

chkntfs /x C:
The /x setting persists

A drive excluded with chkntfs /x is no longer checked automatically at startup, even if it really has problems. To undo it, run chkntfs /d to restore the default behavior.

You can see whether a check is scheduled with chkntfs C:. At restart you can also press a key on the “Press any key to skip disk checking” screen to skip it just this once.

Check the Results Afterward

After a check at restart, the desktop appears right away, so it is easy to miss the results. You can view them in Event Viewer:

  1. Run eventvwr.msc to open Event Viewer
  2. Select “Windows Logs” → “Application”
  3. Look for events whose source is Wininit (check at restart) or Chkdsk (scan within Windows)

In PowerShell, this command retrieves the latest result of a check at restart:

Get-WinEvent -FilterHashtable @{ LogName = 'Application'; ProviderName = 'Wininit' } -MaxEvents 1 | Format-List Message

Scan While Running (/scan)

On NTFS volumes in Windows 8 and later, /scan performs an online scan without taking the drive offline.

chkdsk C: /scan

/scan only scans; repairs are done later. To keep downtime to a minimum, use /spotfix:

chkdsk C: /spotfix

/spotfix repairs only the problems found. If the drive is in use and cannot be taken offline, it runs at a time when the drive is not in use, such as the next restart.

Check the Exit Code in a Batch File

chkdsk returns its result as an exit code, so a batch file can act on it.

Exit codeMeaning
0No errors found
1Errors found and fixed
2Cleanup was performed, or was not performed because /f was not specified
3Could not check the disk, errors could not be fixed, or errors were not fixed because /f was not specified
disk-check.cmd
@echo off

chkdsk D:
if %errorlevel% equ 0 (
  echo No problems found.
) else (
  echo The disk needs attention. Exit code: %errorlevel%
)
pause

For more on exit codes, see

.

Things to Know Before Using chkdsk

Summary

GoalCommand
Check the state without repairingchkdsk C:
Repair errorschkdsk C: /f
Also scan and repair bad sectorschkdsk C: /r
Scan while the drive is in usechkdsk C: /scan
Repair only the problems foundchkdsk C: /spotfix
Cancel a scheduled startup checkchkntfs /x C:

Practice Questions

Practice Problem

Which option is the minimum needed to repair file system errors on a disk?

Choose one answer.

  1. chkdsk C: with no options
  2. chkdsk C: /f
  3. chkdsk C: /v

Practice Problem

You ran chkdsk C: /f and saw “Cannot lock current drive.” What happens if you type Y?

Choose one answer.

  1. The scan and repair run at the next restart, before Windows starts
  2. All apps are force-closed and the repair starts immediately
  3. The scheduled check is canceled and nothing happens
#Command Prompt #Command Line #Commands #chkdsk #Disk #Administrator Rights #Troubleshooting