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

From: Wes Janzen
Date: Tue Oct 14 2003 - 02:05:08 EST




Rogier Wolff wrote:

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.

Can't you pretty much get the drive to check itself using smartctl, such as running:
smartctl -o on -s on -S on /dev/hde &> /dev/null
in an init script? Also, I think if you just happen to write to a bad sector the drive will remap it without a warning (unless it doesn't have any remapping sectors left), but if you read from it then to get the drive to "notice" it, you have to write back to that sector. Or run the drive test which should find it and correct it.



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.

I think he's using reiserfs on the partition, which ASFAIK doesn't support marking bad sectors without some work. I tend to agree with namesys when they suggest just getting a new drive if it has used up all of its extra sectors. In my experience (admittedly limited), any drive which runs out of extra sectors starts to go bad in a hurry.

-Wes-

Roger.


-
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/