How to know if you have bad sectors on your hard drive in Ubuntu Desktop and how to fix them. You can use badblock program to fix this problem. The badblocks is program command line based allow to test your harddrive for, you guessed it, bad blocks.
To check your harddrive for bad blocks, open the terminal type following command:
badblocks -v /dev/sdax
You can redirect result of this search to a file also.
badblocks -v /dev/sdax > bad-blocks-result
After executing the above command it will generate the file bad-blocks-result in the current directory . Now, you can pass this file to the fsck command to record these bad blocks.
fsck -t ext4 -l bad-blocks-result /dev/sdax
If badblocks reports a block that was already used, e2fsck will try to move the block to another place. If the block was really bad, not just marginal, the contents of the file may be corrupted.