badblocks: Check your hard drive for bad sectors

Sprache ändern:

lrg tango drive hard disk badblocks: Check your hard drive for bad sectors We are living in a time where the quality of hard drives has been drastically decreased. The Vendors are struggling to improve the the capacity what is leading to ECC-Errors. Also the vulnerability for bad blocks has increased. Its no wonder that in one of my PCs an old IDE Spinpoint F1 by Samsung is doing its work while i already had to replace 3 drives within 2 years in my NAS. Because of the dead sectors.

Such dead sectors are blocks on the surface of an hard drive which are not writable due to physical damages. Facing bad blocks can be the sentence of death  for a RAID Array.

But how can we be sure that an hard drive is healthy?

On the one hand there is SMART, which provides various quick checks for the drive but according to studies it is not that meaningful.

If you want to be confident you need to check block by block without leaving one out.

For doing so i am using ‘badblocks’ – Badblocks can check destructive (meaning all data will be lost) or non-destructive. The advantage over the non-destructive mode is that the check will be done ten times faster using the destructive mode. Besides you can also load the check result of badblocks into fsck, which will mark the block as faulty on the filesystem to prevent further writes on them.

Destructive Mode

Warning: Using that mode your data will be wiped!

badblocks -wsv -o foo.badblocks /dev/sdX
  • This line starts an check for /dev/sdX.
  • -w is the destructive Mode.
  • -s shows an progressbar (e.g.: 12.16% done, 35:46 elapsed).
  • -v like always this is for ‘verbose’ whereby found bad blocks will be print to stdin.
  • -o provides the path for an output file (i used foo.badblock here). It can be loaded by fsck.

Because all data will be wiped by this mode its suitable for checking new hard drives or those where the data is not needed anymore.

Non-Destructive Mode

That mode is absolutely harmless and no data will be lost.

badblocks -nsv -o foo.badblocks /dev/sdX
  • This line starts an check for /dev/sdX.
  • -n is the non-destructive mode.
  • -s shows an progressbar (e.g.: 12.16% done, 35:46 elapsed).
  • -v like always this is for ‘verbose’ whereby found bad blocks will be print to stdin.
  • -o provides the path for an output file (i used foo.badblock here). It can be loaded by fsck.

This mode is suitable when there is a suspicion for bad blocks (e.g because S.M.A.R.T reported them). The found dead sectors can be marked as faulty by fsck which will lead to an consistent device again. But keep in mind: bad blocks are spreading.

You can tell fsck to mark the found bad blocks as faulty by running:

fsck -l foo.badblocks /dev/sdX

The executing of badblocks can take a long time. The faster destructive mode took 48 hours for an 2TB drive during my investigations.

Leave a Reply

Connect with:

Your email address will not be published.


7 + 6 =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>