Hard Disk Drives under Linux
useful oneliners
check for bad sectors
Since badblocks was originally written to verify floppy disks, its design isn’t construed for modern HDD drives. With sizes such as 18 TB drives, even the regular tip to use -b 4096 won’t help anymore. This is an alternative: Span a crypto layer above the device:3
# cryptsetup open /dev/device name --type plain --cipher aes-xts-plain64
Fill the now opened decrypted layer with zeroes, which get written as encrypted data:
# shred -v -n 0 -z /dev/mapper/name
Compare fresh zeroes with the decrypted layer:
# cmp -b /dev/zero /dev/mapper/name
If it just stops with a message about end of file, the drive is fine. This method is also way faster than badblocks even with a single pass.4