Subject: Re: Seeking the truth about bad sectors
To: None <netbsd-users@netbsd.org>
From: Manuel Bouyer <bouyer@antioche.eu.org>
List: netbsd-users
Date: 11/14/2001 20:41:56
On Wed, Nov 14, 2001 at 06:43:23AM +0000, Jim Breton wrote:
> What is the story with scanning/re-mapping bad sectors on IDE drives?
> 
> I have done Google searches, asked on IRC, read various web pages.. and
> I get conflicting views and explanations making it difficult to
> determine which to trust as correct.
> 
> First, I should mention that I started my *nix experience on Linux.
> Linux has a "badblocks" tool which can scan a drive for bad sectors, and
> handle the re-mapping for you.  I have used this with success in the
> past, after suffering some drive problems it did correctly identify and
> deal with the issue.

I think this is a software remapping, not hardware.
If I understood things properly, and IDE drive will remap a bad block
when trying to write it.

> 
> On NetBSD (i386) I see the bad144 and badsect tools; however, neither of
> these appears to do an actual _scan_ of a device for bad blocks.  It

No, you need to know the address of the block you want to remap.

> looks to me like the assumption is being made that the IDE controller
> (or drive?) will handle the detection and re-mapping of the sectors.  Is
> this the case?

For write, yes. 

> 
> However, is there really such a guarantee, even with fairly modern IDE
> drives?  i.e., is there really no way for bad sectors to develop and go
> undetected by the hardware?  If so, why do Linux and Windows include
> utilities to perform such a scan anytime you want?  And why do Linux's

With with automatic bad block remapping you have a problem when you have
no free spare block. In this case the hardware will start reporting
the bad block to the driver.
The idea is that when a disk has developed enouth bad blocks to fill the
remapping table, then it's time to remplace it.

> "badblocks" and Win's scandisk find bad blocks at all, if this is
> handled in hardware transparent to the OS?  (And to add to the
> confusion, badblocks's man page also says that IDE drives will handle
> this in hardware.)
> 
> Also, what would one do on SCSI devices?

SCSI disks can also do bad block mapping automatically, but this can be
disabled. You can then use a scsi command to manually remap a block.
See scsictl(8).

--
Manuel Bouyer <bouyer@antioche.eu.org>
--