26

I'm running badblocks to check for bad segments on an external drive, and it's been about an hour and it has not yet finished. Now, I need to go and consider cancelling. Is this somehow risky? Should I avoid this?

Clearly, I will need to start again from scratch; I just want to know if this is somehow risky to abort midway.

1 Answer 1

32

From examining the source code, I find that:

If you didn't specify -n or -w, badblocks doesn't write to the disk at all, so you're safe interrupting it.

If you specified -w, badblocks has already overwritten the filesystem, so it's much too late to worry about interrupting the process.

If you specified -n, badblocks uses a signal handler to prevent the program from exiting with the disk in an inconsistent state, so it is safe to press ctrl-c.

4
  • Can there be an inconsistent state if there is no filesystem on the device? I assume that in write mode badblocks would have damaged all filesystem metadata structures already, so is there still room for inconsistency?
    – phunehehe
    Jul 26, 2012 at 6:44
  • 1
    @phunehehe: There may be non-overwritten blocks on the device; but given that badblocks will start at the beginning of the disk, it's a moot point, as there won't be any partition table, thus technically making the disk "unformatted". (An unformatted disk is not required to be filled with zeroes - the content is undefined) Jul 26, 2012 at 8:38
  • But I supposed that means there is no risk of inconsistency? Because everything is basically gone already.
    – phunehehe
    Jul 26, 2012 at 9:02
  • Is this correct also when badblocks is used by calling e2fsck -cc? From man page: "If any bad blocks are found, they are added to the bad block inode to prevent them from being allocated to a file or directory." and "If this option is specified twice, then the bad block scan will be done using a non-destructive read-write test."
    – lumbric
    Jun 24, 2018 at 19:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .