Checking a harddrive for bad sectors on Ubuntu/Debian

As I was cleaning up my old stash of hardware, I found some harddrives. Of course, I needed to test these before I'd sell them. This is extremely easy in linux! The badblocks program will test your harddrive for, you guessed it, bad blocks. The badblocks program is part of the e2fsprogs package, which is installed by default in almost all GNU/Linux distributions. To check your harddrive for bad blocks, use the following command:

badblocks -n -v /dev/sdx

where /dev/sdx is the device name of your harddrive. That command will perform a non-destructive read-write test on your harddrive, meaning that it will first read an amount of data from your harddrive and then attempt to write it back. It will do this with every byte of your harddrive.

The runtime for this program is pretty high, as it is very I/O intensive.

Written by Jannich Brendle tir 17 august 2010 In How to