0

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

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

So as far as I understand, those tools only test space assigned to partition, not whole disk. Is there any way to test whole disk?

2

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).

| improve this answer | |
  • I get badblocks invalid starting block (0) error on this. Found on internet its due I did not supply partition. – Gacek Jan 19 at 15:23
  • @Gacek Just omit the first_block argument. badblocks will start from the beginning of the disk by default. – mosvy Jan 19 at 15:26
  • 2
    @Gacek It's not mentioned anywhere in the badblocks manpage that it only works with partitions, but not full disks. With that being said, I would not rely on badblocks: I just run it on an old broken disk both in its read-only and in its read/write mode and it was NOT able to find any bad blocks; but running an actual OS on it failed almost immediately -- it probably has to do with the real-life access pattern which badblocks doesn't try to emulate. – mosvy Jan 19 at 15:32
  • 1
    Modern drives hide badblocks. I thought you need to ask SMART, to tell you the health of the device. Does badblocks talk to SMART? – ctrl-alt-delor Jan 19 at 18:15
  • 1
    @ctrl-alt-delor they hide them up to a point — a failed block will still cause read errors. badblocks doesn’t talk to SMART. – Stephen Kitt Jan 19 at 19:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.