chkdsk - Check and Repair Disk Errors
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
| Goal | Command |
|---|---|
| Check the state only (no repair) | chkdsk C: |
| Scan and repair errors | chkdsk C: /f |
| Also scan for bad sectors (slow) | chkdsk C: /r |
| Dismount a busy drive first, then repair | chkdsk D: /x |
| Scan an NTFS volume while it is in use | chkdsk C: /scan |
| Quickly fix only the problems found (NTFS) | chkdsk C: /spotfix |
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]
| Option | Description |
|---|---|
| (none) | Scans only; reports errors but does not fix them |
/f | Fixes errors on the disk. The drive must be locked |
/r | Locates bad sectors and recovers readable data. Includes everything /f does |
/x | Dismounts the drive first if necessary. Includes everything /f does |
/scan | Scans an NTFS volume online (while in use) |
/spotfix | Quickly repairs only the problems found, offline (NTFS volumes) |
/v | Shows 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 repairs | File system inconsistencies | File system inconsistencies + bad sectors |
| Time required | Relatively short | Long (can take hours on a large HDD) |
| Best used | As the first thing to try | When 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 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 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:
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:
- Run
eventvwr.mscto open Event Viewer - Select “Windows Logs” → “Application”
- 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 code | Meaning |
|---|---|
| 0 | No errors found |
| 1 | Errors found and fixed |
| 2 | Cleanup was performed, or was not performed because /f was not specified |
| 3 | Could not check the disk, errors could not be fixed, or errors were not fixed because /f was not specified |
@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
- Back up first: if the disk is physically failing, repairing with
/for/rcan make things worse. Copy important data first. - Some files may be lost: corrupted files can be saved as fragments in folders such as
found.000, or removed, during repair. - Repeated errors suggest hardware failure: if the same errors come back after repair, the disk itself may be near the end of its life.
- For system file corruption, use sfc: problems caused by damaged Windows system files are handled with , not
chkdsk.
Summary
| Goal | Command |
|---|---|
| Check the state without repairing | chkdsk C: |
| Repair errors | chkdsk C: /f |
| Also scan and repair bad sectors | chkdsk C: /r |
| Scan while the drive is in use | chkdsk C: /scan |
| Repair only the problems found | chkdsk C: /spotfix |
| Cancel a scheduled startup check | chkntfs /x C: |