SD card corruption

From: mike tancsa <mike_at_sentex.net>
Date: Thu, 13 Jul 2023 15:33:08 UTC
TL;DR. We get batches of cards that suddenly fail with SD card wide file 
corruption out of the blue.


A little background.  We have APUs (PCEngines) in the field that work 
REALLY well for reliability.  However, the odd time that things go 
south, its due to SD cards.  I had a couple of devices last week fail 
after about a year and when I got them back both had hundreds of fsck 
errors. These are devices that stay mounted Read Only so there are no 
writes to them. Even on the second partition of the nanobsd image which 
was never mounted had many fsck errors.  Normally we use SanDisk but had 
to switch to some PNY due to supply chain issues.  The PNY seem to be 
more failure prone than the SanDisk, but we do get the odd SanDisk too 
with the same pathology.

Once I get the bad SD card back, I can newfs it and all is fine. e.g. I 
can fill the disk with 16GB of /dev/urandom files and the hashes all 
match over time.

Is it just bad hardware / bad luck that is causing these seemingly 
catastrophic failures or are there things that should be done in the 
field to extend the life of SD cards ?

Is there any way to predict these failures in advance ?

If I newfs -E (does the -E make a difference?) the unused partition and 
then re-write it with the live image and then boot to the new partition, 
does that buy my any longevity ?

     ---Mike