Burning out SD cards

Hi all, been a while since I have posted here but still running a receiver, it just keeps running EXCEPT…

It seems every 6 months or so I have a power event and the PiAware reboots and fails, further investigation reveals it the SD card giving up (it did fail outright once as well).
Each time a new SD card with a clean image sorts the issue out.

I wasn’t aware there was enough write activity to wear a card out, however that seems to be the case.

So my question is, is there a way of making the SD cards more reliable? I don’t expand the file system after firing it up as 2GB seems to be plenty of space. Would having more accessible capacity reduce the wear?

With the RaspberryPi 4 around the corner I was considering moving to a USB SSD, however I am not convinced the Pi 4’s extra resources will be of much benefit.

1 Like

I have 2 Pis and I always expand file system . Both microSD cards are running 24/7, one for 4 yers now, other for over 3 years now, without fail. Both are 8 Gb, class 10. Both have undergone re-imaging several times.

1 Like

It’s more likely that either your RPi is killing sd-cards or at least corrupting them.
Are the sd-cards actually unusable after that?

What model RPi are you running, i believe the models 2 and 3 kill less sd-cards.

Could also be an issue with the power supply providing unstable power.

1 Like

I am running the latest version of the 3 (B+?).

The cards seem to be dead after that as I can no longer write images to them or format them correctly.

Going to expand my file system too, nothing to loose there…

What cards are you using? It’s possible some are more susceptible than others to power blips.

Regarding expanding the file system, if you build from scratch then Raspbian does it automatically anyway but I don’t think the Piaware image does (at least, it didn’t on earlier versions). When I was using the Piaware image, I always expanded it because there’s no reason to leave that space there unavailable.

If the sd-card has wear leveling it will use the non-expanded part of the sd-card as well.
Don’t think expanding the file system helps in any scenario.

As written above multiple options:

  • sd-card killing power supply
  • sd-card killing RPi
  • low quality sd-cards
  • strange power spikes

For the power spikes you could get a surge protector and hope it helps.
A good quality power supply should already protect from that but most USB power supplies aren’t that good quality.

Current Piaware images do the same thing as Raspbian now (expand on first boot)

That’s really good to know, thanks. Are they a more fuller version of the OS now because from what I remember, the last one I used seemed very cut down, for example it didn’t even have the ifconfig command.

Sometimes after installing dump1090 (fa or mutab), piaware, planefinder, fr24, I make a backup copy of image. To keep the backup image small, I do not expand file system unless I have created the backup.

Is there a way to prevent Raspbian from automatically expanding file system at first boot?

I would assume it’s the same as the Raspbian expand script.

/usr/lib/raspi-config/init_resize.sh

This script avoids being run again by removing itself from the boot commandline:

174 sed -i 's| init=/usr/lib/raspi-config/init_resize\.sh||' /boot/cmdline.txt
175 sed -i 's| sdhci\.debug_quirks2=4||' /boot/cmdline.txt``

So removing that init option from the command line should do the trick.

1 Like

My experience with white / private label SD cards is worse than with genuine / branded SD cards, both in Raspberry Pi’s as in camera’s. I personally prefer SanDisk, which has a good value for money IMHO. Currently in the Pi is the 16 GB SanDisk Ultra C10 (98MB/s) microSD.
On the Pi I use for ADS-B flight tracking, I try to write as little as possible, so I won’t install something like MySQL. I also disabled extensive logging to disk.

1 Like

With those bigger, faster sd-cards which are meant for digital video cameras as well, writing some log files or even database data will usually be nowhere near enough to cause problems due to excessive amount of writes.

It seems they improved the reliability massively.
With action cameras writing ever increasing amounts of data they probably had to improve the reliability for extended use at hot temperatures and lots of writes.

Samsung now also has an “Endurance” micro sd-card in its offers.
Might just be marketing though :slight_smile:

SanDisk has been hit and miss for me on micro SD, very good on standard SD size. Kingston still has a perfect record.

I exclusively use Sandisk and haven’t had a failure. Of course, now I’ve said that, you can guarantee that one will break in the next few days. Unless I make a backup of them all, that will guarantee they’ll work for years!

1 Like

The sdcard images now closely follow Raspbian lite (the images are built with pi-gen with a custom stage to do the piaware bits)

As mentioned above you can tweak the init= arg before first boot.

It may be simpler to just deal with it after the fact though: take the image file, use kpartx to create partition loop devices pointing at the image, run zerofree on the root filesystem, and then compress the resulting image - the extra space on the expanded filesystem will be almost entirely zeros and will compress excellently. This is essentially the same process run as part of building the original image.

2 Likes

Might be simpler for most people to just reduce the partition size with gparted on the sd-card, do a backup and then re-expand it as needed.
Also avoids first writing a 32 GB image file to disk.

1 Like

Thanks @obj and @wiedehopf for the very useful tips.

Is there a simple way to download a mirror of a working SD card via Wi-fi, ready to reimage a card in the event of a failure?