badsect

Bruce Evans bde at zeta.org.au
Thu Feb 24 20:19:56 GMT 2005


On Thu, 24 Feb 2005 falaki at ce.sharif.edu wrote:

> I have a hard disk that seems to have some limitted number of bad sectors.
> I want to use badsect to avoid these errors.
>
>    ad0: TIMEOUT - READ_DMA retrying (2 retries left) LBA=27546816
>    ad0: FAILURE - READ_DMA timed out
>
> I tried this:
>
>    #badsect /mnt/data 27546816
>
> and got:
>
>    block 27546816 out of range of file system
>    don't forget to run fsck ...
>
> What should I do?

The usual answer is to replace the disk.

If you want to try to use badsect, be aware of bugs.  Accordng to badsect(1):

     ...  (The sector numbers
     must be relative to the beginning of the file system, but this is not
     hard as the system reports relative sector numbers in its console error
     messages.)  ...

This never worked for all disk drivers in FreeBSD, and only worked for
a short time in the ATA driver.  Drivers were supposed to call diskerr()
to report the disk block number in a uniform way that includes the
subdevice and relative block number.  The ATA driver used to call
diskerr(), but about a year the call was replaced by a printf() that
just gives the absolute LBA as above.  The ATA driver still calls
diskerr() in RELENG_4, but it passes a wrong block number so that
the actual failing block number is even harder to untangle than for
an absolute one (the result is the relative block number doubled
for single 512-block accesses and sometimes a bit less than doubled
for larger accesses).

badsect also has a fairly fundamental limitation to sector numbers
less than 2^31-1, so it will be even less useful when 1TB is a small
disk.

Bruce


More information about the freebsd-fs mailing list