tool for mapping away bad blocks on an external disk

Warren Block wblock at wonkity.com
Sun Apr 17 16:33:43 UTC 2016


On Sun, 17 Apr 2016, Steve O'Hara-Smith wrote:

> On Sun, 17 Apr 2016 09:26:41 +0200
> Matthias Apitz <guru at unixarea.de> wrote:
>
>>
>> Hello,
>>
>> I have an older external disk, connected through USB, which has bad
>> blocks:
>
> 	The tool you're looking for is badsect - I'm moderately surprised
> it's still around, the last time I used it was on FreeBSD 1.1.5.1 but it is
> still in FreeBSD 10.3.
>
> 	It doesn't do the analysis though - you'll have to do that with the
> filesystem unmounted and just used dd conv=noerror if=<device> of=/dev/null
> to read the whole device and pull the duff sectors out of the error
> messages.

That won't remap them, though.

> 	However it's been a *long* time since this was worth doing except
> perhaps as a last ditch data recovery exercise, drives have had internal
> sector remapping for a long time now and when that stops working they are
> well and truly banjaxed.

True.  But this is not (yet :) a data recovery problem, just a desire to 
make the disk usable again.  Bad blocks are only remapped on a write. 
I think that a SMART long test (smartctl -tlong) writes every block 
and will do remapping as a side effect, but have not verified it.

The even more brute-force method would be to just manually write every 
block on the disk with dd.  A bs= of 64K or 128K or more will help speed 
that up.  Retries on bad writes might slow it down again.

The drive could use up all available spares during that process, or 
continue to grow new bad blocks.  That makes the decision to scrap it 
easy.  If it successfully maps out the bad blocks and does not appear to 
be creating new ones, then using it becomes a judgement call.  As they 
say, choose wisely.


More information about the freebsd-questions mailing list