I am working on a project that will use a Raspberry Pi or similar as an IOT device and am concerned about the life and reliability of the SD Card. I hope other users will post their experiences for everyone’s benefit. The two most common issues I have read about are corruption of the card and wearing out the card by writing to it too often. There are probably other issues I have yet to consider.
Corrupt Cards. Many internet postings complain about corrupt SD cards that won’t boot. I read one warning that removing or inserting an SD card while the device is powered up will corrupt the card. Are there other ways too?
Worn Out. A high frequency of IOT loggings and a high number of devices being logged could wear out an SD drive before the intended life of the product. Here are a few ideas to extend that life:
Use a bigger SD card. Some sites say the Raspberry Pi is limited to 32 GB. This site lists cards up to 512 GB that are reported to work in a PI.
Always use transactions to avoid individual writes to disk.
Consider using a ramdisk or in-memory SQLite database. Also consider what happens if there is a power failure.
Send everything to the cloud instead of storing it locally.
Add storage with a USB flash drive.
Please post your good and bad experiences with SD cards and any other issues that may affect them.
SD cards like all memory cards wear out after a while. nature of the media.
inserting/removing SD cards while the device is on, will corrupt the filesystem on the SD card. just like inserting/removing a HardDrive in your computer while you are using it. Just a bad idea. PIs take like 10 seconds to boot (didnt time it but that is roughly how long it takes). So just power it off before swapping cards.
newer versions of the firmware on the PI and newer O/Ses support larger SD cards. I have only dealt with 64GB or less (most of the time 16GB). never needed a bigger one (to date).
minimizing the reads/writes to the SD card will make it last longer but dont going insane to avoid doing IOs. Reads dont affect the longevity as much as Writes, but both will wear the media out eventually. I have a few PIs that are still running after 2 years on the original SD cards. now those are not IO intensive apps.
storing the “data” on an USB drive will just move the media issue from the SD cards to the USB drive. now if you boot off SD card and store all your data on the USB, when the USB fails, the system will still boot but wont have data. both USB & SD cards are memory based media.
as for RAMdisk option, you will need to eventually write the data to disk or you will lose it when the system reboots.
cloud options are always an option. but depending on where you are sending/reading the data to/from, the latency might be brutal to your app. so if it is reading from another computer on the same local network, you should be fine. should is the key word as we dont know your app or how it uses the data. now going across the internet to some cloud service, makes it “less good” for your app as the latency is going to be much higher. I cant say good or bad, again as I dont know your app.
Another point to consider is the SD card speed class.
This is number and image is shown on each SD card. I have found that the minimum should be a Speed class 10, UHS Class 1, or a Video speed class V10, which are all supposed to be at a minimum of 10 MB/second. Faster is better in this case, especially if there are graphics or timing of electrical communication is critical. If there are threads then the Raspberry Pi could have very poor performance.
Here is a link to some common manufacturers, if they have errors (red colour) and some helpful descriptions. SD Card Performance
As Scott mentioned, I would also suggest getting a name-brand SD card, and have a higher transfer rate speed card.
I routinely use 128G SD cards. Only the best, class 10 and Sandisk.
The device should be fully powered down before removing. Powering down does not mean removing power, but actually shutting down the system (raspberrian) before removing power or the SD Card. If the OS is running and/or the device is powered, it can corrupt the whole SD Card. This is due to the SD Card itself reading/writing/moving data around itself, even when not being written to or read from, by the OS.
I use a push switch that one of my apps watch. When it sees it depressed for a period of time, it launches a script to power down the Pi. After the Pi is powered down it is safe to remove the power from the device and/or the SD Card.
First of all, You have to think that a corrupted SD cards is something unavoidable at some point, so you have to desing your software considering this.
As any PC, the raspberry must be shut off by the OS. If you just pull the plug, there is a chance that the card get corrupted.
That is not as important as many say. The SD cards have countermeasures, and tries to distribute the writes in the whole card.
I have 60 Rasp working 24/7 for almost 2 years, and a peak of 60 database search and write each day. All with 16gb SDHC/SDXC UHS-I ADATA CLASS 10 and only 5 corrupted cards. Even considering lots of power losses.
the write issue and corruption in my case was solved by using a ramdisk for logging and DietPi as the OS which is a small footprint OS that works well for me, it is a fork of the official raspbian, i have an image that is about 1.2Gb on the running card.
power supply is most definitely very important for reliable operation, although this is unlikely to cause any corruption, it can stop boot up or high CPU operation.
a class 10 card will be noticeably faster in use in my experience than a cheap card and more reliable.
for power failure i use a mini ups i designed that has super capacitors to allow SD card writes before close down.
If reliability is important and the project can stand some additional cost, have a look at the Up board Far more robust and powerful than the Pi, in pretty much the same form factor, for about $120. Boots from onboard eMMC instead of SD card. Built-in RTC, runs Windows 10, etc. Produced by Aaeon, so well-funded.
If anyone has had the same experience as I’ve had with SD cards on rPI’s, then, like me, you’ll probably never trust them again. I used all the name brand SD cards, and the best I could get was maybe 10 system boots before they became corrupted and unbootable. And yes, I did a proper system shutdown, every time, before I turned off the power. I realize that my experience was worse than most. I was never able to nail down a reason for the problem other than the possibility that my rPi was just far enough off spec in one particular parameter to cause the problem. However, the simple fact is that SD cards were never intended for this kind of service. So, I would definitely check out the non-SD options mentioned by Julia and Ivan. Frankly, after all this time, I’m amazed that rPi’s still rely on SD cards for their mass storage.