Avoiding bad sectors?

Daniel Eriksson daniel_k_eriksson at telia.com
Sun Aug 20 14:07:13 UTC 2006

First thing you should do is run a SMART selftest on the device using

smartctl -t long /dev/adX

Poll the status of the selftest using:

smartctl -a /dev/adX

until the selftest has finished (an hour or two) or aborted. This can be
done while in multiuser mode, but beware that disc accesses will be
slower than usual.

If you want to "fix" the problem and avoid downtime, then move swap to
another slice (possibly an inode-backed md device, if that is possible)
and fill the bad slice using 'dd'. Not sure if taking the data from
/dev/random instead of /dev/zero makes any difference, but it will not
hurt you other than by adding some time to the operation.

Once you've written to the bad slice you probably want to re-run the
SMART selftest to make sure it passes without any more failures.

/Daniel Eriksson

More information about the freebsd-current mailing list