Sub topic 6
Repairing System Files and Disks with sfc, DISM and chkdsk
This chapter assumes you can open an elevated Command Prompt or PowerShell, you know what a file system is, and you have read the earlier chapters on the troubleshooting methodology and the Windows Recovery Environment (WinRE). Here you will learn what each repair tool fixes, the order to run them in, and the errors that trip people up on the job and on the exam.
Why three tools exist
Windows keeps its core files in a few places. Each tool checks a different layer.
- System File Checker (sfc) checks protected system files, such as DLLs and executables, against cached known-good copies. It replaces any file that is damaged or altered.
- Deployment Image Servicing and Management (DISM) repairs the component store, the
WinSxSfolder. sfc draws its replacement files from this store. If the store is damaged, sfc has nothing healthy to copy from. - chkdsk checks the file system structure and the disk surface. It does not look at what the files contain. It looks at whether the disk can store and find them.
So the layers stack: the disk holds the file system, the file system holds the component store, and the component store feeds sfc.
When to reach for these tools
Typical symptoms that point to corruption:
- Applications or Windows features crash with missing or invalid DLL messages.
- Windows Update fails repeatedly with the same error.
- Stop errors that name file system or disk problems, such as
NTFS_FILE_SYSTEM. - Files disappear, become unreadable, or the drive reports errors in Event Viewer.
- Boot problems after a power loss or an improper shutdown.
Follow the methodology. Gather evidence first, for example from Event Viewer, and back up important data before a repair that may change the disk. Prefer the least destructive fix. Running sfc is low risk. A long chkdsk on a failing drive is not, as the later section explains.
System File Checker
sfc must run from an elevated prompt. Open Command Prompt or Windows Terminal with "Run as administrator."
| Switch | What it does |
|---|---|
| `sfc /scannow` | Scans all protected files and repairs them |
| `sfc /verifyonly` | Scans and reports, but changes nothing |
| `sfc /scanfile=<path>` | Scans and repairs one file |
| `sfc /verifyfile=<path>` | Verifies one file without repairing it |
| `sfc /offbootdir=C:\ /offwindir=C:\Windows /scannow` | Repairs an offline Windows installation, for example from WinRE |
sfc ends with one of a few messages. Know what each means:
- No integrity violations. Protected files are intact. Look elsewhere for the cause.
- Found corrupt files and successfully repaired them. Restart and test again.
- Found corrupt files but was unable to fix some of them. The cached copy is bad too. Run DISM, then sfc again.
- Could not perform the requested operation. Often a permissions problem (not elevated), or another repair is pending. Try again from an elevated prompt, or from Safe Mode or WinRE.
sfc writes details to C:\Windows\Logs\CBS\CBS.log. That file is large. Filter it for the lines that matter:
findstr /c:"[SR]" %windir%\Logs\CBS\CBS.log > "%userprofile%\Desktop\sfclogs.txt"DISM
DISM repairs the component store that sfc relies on. The /Online switch targets the running Windows installation. The /RestoreHealth option downloads good files from Windows Update by default.
| Command | Purpose |
|---|---|
| `DISM /Online /Cleanup-Image /CheckHealth` | Quick check for a corruption flag. Makes no repairs |
| `DISM /Online /Cleanup-Image /ScanHealth` | Deeper scan. Makes no repairs |
| `DISM /Online /Cleanup-Image /RestoreHealth` | Scans and repairs the store |
If the computer has no internet access, or Windows Update itself is broken, point DISM at a known-good source such as a mounted Windows installation image:
DISM /Online /Cleanup-Image /RestoreHealth /Source:WIM:D:\sources\install.wim:1 /LimitAccess/LimitAccess stops DISM from contacting Windows Update. The :1 is the image index, which selects the edition inside the image file.
The standard repair sequence
Microsoft's guidance, and the usual exam answer, is to repair the store first and then run sfc again, so that sfc can pull healthy files from the repaired store. Run this from an elevated prompt:
sfc /scannow
DISM /Online /Cleanup-Image /RestoreHealth
sfc /scannowRun the first sfc to see whether the problem is simple. If it fails to fix everything, DISM repairs the source, and the second sfc finishes the job. Restart afterward.
chkdsk
chkdsk examines a volume's file system and can also test the disk surface. It must be run elevated.
| Switch | What it does |
|---|---|
| `chkdsk C:` | Read-only check. Reports problems, fixes none |
| `chkdsk C: /f` | Fixes file system errors |
| `chkdsk C: /r` | Locates bad sectors and recovers readable data. Implies `/f` |
| `chkdsk C: /x` | Dismounts the volume first. Implies `/f` |
Use this form for a thorough check:
chkdsk C: /f /rThe system drive is in use, so chkdsk cannot lock it. It offers to run at the next restart. Answer Y, restart, and the check runs before Windows loads. From WinRE, the drive is not in use, so the check starts immediately. Note that the drive letter may differ in WinRE. Confirm it with dir or diskpart first.
Edge cases and risks
/ris slow. It reads every sector. On a large drive it can take hours. Plan for it.- A failing drive can get worse under stress. Clicking noises, rapidly growing bad sector counts, or SMART warnings mean you should image or copy the data first. A complete chkdsk on a dying disk may finish the job of killing it.
- chkdsk can delete data. When it repairs a damaged file system, it may truncate files or move orphaned fragments into
FOUND.000folders as.chkfiles. Back up first when you can. - Dirty bit. When Windows detects a problem or an unclean shutdown, it sets the volume's dirty bit, and autochk runs at the next boot. You can query it with
fsutil dirty query C:. - SSDs.
/rstill works, but a surface scan matters less on solid state drives. A file system check with/fis usually enough. A recurring error on an SSD points to a failing drive or firmware. - Repeated errors after repair. If chkdsk finds new errors each time, the cause is hardware: the drive, the cable, or the controller. No software fix will hold.
Choosing the right tool
| Symptom | First tool |
|---|---|
| Missing or corrupt system DLL, odd Windows feature failures | `sfc /scannow` |
| sfc reports it cannot fix files, or Windows Update is stuck on corruption | `DISM /RestoreHealth`, then sfc |
| Unclean shutdown, file system error messages, unreadable files | `chkdsk /f` |
| Slow disk, repeated read errors, suspected bad sectors | Back up, then `chkdsk /r` |
| Windows will not boot at all | WinRE, then offline sfc or chkdsk |
Common errors
- Not running elevated. sfc, DISM and chkdsk all fail or refuse to repair without administrator rights.
- Running sfc once and stopping. A single sfc pass may need a restart and a second pass to confirm the fix.
- Skipping DISM when sfc cannot repair. sfc cannot repair files if its source is damaged.
- Using
/fand expecting a surface scan. Bad sector detection needs/r. - Forgetting the restart. On the system drive, chkdsk repairs happen at boot. If you decline the schedule or never reboot, nothing is repaired.
- Treating repair as a cure for malware. Malware can alter system files. sfc may restore files, but you must also remove the infection or the files will be altered again.
Exercise
A technician runs sfc /scannow on a Windows 11 PC. It reports that it found corrupt files but could not repair some of them. The PC is online. What should the technician run next, and what should they do after that?
Show answer
Run DISM /Online /Cleanup-Image /RestoreHealth from an elevated prompt to repair the component store that sfc uses as its source. Then run sfc /scannow again and restart the PC.
Exercise
A user's PC shows file system errors after a power outage, and the technician hears clicking from the hard drive. Why should the technician hesitate before running chkdsk C: /f /r, and what should they do first?
Show answer
A full chkdsk reads every sector and can put heavy stress on a failing drive, and its repairs can also truncate or remove damaged files. The clicking suggests physical failure, so the technician should back up or image the data first, then run chkdsk and plan to replace the drive.
Exercise
You boot a PC into the WinRE Command Prompt to check the Windows volume. Why should you confirm the drive letter before running chkdsk or an offline sfc?
Show answer
WinRE often assigns different drive letters than the running Windows installation, so the Windows volume may not be C:. Running a command against the wrong volume checks the wrong disk. Use dir or diskpart to identify the correct letter first.