Raspberry Pi And The Story Of SD Card Corruption
Tales of Raspberry Pi SD card corruption are available online by the fistful; and are definitely a constant in Pi-adjacent communities. It’s apparent that some kind of problems tend to arise when a Raspberry Pi meets an SD card; which sounds quite ironic, since an SD card is the official and recommended way of booting a Pi. What is up with all of that?
Over the years, a devoted base of Pi SD card haters has grown. Their demand has been simple – Raspberry Pi has to get an ability to boot from something else; in large part because of corruption reasons, but also undeniably because of speed and capacity/cost limitations of SD cards. Thanks to their demands and work, we’ve seen a series of projects grow from unofficial efforts and hacks into officially supported Raspberry Pi abilities; USB boot being initially more of a workaround but now something you can enable out of the box; SSD-equipped Pi enclosures becoming more of a norm, and now, NVMe boot appearing on the horizon. Every few years, we get a new way to boot a Pi.
SHOULD YOU DITCH SD CARDS?
I’d like to make it clear; booting from an SSD or USB drive is a very nice option; and when you want your Pi to be fast, responsive, and reliable, you can absolutely try it. The SD card slot has stayed after all this time; is not about to disappear, and neither will all the SD cards in our drawers. Should you personally ditch SD cards? The answer is more likely to be “no” than “yes”.
Not everyone encounters SD card problems, with SD card images being the first thing available whenever you see a cool new project, and an SD-equipped Pi still a staple of an average maker contraption. Proponents of USB and network boot also cite improved latency for Pi-as-desktop usage, easier Pi management in case of network boot, and these alone are good reasons – but definitely not for every project out there. SD cards remain the simplest and cheapest option to boot a Pi.
You cannot always avoid SD card boot either. Booting a Pi Zero from an USB stick requires that you either waste your only USB port or add an entire USB hub into the mix, complicating the setup further, adding pesky cables and failure points. When it comes to portable and battery-powered devices built with a Pi, an SD card is hard to beat in terms of power consumption – USB flash drives aren’t known for being low-power-optimized, and neither are USB hubs, which you’ll notice if you check how warm a USB hub IC can get after passing a relatively low amount of USB packets.
In the end, even the most devoted external SSD booting enthusiasts might still want to add an SD card for the independent additional storage that it brings. The slot is there, and if you have a card to spare – why not use it? Unless you encounter problems, that is – so let’s go through those.
WHY DO CARDS STILL FAIL?
First of all, fake and cheap cards ruin the fun for everyone. MicroSD card clones are ever-present and hard to distinguish from legitimately made cards, but certainly not subject to the same quality standards. Cheap cards share the “low quality standards” part, but at least, you can recognize a no-name card by looking at it. Neither fake nor cheap cards are typically suitable for an entire OS to run from. They will not only make your Pi behave way more sluggishly than it actually can run, but will also result in mysterious failures and, later on, pretty explicit corruption. Getting decent cards from reputable places is part of a recipe for a calm Pi exploration journey, and nowadays, it doesn’t even really break the bank anymore, given the hefty amount of storage that you get for your money.
IT IS NOW SAFE TO TURN OFF YOUR SBC
This is the rationale behind “shutting down your Pi safely” aka “running poweroff
before unplugging power” talking point – if you don’t give your SD card a bit of time and maybe even an automated advance notification from the OS, there might be pending write operations that will never get completed, resulting in garbled storage when you next power up the card. Some seasoned engineers claim that such shutdowns are eventually guaranteed to irreversibly break an average SD card long-term, due to how the cards work internally, and I wouldn’t argue with them on that.
Read more: https://hackaday.com/2022/03/09/raspberry-pi-and-the-story-of-sd-card-corruption/