Drive Hardware Error Detection

There are many ways of detecting hardware errors with your storage media including SMART status from a device. This page specifically focuses on using a tool to check a device for bad blocks.

Tools to detect bad blocks


Notes specific to using badblocks on a mac OS X system.

OS X specifies the disks within /dev as two different kinds. The first kind (example : /dev/disk1) is a buffered device. The problem with working with a buffered device is in some situations it may be slower, than having direct access to the device. This brings us to the second kind of disk device in OS X a raw disk (example : /dev/rdisk1). Accessing the raw disk will be faster for some operations. In particular when using badblock you will tend to see an improvement by using the raw device rather than the buffered device.

Installing badblocks via HomeBrew :

  1. Download and install brew for Mac OS X.
  2. Install e2fsprogs and the dependencies with brew which will include the badblocks program.
    1. $ brew install e2fsprogs

Example of usage :

  1. Ensure any disk and/or partition(s) on which you are going to check for bad blocks are unmounted
  2. Set the PWD to the the newley installed sbin directory. You may need to select the correct version for your install.
    1. $ cd /usr/local/Cellar/e2fsprogs/1.42.13/sbin
  3. Run bad blocks on your disk device. The -s flag will show progress. Further usage information is available from the man page.
    1. $ sudo ./badblocks -sv /dev/rdisk5



Remember it is always best to have a backup than needing to resort to this kind of tools or approaches for data recovery.