badblocks

Oliver Fromme olli at lurza.secnetix.de
Tue Aug 16 15:26:53 GMT 2005


Matthias Buelow <mkb at incubus.de> wrote:
 > Augusto Cesar Castoldi wrote:
 > > is therer any application similar to badblocks of linux on freebsd?
 > 
 > badsect(8)
 > 
 > > How can I check and mark bad blocks of HD's ?
 > 
 > But normally modern drives do that by themselves (and transparently
 > remap them). If the filesystem starts complaining about bad blocks
 > (that is, hard read/write errors), that means the on-disk bad sector
 > list is full and it's probably time to buy a new drive.

That's not completely true.

The transparent remapping feature only works when sectors
are being written to.  When you read from a file and get
a read error, nothing will be rewritten and you you keep
getting the same error.

To force the drive to remap the bad sectors, you have to
write to them.  If the bad sectors are inside a file, it
might work to overwrite the file.  Otherwise you have to
extract the sector numbers from syslog and use dd(1) to
overwrite them on the raw device, followed by fsck.  Of
course it is always a good idea to make a complete backup
(if possible) before.  If you have a good backup, you can
also simply overwrite the whole disk with dd (and then use
fdisk, disklabel, newfs as usual and restore from your
backup).

Note that remapping has to be enabled.  For SCSI disks, the
camcontrol(8) manpage contains an example for that.  Also
note that some drives don't remap bad sectors, no matter
what you do.

In any case:  If the drive is used to store important or
valuable data, then it should be replaced when read errors
occur, no matter whether remapping the bad sectors works
or not, because it is quite possible that further sectors
will be damaged.

Just my 2 Euro cents.

Best regards
   Oliver

-- 
Oliver Fromme,  secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing
Any opinions expressed in this message may be personal to the author
and may not necessarily reflect the opinions of secnetix in any way.

"With sufficient thrust, pigs fly just fine.  However, this
is not necessarily a good idea.  It is hard to be sure where
they are going to land, and it could be dangerous sitting
under them as they fly overhead." -- RFC 1925


More information about the freebsd-stable mailing list