This command:
badblocks -svn /dev/sda
What does it do? Does it just report the bad blocks? Or does it somehow handle the bad blocks so that I don't need to be worried about them?
I read the manual by man badblocks
, but I don't get the -n
option:
-s Show the progress of the scan by writing out rough percentage completion of
the current badblocks pass over the disk. Note that badblocks may do multiple
test passes over the disk, in particular if the -p or -w option is requested
by the user.
-v Verbose mode. Will write the number of read errors, write errors and data-
corruptions to stderr.
-n Use non-destructive read-write mode. By default only a non-destructive read-
only test is done. This option must not be combined with the -w option, as
they are mutually exclusive.
The output of running badblocks -svn /dev/sda
which lasted for almost two days:
Update
Some posts suggest that after running badblocks -svn /dev/sda
, the hard disk controller would take care of bad blocks. Not sure.
to have the hard disk controller replace bad blocks by spare blocks.
https://askubuntu.com/a/490552/507217
If you have fully processed your disk this way, the disk controller should have replaced all bad blocks by working ones and the reallocated count will be increased in the SMART log.
https://askubuntu.com/a/490549/507217
SMART
I checked the SMART table after running the badblocks
command by:
smartctl --all /dev/sda
Note that Current_Pending_Sector
raw value is 56
. It's twice the 28
reported by badblocks
. Maybe they are related.
Error interpretation
According to this:
How to interpret badblocks output
badblocks
error log is in the form of reading/writing/comparing
. In my case, all of 28
errors are reading errors. Meaning no application can read those blocks.
OS logs
I looked at OS logs by sudo journalctl -xe
. Actually, SMART is throwing errors about those 56
bad sectors (28
bad blocks):
smartd[1243]: Device: /dev/sda [SAT], 56 Currently unreadable (pending) sectors
Conclusion
I'd rather backup the data and replace the hard disk before it's too late.
...to reallocate a faulty block...
, does it mean I don't need to be worried about the bad blocks anymore? They won't be a trouble-maker in the future, right? – Megidd Dec 21 '21 at 10:04badblocks -svn
to report a bad block? I haven’t checked, but I imagine that if it fails the read before the test write, then presumably nothing is written, so blocks which can’t be read aren’t reallocated either, and they will still cause trouble in the future. – Stephen Kitt Dec 21 '21 at 10:06badblocks
code, the first step is to read, and if the read fails, the test data isn’t written; so it’s not true that all blocks end up written. With the non-destructive test, a block will be flagged as bad if it fails to read, or if it fails the write test (write test data, read it back and compare). In the former case, the disk won’t have a chance to reallocate it (but that’s standard practice for failing disks — never overwrite data you care about, on the off-chance that a read will succeed at some point). – Stephen Kitt Dec 21 '21 at 11:47badblocks
writes the original data back, failures are actually ignored AFAICT... – Stephen Kitt Dec 21 '21 at 12:15badblocks -n
can't well write to blocks it can't read, since it wouldn't know what to write there... A rewrite with random data would turn a known error into just random invalid data with no way to identify it as such. If you decide to discard any data on the drive, you can still use the list of blocks printed to overwrite and reallocate just those. (In which case you'll hope you'd just done a destructive write test in the first place, since it'd have been faster. But you had no way of knowing.) – ilkkachu Dec 21 '21 at 12:28