Badblocks is a program that is capable of scanning disk blocks for bad sector. This section guides you on how to setup and use badblocks in Linux OS.
badblocks is available in the upstream. To install it, simply use the following command:
$ apt install badblocks -yBefore going straight for badblocks scanning, you should umount all the partition (you shouldn't mount a suspicious disk anyway).
Now that you're done, you may proceed to scan for bad blocks. The command is as follow:
badblocks -v <partition> > badsectors.txt 2> badsectors.logExample:
badblocks -v /dev/sdb3 > badsectors.txt 2> badsectors.logThis will generate 2 files:
badsectors.txt - holding all the bad sectors ID.badsectors.log - holding the text output and report of the scan.If you have any numbers in badsectors.txt , that disk is having bad sectors.
That's all for badblocks scanning.