How can I check the health condition of an SD card?
When I want to check a hard drive, I can use SMART, how should I check an SD card? Is there a universal approach?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
(Old question, but useful info for those searching)
If you want to fully test an SD card (destructively) you can check the entire data space with the F3 tools which have been ported to Linux
They let you write a variety of patterns to the disk and then check to see if there are any failures.
You could also use badblocks, but badblocks uses repeating patterns that counterfeit scam SD cards will often still pass (cards that have less than advertised space, a common issue with online purchased cards), F3 specifically looks for these kinds of issues and is free.
It's slow, and it completely rewrites your card (or at least fills up the empty space if you just want to test that), but it's fairly comprehensive.
SD cards are pretty much the worst kind of flash storage. They're fine for cameras that do large linear reads and writes to FAT format cards, and don't overwrite the same spot very often, but they wear out very quickly of you try to put a rootfs on them. I have a very unhappy card in a dev board to prove it.
I don't know of a way to monitor the card, but in my experience it'll be the files you use most that die first. On my card it was the apt files under /var (the ones that get updated every day) that developed faults.
If you need to use flash storage, USB drives are a faster and more reliable option.
EDIT: If you want to check a cards current state, plain old
fsck is certainly a good start. Do not be tempted to do any sort of bad-blocks scan though as you'll only wear the card out sooner.
I answered a similar question on superuser here.
In brief: I personally use the non well known software named F3.
Also take into account that *not all USB SD cards readers can read correctly "big" SD cards:
If you try to read a SDXC card on a card reader that can only read SDHC cards, you'll not be able to read correctly all card data, and that can look like data corruption.