Seven dead SD cards in two years. Here is what finally fixed it
Contents
G'day legends. Went through the shed drawer on the weekend and counted seven dead microSD cards, all out of Pis that run 24/7. The weather station, the chook house door, the Pi-hole, the garage camera. Every one died the same way: fine for months, then one morning it boots read-only or doesn't boot at all.
Parts I use now (AUD, roughly): second hand 120GB SATA SSD ($20 at the tip shop / marketplace), a USB 3 to SATA adapter ($15, see the warning below), the official Pi power supply ($15ish), and for the one Pi that has to stay on SD, a "high endurance" card ($18).
Why they die
Flash wears out with writes. A cheap card has a tiny controller with not much wear levelling, and Raspberry Pi OS out of the box writes a fair bit: journald, swap, apt, plus whatever your own app logs. Then there's the real killer, power. Pull the plug (or cop a brownout in a Brisbane storm) mid-write and you can corrupt the card's own mapping table, not just one file.
What fixed it, most useful first
- Stop booting from SD. Pi 4 and Pi 5 boot from USB no dramas now. Easiest way is
sudo raspi-config→ Advanced Options → Boot Order → USB Boot. If you'd rather see what it's doing,sudo rpi-eeprom-config --editand on a Pi 4 you wantBOOT_ORDER=0xf14(read it right to left: USB, then SD, then start again). - Watch the adapter. Some cheap SATA adapters misbehave with UAS on the Pi and you get random I/O errors under load. Find the ID with
lsusband addusb-storage.quirks=XXXX:YYYY:u(your vendor and product ID) to the front of the single line in/boot/firmware/cmdline.txt. Slower, but stable. Two of my three adapters needed it. - Proper power. Phone chargers droop under load. If
vcgencmd get_throttledgives you anything other thanthrottled=0x0, or dmesg says undervoltage, fix that before you blame anything else. - Log less, and log to RAM. In
/etc/systemd/journald.confsetStorage=volatileandRuntimeMaxUse=30M. You lose logs on reboot, which on a sensor Pi I genuinely don't care about. Turn swap off if you don't need it:sudo dphys-swapfile swapoffthensudo systemctl disable dphys-swapfile. - Read-only root for the ones that matter. raspi-config → Performance Options → Overlay File System. Everything writes to RAM and vanishes on reboot. The weather station has run like this for 14 months without a hiccup. Remember to turn it off before you
apt upgradeor you'll be very confused why nothing stuck (ask me how I know 😅). - If it has to be SD, buy endurance. The cards sold for dashcams. Not magic, but noticeably better wear levelling than the bargain bin.
Pi OS already mounts root with noatime, so that old tip is done for you. Check it if you're on another distro.
Would I do it again?
SSD on everything that runs 24/7: absolutely. The three Pis I moved over in January haven't missed a beat. The Zero 2 W in the letterbox stays on SD because there's nowhere to put an SSD, so it's overlay FS plus an endurance card and I've made my peace with it.
cheers, Matt 🍓
Get the best of #raspberry_pi_lab weekly
One email each Monday with the most useful posts. No spam; unsubscribe in one click.
Comments
Sign in to join the conversation.
Sign in to comment