Skip navigation.
Just your average bearded geek

Checking whether a new hard drive is safe under Linux

My 250Gb external hard drive (a Seagate Barraccuda, which I was expecting to last at least for many years) just died a couple of days ago after less than two years of service. No matter the reputation of the manufacturer, hard drive failures can happen any time, so it's better to be prepared and not rely on only one storage for your important data. Fortunately, that was my case and nothing critical has been lost in the process.

Well anyway, now I just bought a new, 500Gb Western Digital Caviar drive, and the first thing I want to be sure about is that it is safe to store things on it. So, before even creating a new partition, let's make a complete surface check with badblocks!

# badblocks -w -v -s -o badblocks.txt /dev/<device>

The -w options tells badblocks to make a write test, which means any data on the drive (including the partition table, since we run it on the whole device) will be erased. Well, in this case it's ok since it's a brand new drive. Badblocks will run several passes on the disk (4 with my version of badblocks) with different patterns. -v asks for a verbose output. Better to know what's going on. -s reports the progress of the test by displaying the amount of blocks checked for each pass, so you can complain about how long it takes. finally, -o specifies an output file where the coordinates of bad blocks should be written (here, badblocks.txt).

Just run this program on your new disk in the morning before going to your job. Chances are that it is over when you are back. Check the badblocks.txt file, which should be empty - if not, return the drive. Finally, check on your system logs that nothing weird happened during the process. Allright, your drive is sane and you can consider using it. Just make sure to have a second copy of important stuff somewhere, as you never know when it will die...