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 window and that you know what a boot failure and a Windows Recovery Environment (WinRE) are from earlier chapters. Here you will learn what each repair tool fixes, the order to run them in, and the mistakes the exam likes to test.
What each tool repairs
The three tools work on different layers, so picking the right one depends on the symptom.
| Tool | Repairs | Typical symptom |
|---|---|---|
| sfc /scannow | Protected system files, replaced from the component store | Missing or corrupt DLLs, odd Windows behavior |
| DISM /Online /Cleanup-Image /RestoreHealth | The component store that sfc copies from | sfc reports damage it cannot fix |
| chkdsk /f /r | File system errors and bad sectors | Slow disk, read errors, unexpected "dirty" volume |
System File Checker (sfc) compares protected files against cached copies. Deployment Image Servicing and Management (DISM) repairs the store those copies come from, usually by downloading good files from Windows Update. The chkdsk tool checks the volume itself, not Windows files.
Running them in order
Open an elevated prompt first. Without administrator rights, sfc fails with a message that you must be an administrator.
sfc /scannow
DISM /Online /Cleanup-Image /RestoreHealth
sfc /scannowRun sfc first. If it says it found corrupt files and could not fix them, run DISM next. DISM needs a working network connection to fetch replacement files unless you give it another source. Then run sfc again, because it can now restore files from the repaired store.
Checking the disk
chkdsk C: /f /rThe /f switch fixes file system errors. The /r switch locates bad sectors and recovers readable data, and it includes the work of /f. Because Windows is using the C: drive, chkdsk offers to run at the next restart. Answer Y and reboot. A /r scan on a large drive can take hours.
Using the tools when Windows will not start
If Windows cannot boot, open the Command Prompt from WinRE. The drive letter there often differs from C:, so confirm it with dir first. You can then run chkdsk against the Windows volume. You can also run sfc offline with sfc /scannow /offbootdir=D:\ /offwindir=D:\Windows, replacing D: with the letter you found.
Common errors
- Running the tools without elevation.
- Running DISM with no internet access and no alternate source.
- Interrupting chkdsk on a large drive and leaving the volume marked dirty.
- Using chkdsk to fix a corrupt Windows file, or sfc to fix a bad sector.
- Skipping a backup before a long /r scan on a drive that is already failing.
Exercise
A technician runs sfc /scannow, and it reports that it found corrupt files but could not repair some of them. What should the technician do next, and why?
Show answer
Run DISM /Online /Cleanup-Image /RestoreHealth to repair the component store that sfc draws its good copies from, then run sfc /scannow again so it can restore the damaged files.
Exercise
A user's C: drive shows read errors and Windows reports a possible bad sector. Which command should you run, and what do its two switches do?
Show answer
Run chkdsk C: /f /r. The /f switch fixes file system errors. The /r switch locates bad sectors and recovers readable data. Windows will ask to run it at the next restart. Back up the data first if the errors persist.