How to test newly bought hard drive using badblocks on Linux
Caution: these steps will delete all the data in the selected partition of hard drive.
Understand the following command:
sudo = root permission
badblocks = testing program on Linux
-b = block size, 4096 is preferable for external hdd which is more than 2TB
-wsv = write & then read test, with response.
/dev/sdX = drive location which you can find from Disk program (you can change into your particular drive eg: sdb. Please make sure to select the correct drive or lose data)
-t = test type (eg: 0xaa, 0x55, 0xff, 0x00)
-o = output file to a specific location
Last two numbers = range of block to be tested, eg: from #1 to #400000000. Beware, the range is in reversed order.
Open the terminal, you can start input your command, for example:
sudo badblocks -b 4096 -wsv /dev/sdX -t 0x55 -o /mnt/1BE48F33510B4128/output.txt 400000000 1
An error-free result will look like the following:
Testing with pattern 0xaa: sdone
Reading and comparing: done
Testing with pattern 0x55: done
Reading and comparing: done
Testing with pattern 0xff: done
Reading and comparing: done
Testing with pattern 0x00: done
Reading and comparing: done