Corruption of memory card

My experience of early RaspberryPi based systems is that the memory card is easily corrupted if the system is not powered down properly before being turned off, for example, as the result of a power failure. This makes me reluctant to use any Pi-based system in an embedded environment and to prefer Arduino based systems which are much more robust in this regard, despite the limitations in computing power.

My question(s) to the community is(are) - have others experienced this issue? Is there something different about later Pi designs that solves this problem? Is there anything that others have done to fix the problem?

Many thanks in advance for any responses.


Richard - I have not experienced this issue but because of many odd issues I was experiencing (slowdowns, etc) a SD Card corruption was suspected.

I booted a Raspberry Pi with a different SD card running the standard Jessie image, plugged the suspect SD card into a USB SD card reader and then ran the fsck command to check for errors or issues.

[email protected]:~ $ sudo fsck /dev/sda1
fsck from util-linux 2.25.2
fsck.fat 3.0.27 (2014-11-12)
/dev/sda1: 109 files, 2628/7673 clusters
[email protected]:~ $ sudo fsck /dev/sda2
fsck from util-linux 2.25.2
e2fsck 1.42.12 (29-Aug-2014)
/dev/sda2: clean, 88877/216384 files, 482830/894720 blocks
[email protected]:~ $ sudo fsck /dev/sda3
fsck from util-linux 2.25.2
e2fsck 1.42.12 (29-Aug-2014)
/dev/sda3: clean, 12520/1021832 files, 863292/4066304 blocks
[email protected]:~ $


All of the partitions (3 for me) came back clean.

I don’t know if this is the only way to check the SD card, but it might help.

Many thanks for the tip Jon

The Arduino’s are still better for small embedded repetitive jobs predominantly because they do not have an OS, just firmware, simpler and more reliable.

But having said that the SD card tech has got better and the Pi software has got better so there has been a marked improvement since the Pi’s launch. the wear on SD 's is done by excessive writes and a majority of the damage to corrupt cards is due to a power interuption during a write cycle.

This project optimizes sd card life by reducing writes to disc using RAM to buffer data and performing fewer writes, the OS is also adapted to operate Read-only so that all but essental writes are eliminated to reduce the odds of the OS being in a write cycle when power is removed. It isn’t absolutely safe (few things are!) but for many, it is no longer a real concern.

You can take further steps like using a usb stick in place of the data partition, that pretty much make the whole sdcard read-only and only the usb stick is at risk of power related corruption. Or you can even put the whole filesystem and data on a small spinning disk hdd and reduce the risk even further.

Many thanks Paul. That answers the question in depth. I much appreciate it.

Our emonSD pre-built SD card for our raspberryPi base stations (emonPi / emonSD) have got the root file-system setup to run in the read-only mode with log files going to a ram disk and a carefully controlled R/W data partition. Since moving to this setup we have not ha any reports of SD cards corrupting. I’ve had cards running for over 2-3 years and counting.

See build guide for info on how exactly our emonSD card is built (based on Jessie): emonpi/ at master · openenergymonitor/emonpi · GitHub

Thank you Glyn. That is very helpful to know. My concern arose from a ‘Squirrel Cam’ project I did with a Pi and a webcam about 3 years ago which kept crashing and corrupting the card. I can see that you, however, have the issue fully under control.

1 Like

Which, IIRC, you wrote a small script to achieve (can’t find the right post)?