Powered by Drupal

Checking for Bad Blocks on a Hard Drive in Linux

In Fedora, the badblocks program is part of the e2fsprogs program. You probably already have that installed. But in case you don't do the following:

yum install e2fsprogs

To just see the bad blocks the following to do a non-destructive read/write test:

badblocks -nvs /dev/sda

To generate generate a list of the bad blocks do the following:

badblocks -nv /dev/sda > badblocks.txt

Now you can mark the bad blocks found with the following:

e2fsck -l badblocks.txt /dev/sda

If you don't care what's on the drive you can do the following destructive command. It will write different patterns over the drive and read them back in. It does this in four passes with a different pattern each time.

WARNING: This will erase everything you have on drive /dev/sda"!

badblocks -wvs /dev/sda
Category: