Hard Disk Check – How to Find Errors and Bad Sectors

badblockshard-disk

I may be misunderstanding some concepts here, but as far as I know, each disk has a partition table and actual partitions.

I'm looking to test a hard drive for bad sectors and errors, but the tools I found to do this are meant for partitions — not disks. badblocks takes a partition /dev/sda1 not /dev/sda. Same story with e2fsck.

As far as I understand, those tools only test space assigned to partitions, not a whole disk. Is there any way to test an entire disk?

Best Answer

Is there any way to test whole disk?

Yes, using badblocks:

badblocks /dev/sda

The manpage refers to partitions because badblocks can tell mkfs.ext2 about the bad blocks it finds, and that only works when checking partitions. But badblocks itself works fine on full disks.

However badblocks is really a relic of a bygone era when hard drives didn’t manage their bad blocks themselves. Nowadays drives track errors themselves and are capable of remapping bad sectors as circumstances allow (typically, when a bad sector is rewritten). You’re probably better off running SMART tests and checking the results:

smartctl -t long /dev/sda
smartctl -t offline /dev/sda
smartctl -x /dev/sda

(make sure each test completes before running the next one).

Related Question