I know there are a few debates about SD card corruption, but nothing is good enough for me.

In the beginning there was no problem with the SD cards, but lately it happened a lot after power failure.

Is there any way to reduce that? What exactly is the cause of that problem? Is there any data to check, what destroys the SD card? It is interesting, because a lot of things are OK, but there is no way to read /home/ or /var/, and the /etc/ssh directory is empty.

There is a python application that receives a lot of messages. Maybe less logging to the FS from the application? In the beginning there was less of the logging.

One possible solution is a UPS, but problem is, that it is sometimes necessary to unplug the power to restart device.

Is there a device, that can signal the Raspberry Pi to gracefully shutdown?

  • Note that power failure is not the same thing as a SD card wearing out over time. A power failure could stop the processor in the middle of writing to the card. As such, the card could still be operational but the partition table, file system or files contained within, might not. However, writing to the SD card repeatedly can wear out the electronics. Check your card specs for details, but I believe it's roughly 100000 writes until they start to wear out. Data corruption is not the same as hardware malfunction.
    – Statement
    Nov 19, 2015 at 20:49
  • To safely turn off device running raspbian, halt the os. type sudo halt, wait for the system to enter an endless loop and pull the cable.
    – Statement
    Nov 19, 2015 at 20:50
  • SD cards are subject to power-loss corruption not only at the filesystem level, but also at the flash translation level contained inside and not exposed via the sd interface, which can be performing houskeeping writes even when the filesystem is not. Nov 20, 2015 at 17:17
  • Checkout github.com/azlux/log2ram. It moves /var/log/ to ram to help reduce disk usage
    – zaforic
    Dec 19, 2019 at 16:12

3 Answers 3


In my experience, the only major corruptions I've had is from power problems. The best solution is to use a UPS. If you need to turn off the device, you should be issuing the command sudo shutdown now -h before you unplug it.

A standard UPS should run something as small as the RPi for a significant length of time. Long enough that I doubt a signal mechanism would be necessary. If you want something like that though, a popular hat tailor made for the RPi exists.


Any raspberry pi users would have faced this problem at-least once in a while. And after such situation I had to reinstall rasbian loosing all my previous setups, scripts etc. Then i started using some tools like testdisk to recover files on the sd card. But still i had to reinstall the os. But sometimes using fsck you don’t need to reinstall the os again(i love both these tools). May be this might be usefull for some people (https://raymii.org/s/blog/Broken_Corrupted_Raspberry_Pi_SD_Card.html)

My present Pi setup is as follows: I use a mi 10400mah powerbank to power up my pi. Since this powerbank can be charged and be used at the same time i chose this one in particular. Later, I hooked an IR receiver to the GPIO and programmed a remote that was lying around doing nothing. With the help of LIRC i was able to identify the remote control's individual buttons. Then i wrote some shell scripts on the pi like shutdown, reboot, kill something etc and linked each scripts to each buttons(its just a configuration file that can be edited). So when there is a power problem at the mains, my powerbank will be backing up. And mean while i will shutdown my pi using the IR remote control.

Just a thought: I had another idea while i was working with IR remote, but haven’t got much time to play around, may be you can implement it if you can(if it doesn’t sounds bad).

Build a sensor that detects current flow(something like how an ammeter works) and connect it to the wire from mains to the powerbank. If ther is a power shutdown at the mains, then using an arduino or the very same pi sensing it to shutdown(Just a thought... ).


Have a look at Nard SDK if you need a robust system. It uses the SD-card only during boot. When startup has finished you can remove the SD-card at it will continue to operate just fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.