11/11/14

Repairing with Chkdsk

This handy link from time to time always saves the day for me, especially when your trying to fix that computer that just will not go smoothly. When in doubt and when things go wrong. Start with the basics until you go to a place where you feel comfortable.

Link

Info

Checking and repairing a disk with CHKDSK

The Windows system utility CHKDSK is a powerful and useful tool in diagnosing and repairing certain types of disk problems. I'll review several ways  to run it, and try and describe what it does.
CHKDSK has been around since before the days of Windows. This utility has in some ways changed dramatically for new environments and new disk formats. Yet in other ways, it’s pretty much the same old disk checking utility that we’ve been using since the days of DOS.
Regardless of its age or origins, CHKDSK is an important tool for disk maintenance and recovery (in some cases) from a variety of disk-related issues.
Let’s run CHKDSK.

CHKDSK on a non-system drive

The simplest usage of CHKDSK is on a drive that is not your system (Windows) drive.
In Windows Explorer, right-click on the drive that you want to check:
D: Properties Link
Click Properties. In the resulting dialog box, click the Tools tab:
 D: Properties
Click the Check now… button.
CHKDSK Options
There are two options presented before CHKDSK begins its work:
  • Automatically fix file system errors. If not checked, CHKDSK will simply report but not fix any problems that it finds.
  • Scan for and attempt recovery of bad sectors. This is a more time-consuming scan of the disk that I’ll discuss below.
In general, the default setting is fine when you suspect that there is a problem that needs to be fixed.
Click Start and you may then get this message:
CHKDSK in use message
CHKDSK can only check or repair a disk when it is the only program using that disk; even the rest of Windows cannot be accessing the disk while CHKDSK does its job. Forcing a dismount makes that happen. If a program is actually accessing the drive or files on the drive about to be dismounted, the old “results are unpredictable” phrase applies. Programs may simply notice and do the right thing, they may crash, or something in-between.
That’s why the common advice is to close most programs when running CHKDSK or at least make sure none can access the drive you’re about to check.
Click Force a dismount and CHKDSK begins its work.
Eventually, this is the message that you hope to see:
CHKDSK Done
“See details” displays a log of CHKDSK’s activity. Any errors to be repaired would be listed here.

CHKDSK on a system drive

Remember how I said that CHKDSK requires exclusive access to the drive in order to be able to repair it? And that even Windows can’t be accessing the disk?
That presents a problem when you want to CHKDSK the system drive – typically your C: drive. If Windows is running, then by definition, it accesses the system drive nearly constantly.
The solution is to run CHKDSK before Windows runs.
CHKDSK System Drive
If you attempt to CHKDSK your system drive instead of getting the option to dismount it (not something that can be done while Windows is running), you’ll get this message offering to run the CHKDSK before Windows is loaded the next time that you reboot.
Click Schedule disk check. Now, reboot your machine. As the machine reboots, you’ll see something like this before Windows loads:
CHKDSK running before Windows
Once completed, Windows will load normally.

Getting the results of a scheduled CHKDSK

A very common question is where to get the results of a CHKDSK that ran before Windows started. There’s no pause, and the information shown above disappears as soon as Windows starts to boot.
Run the Event Viewer by clicking Start, and then Run, (or type Windows Key + R). Enter in eventvwr and click OK:
Start -> Run eventvwr
In Event Viewer, click the Application log under “Windows Logs”, look for the line item that ends with Wininit (for Windows Initialization) and has “Checking file system on C:” in the lower General tab.
CHKDSK in Event Viewer
To make reading the results easier, just double-click on that Wininit line.
CHKDSK results in event viewer
The scrolling box near the top contains the results of CHKDSK that scrolled past on the screen before Windows loaded.

CHKDSK via command line

CHKDSK is a command-line tool. All of the options above simply run that same tool in some way that captures its output.
You can do that directly yourself.
Click on StartAll ProgramsAccessories, and then right-click Command Prompt.
Run CMD as Administrator
Click Run as administrator because CHKDSK does require administrative access to do its job.
In the Command Prompt, type:
CHKDSK /F
…to run CHKDSK with the “/F” or “fix” parameter. Without /F, CHKDSK will simply report but not repair any errors.
CHKDSK in CMD
As you can see, the example above checks the D: drive and just as in the windowed interface, CHKDSK must dismount the drive before it can be checked.
If you run CHKDSK against the C: drive:
CHKDSK in CMD on C:
…it similarly requests that the CHKDSK be scheduled at the next reboot.

So what does CHKDSK check?

It’s difficult to describe exactly what information it is that CHKDSK checks without getting lost in the geekery of filesystem details and hard disk layout. Essentially, it checks the organizational and overhead information on a hard disk that allows Windows to locate and access the files stored on that disk.
One analogy might be to think of a hard disk as a kind of simple telephone book.
By default, CHKDSK reads through all the listings and makes sure that they all have a name and a properly formatted telephone number. If a street address is present, CHKDSK might also ensure that the address is also properly formatted and represents a real address in the area that the phone book is supposed to cover.
If problems are found and CHKDSK has been asked to repair things, then it might take actions like removing invalid phone numbers or perhaps adding a proper area code or country code that was supposed to be there in the first place, but only if it can infer from other information what the right answer should be. Similarly, it might try to fix a physical address but has the option of removing that information if it can’t come up with what it should have been.
In fact, it’s possible for CHKDSK to simply remove entries that are so garbled that its proper values can’t be figured out.
Scanning for bad sectors? That’s sort of like calling every phone number in the book and making sure that it rings through to a real phone. It might not be the right person answering, but the phone number works at some basic level.

Scanning for bad sectors

Normally, CHKDSK simply checks that the information stored on the disk is correct. There’s a fair amount of overhead information that tells Windows where files are located and how they’re actually stored and distributed around the disk media. CHKDSK uses it’s knowledge of what this information is supposed to look like to ensure that’s it’s correct and try to fix it when it’s not.
Scanning for bad sectors is another thing entirely. When this option is selected, CHKDSK actually reads the entire disk, not just the overhead information. As a result, a bad sector scan takes significantly longer than a simple CHKDSK.
As CHKDSK reads, it notices if those reads actually succeed. When they do not, it marks the area that failed as “bad” so that they system won’t attempt to write more information into those areas with problems.
It’s important to note that this scan doesn’t test whether the data found is good or valid: only that it can in fact be read.
As we saw earlier, scanning for errors is a simple checkbox when you run CHKDSK from Windows Explorer. For those that prefer the command line, it’s the “/R” – repair – option.

When to CHKDSK

Normally, CHKDSK only need be run when a problem is suspected.
In particular, a scan for bad sectors only needs to be done once you’ve actually encountered a bad sector – usually in the form of a bad read, write, or explicit CRC error. CHKDSK will do what it can, but most importantly, it will remove the bad area from use.
Running CHKDSK to simply check the validity of the file system is a quicker operation and it’s not unreasonable to run it every-so-often, particularly if your machine has been crashing. In most cases, Windows will actually force a CHKDSK after a system crash or improper shutdown. This is done not to fix the cause of the crash (although in some cases it could), but rather to fix any disk-related issues that may have resulted from the crash.

What CHKDSK won’t do

While we talk about CHKDSK “repairing” a hard disk, it is not a data recovery tool per se. It’s job is not to recover lost or damaged files, but to ensure that the information currently on the disk is in a consistent and safe state.
When it comes time to search for files accidentally lost or deleted, then you need to use tools like Recuva and similar.
If you’re trying to recover data from a hard drive that has a persistent media problem or is so damaged that a CHKDSK scan for bad sectors can’t help, then a tool like SpinRite might be your only option.