I can't find anything about what badblocks actually considers a bad block. I've read the man page and looked at a bunch of questions on here, but I can't find specifics. Also, how good is badblocks? Should I trust it's results? My company historically used Victoria on Hirens Boot CD to test hard disks, but that isn't always a good option on newer computers.
badblocks reads, and writes, and compares (not necessarily in that order).
badblocks -v will output messages like:
Pass completed, n bad blocks found (x/y/z errors)
Which means it found
n bad blocks, consisting of
x read errors,
y write errors and
z corruption errors. It considers read errors and write errors as they occured while reading and writing (as reported by the kernel). These errors can also be caused due to cable / controller / driver problems.
A corruption error is where data was compared and found to be different than expected (i.e. the data it read deviated from previously known/written data). In particular
badblocks might write various data patterns (specified by one or more
-t pattern options) and check if each pattern was written correctly.
It's possible to get false positives for corruption errors, if you have another program doing their own writes while
badblocks is running. If another program writes, the disk is behaving correctly, but
badblocks won't know about that, it just sees what it considers the wrong data.
Which is also why you should never run
badblocks on a drive that is in use, on a drive that already has a filesystem that could be mounted automatically without you knowing, or on drives you already suspect are bad but you still wish to recover your data.
In terms of data recovery, you should always go with
ddrescue instead of
ddrescue does very much the same thing
badblocks (read mode) does, it reads the entire drive and logs down the sectors it couldn't read; but at the same time it produces a useful copy, whereas
badblocks just discards the data entirely.
Is it trustworthy?
badblocks is a tool like any other, it does exactly what it says in the manpage - search a device for bad blocks. It may or may not be the right tool for whatever it is you want to do.
In the wrong hands, it might be the cause of data corruption. The so called
non-destructive mode is a false friend and does not imply safety for your data at all.
badblocks (write mode) is primarily useful to put a new, empty drive through the wringer before trusting it with data.
For a read only test, it's usually better to go with SMART selftests (
smartctl -t long or
smartctl -t select). Safer than
badblocks and friendly to other I/O.