3
Filesystem checking has nothing to do with scanning for "bad" sectors. "bad" sectors in this context usually means sectors that can't be read reliably or can't be written reliably. Although a filesystem check can certainly stumble upon a bad sector since it attempts to read (and maybe write) blocks all over the filesystem.
What a filesystem check actually does is really up to each individual filesystem and up to the implementer of the filesystem checking utility. For some types of filesystems (for example, NFS and tmpfs), the concept is meaningless, for others it is redundant, because the filesystem continuously checks itself in the course of normal operation, and for others it is vital that to check the filesystem once in a while.
In general, filesystem checking utilities are designed to check for corruption, inconsistencies, and violated invariants in the filesystem's data structures. If you want more detail than that, then you will have to ask about a specific type of filesystem.
3
CHKDSK does quite a few things behind the scenes. They are represented in the different phases of CHKDSK.
NTFS has something called an MFT (or Master File Table). This MFT is a list of all files on the hard drive. To check for file consistency, CHKDSK reads the MFT entry by entry, and then it goes up and looks up the corresponding file in the HDD.
For example CHKDSK finds MyPhoto1.jpg in the MFT. The MFT says it is located in sector 230, and is 30 sectors long. CHKDSK then goes and reads sector 230 to 260, and sees that it is in fact populated by data, and is one file. This is how CHKDSK checks for file system consistency. Files inconsistency doesn't necessarily mean a bad sector, it could mean the computer was powered off during a write to the HDD.
With the /r flag (recover), CHKDSK checks for file inconsistencies and attempts to repair them. Without this flag, chkdsk performs a "dry run"
With the /f flag (fix), CHKDSK attempts to repair the bad sector. In other words, it attempts to recover the data on the bad sector, and attempts to rewrite to that sector. If CHKDSK reads what it wrote the sector in question, then it can mark the sectors as repaired.
Sadly it's not a full "dry run". It'll give you some idea of what problems it finds, but it won't pretend to fix them, and there are cases where finding later problems will depend on fixing earlier problems. – mwfearnley – 2019-12-05T16:15:09.390
The complete manual for chkdsk
can be found here: http://technet.microsoft.com/en-us/library/cc730714(v=ws.10).aspx
I don't know if I agree with this. For example - when you run fsck it attempts to repair nodes and fix missing/deleted files. I don't think these things can happen while the FS is mounted. – Natalie Adams – 2013-01-09T17:18:19.703
Different filesystems are different. ZFS is an example of a filesystem that does indeed verify and repair the filesystem online while it is mounted; it calls this scrubbing.
– Celada – 2013-01-09T19:02:47.077