Check Hard drive for bad sectors or bad blocks in linux

Step:1 Use fdisk command to identify your hard drive info
# sudo fdisk -l

Step:2 Scan your hard drive for Bad Sectors or Bad Blocks

# sudo badblocks -v /dev/sdb > /tmp/bad-blocks.txt

Just replace “/dev/sdb” with your own hard disk / partition. When we execute above command a text file “bad-blocks” will be created under /tmp , which will contains all bad blocks.
Step:3 Inform OS not to use bad blocks for storing data

Once the scanning is completed , if the bad sectors are reported , then use file “bad-blocks.txt” with e2fsck command and force OS not to use these bad blocks for storing data.

# sudo e2fsck -l /tmp/bad-blocks.txt /dev/sdb

Note : Before running e2fsck command , you just make sure the drive is not mounted.

For any futher help on badblocks & e2fsck command , read their man page

Bad Behavior has blocked 109 access attempts in the last 7 days.