Scanning the disk surface for errors

 

A step-by-step example of how to use this function can be found here.

Introduction


DiskPatch allows you to scan a selected partition, an entire disk or a user defined area of the disk for what is commonly referred to as 'bad sectors'. Bad sectors can be the cause for many kinds of data loss: files may become corrupt because some of the sectors that the file was saved to have become unreadable, or whole partitions may become in-accessible because the structures that define the partitions contain unreadable sectors.

Sometimes disk problems can be fixed by the tools that are included with several operating systems: scandisk, checkdisk or similar tools will sometimes restore access to files if disk structures such as the FAT were damaged. These tools however do not correctly address the problems that might arise from bad sectors! Let's look at this a bit more closely:

The first priority for a tool such as scandisk or checkdisk is a consistent file system. In other words, their main job is to keep the file system okay, not the actual data that resides on the disk. If a problem occurs with the file system, scandisk or checkdisk may repair the damage, but always in favor of the file system. The result may be that access to actual data can be compromised because the repair could only be completed by removing references to certain files from the file system. These removed files (or fragments of them) then appear as filexxxx.chk files (in case of scandisk or checkdisk).
Another point of interest is how tools like scandisk and checkdisk handle read problems. To put it simple: they don't do that very well. If they encounter a read problem (a bad sector) the entire cluster that the bad sector was a part of, is discarded. If a disk has large clusters (32K clusters for FAT32 is normal, that's 64 sectors per cluster) you lose a lot of capacity, not to mention the impact this may have on files or file system structures. Also, since scandisk and checkdisk by default only check the used areas of the disk, bad sectors may not announce themselves until data is written to one. That may be too late.
Scandisk in particular is not able to deal with bad sectors in a FAT area at all; these sectors will not be recovered by scandisk.

How modern day hard disks handle read errors:

These days disks have a so called 'spare pool' of sectors. When a sector on a disk becomes unreadable and should be taken out of commission, the disk maps one of the sectors from the spare pool to the location that contains the unreadable sector. The problem sector is not 'replaced' as such, but simply ignored from now on: the sector from the spare pool is used when the disk accesses the original bad sector. This process is called 'remapping', or 'sector reallocation'.
It is possible to enforce this remapping process: when a sector becomes inaccessible, it is usually only remapped when the 'bad sector' is accessed for a write operation after it has been detected as being a 'bad sector'. By writing to a sector on the disk the remapping is triggered IF the sector was marked for remapping. By letting DiskPatch run a read-write surface scan, all sectors are read and then written to, causing the sector to be remapped if the sector was eligible for remapping. This effectively 'fixes' an unreadable sector, as long as the spare pool is not yet depleted.
It's important to understand that when we speak of 'repairing bad sectors', the remapping as described above is what we're talking about.

DiskPatch surface scanning

DiskPatch will scan each sector on the disk, whether it's a part of a FAT, filled with data or empty. By allowing DiskPatch to detect 'bad sectors' before the Operating System or the on-board disk repair tools do, you allow your hard disk's internal error management to take care of the bad sector: it will be re-allocated.

DiskPatch interacts with sectors on a low level and does not interact with the file system. When DiskPatch detects a read or write problem, it is handled (by the disk) using one of the following strategies:

  • Error on read that can be corrected:
    Hard disks apply multiple strategies for correcting 'bad' data allowing the disk to provide you with your data even if a sector could not be read entirely. If the data in a sector can be recovered using this strategy, the data is copied to a spare sector and the bad sector is taken out of service.
  • Error on read that could not be corrected:
    If a sector can not be read and the hard disk's automatic error correction can not recover the data in the sector, the sector will become a candidate for reallocation. A read error will be reported. The candidate for reallocation will be reallocated when the sector is accessed for a write operation.
  • Error on write:
    The bad sector is taken out of service and the data is immediately written to a spare sector. In other words, the bad sector is 'reallocated'. If sectors were corrected they will not appear again during the next disk surface scan; this means that if errors that appeared in the first surface scan do not appear in the next surface scan, these 'bad sectors' were reallocated and should now be available again for use.

Using DiskPatch to find and correct disk errors

There are a number of configuration settings that affect DiskPatch's behavior during surface scanning. Make sure these settings are correct before starting the scan.
The settings that affect surface scanning are:

  • read retries
  • write retries
  • read error threshold
  • write error threshold
  • disk reset after error
  • verify fixed bad sectors

DiskPatch offers two ways to scan your disks for read-write errors:

  • The read-only surface scan: By scanning your disk's surface you allow the disk's internal error management as described above to become aware of read problems. If a read error is encountered there are 2 possibilities:
    • the data can be corrected and is placed in a spare sector,
    • the data can NOT be corrected and a read error is reported. The sector becomes a candidate for reallocation, the data in the sector is lost and the candidate sector will be reallocated during the next write operation.
    If a sector can not be read on the first attempt, DiskPatch will retry the read action as many times as is configured in the 'Read Retries' option. If the read eventually succeeds, the correct sector handling strategy is applied.
  • The read-write surface scan: The read-write surface scan is non-destructive: data that can be read remains unmodified. During a read-write scan DiskPatch reads and writes from/to each sector in the scan area.
    Sectors that are 'reallocation candidates' are reallocated when written to. The data in these sectors is lost and is replaced by an F6h byte pattern. By writing a pre-defined byte pattern you can determine if files were affected by the repair and if so, which files were affected (see below).
    If write errors are reported this indicates sectors could not be reallocated, possibly because the spare pool was exhausted. Run an additional read-write surface scan to see if the errors are persistent. You can use our S.M.A.R.T. utility or the disk manufacturer's diagnostic tool (refer to the disk manufacturer's website) to determine the exact condition of the hard disk. Once the pool of spare sectors has been exhausted bad sectors can no longer be reallocated, and bad sectors will continue to appear during surface scans.

To run a surface scan:

Select [Disk related tasks], [Surface Scan (read-only)] or [Surface Scan (read/write)].
When you select a read/write scan, a menu will be displayed that will allow you to fine-tune the surface scan:

Write only after read-error will be the quickest way to scan the disk; a write will only be issued when a bad sector is located.
Full read/write scan will take longer but is more thorough; all sectors will be read and written.

Now select a partition to scan or select a region of the disk manually:

To scan the entire disk, select 'entire disk' and leave the suggested default values (just press <enter>).

Tip: determining if and which files were affected by sector reallocation on write
:

What happens when a bad sector is encountered:
If DiskPatch encounters a bad sector during a read operation and the sector's contents can not be read at all, DiskPatch replaces the sector data with a text string: DPBADSECTOR. If the contents of the (bad) sector needs to be written to disk after the read error (for instance during a clone operation, or a read-write surface scan) the sector data will contain this string. This can help to locate files that were affected by the read errors: search through the files and use DPBADSECTOR as a search string.
  • start the windows search tool
  • in the 'text to search for' box, type DPBADSECTOR. Use a case sensitive search, enter the text in upper case. Do not use spaces or other characters
  • make sure the search tool searches all files (*.*) and that the search includes hidden and system files
  • start the search

The resulting file list contains files that are likely to be damaged. Verify this and if necessary restore correct versions of these files.
If a disk contains more than 1 partition, repeat this process for all partitions.

http://www.diydatarecovery.nl