Check hard disk for Bad Sectors by command-line in Ubuntu, Linux Mint, and elementary OS

Step 1: Next, let’s find if there are any Bad Sectors on the hard disk. We shall use badblocks command. Make sure to enter your hard disk info instead of /dev/sda in below command. My test PC has /dev/sda for the hard disk. This command will scan for bad blocks in the hard disk and then export the result to the file badsectors.txt in the ‘scan_result’ directory.

sudo badblocks -v /dev/sda > /scan_result/badsectors.txt

Step 2: Finally we shall use fsck command to tell Ubuntu not to use the bad sectors mentioned in the badsectors.txt file. That way life of the hard disk is increased a bit until you get a new one for replacement.

sudo fsck -l /scan_result/badsectors.txt /dev/sda

Source: Check hard disk for Bad Sectors by command-line in Ubuntu, Linux Mint, and elementary OS | FOSS Linux

Check hard disk for Bad Sectors by command-line in Ubuntu, Linux Mint, and elementary OS was last modified: November 18th, 2018 by Jovan Stosic