The magnetic material on the surface of a computer disk almost always includes some microscopic flaws, no matter how careful the manufacturing was. These areas of course aren't usable because those microscopic flaws interfere with the storage of information. But it wouldn't work out to just throw away all those disks. Some way of making them useful despite the microsopic flaws in their magnetic material is needed.
The usual solution is to "catch" disk write operations to flawed areas and redirect them to some extra invisible space on the disk, then "catch" the corresponding disk read operations and return the appropriate data read from the extra invisible space. Nowadays this operation is performed by the disk itself (or by the "microcode" inside the disk if you prefer that terminology).
New disks already have most of their flawed areas identified. And if reading problems suggest an additional flawed area, the disk adds that area to its list of flaws and moves the data automatically. The user doesn't have to do anything.
Of course when installing a new OS, it often makes sense to first obtain the manufacturer's disk diagnostic program and have it scan (test) the entire magnetic surface and recreate the entire list of flawed areas. (Such diagnostics are usually [but not always] non-destrictive of data and can be run safely after the new OS is installed too. But rather than risking a surprise, use the disk diagnostics to scan (test) the whole surface before installing a new OS.) Note that a complete surface scan to completely rebuild the list of flawed areas can take a very long time, perhaps even several hours. So plan ahead.
This system works so well and so automatically that many users don't even realize their disk includes some microscopic flaws. Nevertheless very occasionally some reason may arise for using some tool other than the disk itself to handle the surface scan and the flaw redirection. Such an alternative is the disk scan and redirect tools built into Linux. Way back when Unix was invented, disks weren't so smart, and it was necessary to provide the entire set of scan and redirect tools some other way. So the whole set of tools was included inside Unix itself. Although seldom used, it's still there.
In most cases, using these tools isn't recommended because with both Linux and the disk thinking they're in charge of scanning and redirecting, the situation can be too complex to understand clearly. But there may be times anyway...
The Linux command to enter at a shell prompt
to surface scan a disk partition is
fsck -f -y -C -V -c -c /dev/xxan
Those parameters mean:
||"force" the complete operation to occur even if the flag says the disk is "clean"|
|automatically answer "yes"
whenever an error is discovered which asks the user what to do
(needed for unattended automatic fix operation)
|(note upper case)
present a progress bar showing how much of the operation has been completed
|(note upper case)
enable "verbose" mode to keep the user apprised of what's happening by printing informative messages
|(no that's not a stutter,
it really does need to be entered twice for this particular piece of software -
only once would specify the "shortcut" of
only reading the existing data from every sector
and relying completely on the disk itself to detect any problems,
thus missing many flaws)
do a comprehensive surface scan operation by saving the existing contents of each area, writing a test pattern to the area, reading the area and making sure the data read is exactly the same as the pattern that was written, then finally restoring the initial contents of the area
|xxan||the disk partition to be operated on:
xx is either
(Note the disk partition should not be mounted
[i.e. any possibility of being in use] during the operation.
For some partitions the
will do all that's necessary;
for others you may have to
boot the system in "emergency" mode.)