Re: Why are bad disk sectors numbered strangely, and what happens to them?

From: Rogier Wolff
Date: Tue Oct 14 2003 - 01:52:09 EST


On Mon, Oct 13, 2003 at 07:24:00PM +0900, Norman Diamond wrote:
> John Bradford replied to me:
>
> > > How can I tell Linux to read every sector in the partition? Oh, I might
> > > know this one,
> > > dd if=/dev/hda8 of=/dev/null
> > > I want to make sure that the drive is now using a non-defective
> > > replacement sector.
> >
> > A read won't necessarily do that. You might have to write to a
> > defective sector to force re-allocation.
>
> I agree, we are not sure if a read will do that. That is the reason why two
> of my preceding questions were:

I've seen a disk (which now failed and will be replaced 3 hours from now)
remap defective sectors without reporting any errors to the OS.
The SMART "remapped sector count" just went up, but no errors in the
logs. So apparently, the disk noticed something and remapped teh sector
without anybody noticing.

> How can I find out which file contains the bad sector? I would like to
> try to recreate the file from a source of good data.

Try:
tar cf - / | dd of=/dev/null

(note some people will try to abbreviate that to
tar cf /dev/null /
but that won't work: Tar will recognise that it's writing to /dev/null
and skip reading the files! That's a bug in tar in my book. )

> How can I tell Linux to mark the sector as bad, knowing the LBA sector
> number?

man tune2fs .

You have to do the math on the LBA sector numbers (subtract the
partition start, divide by two).

Also, you can use the "badblocks" program.

Roger.
--
** R.E.Wolff@xxxxxxxxxxxx ** http://www.BitWizard.nl/ ** +31-15-2600998 **
*-- BitWizard writes Linux device drivers for any device you may have! --*
**** "Linux is like a wigwam - no windows, no gates, apache inside!" ****
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/