66

The man pages for badblocks do not seem to mention what the three numbers in the output mean in particular:

Pass completed, 7 bad blocks found (7/0/0 errors)
Pass completed, 120 bad blocks found (0/0/120 errors)

I'm guessing it's "Errors while reading/writing/comparing". Can someone enlighten me?

Tomalak
  • 1,069

2 Answers2

69

Your guess is correct.

The source code looks like this:

if (v_flag)
    fprintf(stderr,
            _("Pass completed, %u bad blocks found. (%d/%d/%d errors)\n"),
            bb_count, num_read_errors, num_write_errors, num_corruption_errors);

So its read/write/corruption errors. And corruption means comparison with previously written data:

if (t_flag) {
    /* test the comparison between all the
       blocks successfully read  */
    int i;
    for (i = 0; i < got; ++i)
        if (memcmp (blkbuf+i*block_size,
            blkbuf+blocks_at_once*block_size,
            block_size))
            bb_count += bb_output(currently_testing + i, CORRUPTION_ERROR);
}
frostschutz
  • 48,978
  • Perfect. Looking it up in the source the one thing that should have occurred to me, but somehow it didn't. Thanks. :) – Tomalak Feb 19 '13 at 16:52
  • Of course that's also the reason why there are no kernel error messages in the (0/0/120 errors) case. – Tomalak Feb 19 '13 at 16:59
  • 1
    A possible cause for corruption errors is that something else wrote to the disk while badblocks was running, in which case it wouldn't be an error at all (other than user error). – frostschutz Feb 20 '13 at 22:31
  • In this case it's a suspect disk that I'm using exclusively with badblocks. No other process writes to it. Is there a way to visualize the output file with the bad sector list, short of manually calculating their position? – Tomalak Feb 21 '13 at 08:18
  • When you paste source code from a program like this you should cite the source code (version or date, github or git repo url, filename, line numbers). This would help us look at it later, verify it, gain additional context and insight, etc, without having to redo the work of finding it. – Gabriel Staples Aug 08 '20 at 06:28
  • 1
    @GabrielStaples source: badblocks. file name: badblocks.c version: any since Feb '11 - now ;-) github.com/tytso/e2fsprogs@89d459 – frostschutz Aug 08 '20 at 07:40
-13

Wrong. If badblocks says anything that isn't "no errors found", it means:

  • Turn off the machine immediately
  • Get a replacement disk
  • Pray to $GOD_OF_BACKUPS important data is safe
  • Do whatever is needed to set up the new disk, and copy the data from the old one

You may optionally keep the disk around for entertainment, or as a paperweight.

(Modern disks have a set of extra cylinders for remapping bad blocks, as there is no way to manufacture disks without them, and users screamed bloody hell when they saw the bad block list. If bad blocks do show up, it means that that space is used up. As the common failure modes of rotating disks give exponentially increasing number of bad blocks, seeing some means that the disk typically has a few hours left.)

vonbrand
  • 18,253
  • 17
    That wasn't even the question. – Tomalak Feb 20 '13 at 07:37
  • 2
    Never run badblocks on a disk that has important data on it. If the disk has an error, badblocks may cause extra damage even in nondestructive write mode, if it can't write the original data back due to the error. – frostschutz Feb 20 '13 at 22:29
  • @frostschutz, The -n test is supposed to be read-only? – vonbrand Feb 20 '13 at 22:32
  • 5
    No, -n is nondestructive write. So it writes, but restores the original data after testing. Which may fail due to errors. For readonly badblocks, I believe you use no option at all. – frostschutz Feb 20 '13 at 22:36
  • 2
    Not bad advice, but does not fit the question. You could have made a Q&A style answer out of it. – neverMind9 Mar 17 '19 at 22:38
  • I think this answer may contain accurate information in some circumstances, but not all. For example, I have a disk which badblocks has found both read and write errors, but SMART attributes say I still have space for additional reallocated sectors. – pcronin Apr 28 '21 at 15:07
  • 1
    If the drive is a USB-connected one you need to think about the voltage it is seeing instead of 5.0. Long cables, not enough powered hubs, dirty connectors can be factors and will cause intermittent unreliable behavior. – Alan Corey Dec 21 '21 at 17:08