-1

man badblocks says:

   -n     Use non-destructive read-write mode.

This answer says:

The non-destructive read-write test works by overwriting data, then reading to verify, and then writing the original data back afterwards.

Is there any way to allow for recovery should badblocks be interrupted (eg kernel hang) during or after writing the test data but before it has written back the original data?

Tom Hale
  • 30,455
  • 1
    I don't think there's any way. I may be wrong, but it looks like badblocks is simply saving the original data into a memory buffer, not anywhere on another disk/partition from where it could be restored in the case of a SIGKILL or kernel hang. –  Feb 12 '19 at 10:46

2 Answers2

1

File systems protect data from a crash with journals, checksums, mirrors, etc. The only option I see for badblocks would be to re-compile it with an option to store the read buffer (and location) on disk, but this would make the tool much slower (and would be bad for a NMVe life if one tried to speed it up that way). The better alternative is to use a filesystem to handle it for you; btrfs and zfs are here for you.

user1133275
  • 5,574
  • btrfs's scrub will only do a read test. I'm assuming that badblocks has two (generally) non-destructive tests (read and re-write) for good reason. – Tom Hale Feb 13 '19 at 06:04
0

Given there doesn't seem to be a way to recover from an interrupted badblocks -n:

  • I run it only on a disk set with filesystem-level redundancy
  • I trust the filesystem can recover should one set of blocks under test be lost
Tom Hale
  • 30,455