2

I have a Raspberry Pi (running Raspbian) that is booting from a microSD card. Since it's acting as a home server, naturally I want to monitor the microSD card for errors. Unfortunately though, microSD cards don't support SMART like other disks I have, so I am unsure how to monitor the disk for errors.

How can I monitor / check disks that do not support SMART for errors when they are still in use / have partitions mounted?

1 Answer 1

1

You can replace smartctl -t long selftests with badblocks (no parameters). It performs a simple read-only test. You can run it while filesystems are mounted. (Do NOT use the so-called non-destructive write test).

# badblocks -v /dev/loop0
Checking blocks 0 to 1048575
Checking for bad blocks (read-only test): done
Pass completed, 0 bad blocks found. (0/0/0 errors)

Note you should only use this if you don't already suspect there are bad sectors; if you already know it's going bad, use ddrescue instead. (badblocks throws away all data it reads, ddrescue makes a copy that may come in useful later).

Other than that, you can do things that SMART doesn't do: use a checksumming filesystem, or dm-integrity layer, or backups & compare, to actually verify contents. Lacking those, just run regular filesystem checks.

MicroSD cards also have failure modes that are hard to detect. Some cards may eventually discard writes and keep returning old data on reads. Even simple checksums might not be enough here - if the card happens to return both older data and older checksums, it might still match even if it's the wrong data...

Then there are fake capacity cards that just lose data once you've written too much. Neither return any read or write errors, and it can't be detected with badblocks, not even in its destructive write mode (since the pattern it writes are repetitive).

For this you need a test that uses non-repetitive patterns, e.g. by putting an encryption layer on it (badblocks write on LUKS detects fake capacity cards when badblocks write on raw device does not).

2
  • Thanks for the detailed advice! badblocks sounds like the way to go then, I guess. I already check for fake capacity cards with f3*, so I'm not concerned about that, but I can't seem to find much about dm-integrity. Do you have any resources about it? Jan 5, 2020 at 15:58
  • 2
    man integritysetup (part of cryptsetup, you can also cryptsetup LUKS2 with --integrity). I recommend you test that first on an unrelated machine/storage before putting your microsd to the task... Jan 5, 2020 at 19:28

You must log in to answer this question.

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