0

I have a setup where a Raspberry Pi will be used in a headless mode, inside a model. The model will be used during the day, and then plugged out at night. Since I won't be there when it is in use, I can't guarantee that it will be shut down safely. How likely is it that there will be an problem?

There will be a web server and a python script powering the GPIO pins running on the Pi that will startup when it is pluggged in, in case that changes the situation.

Strawhare
  • 103
  • 2
  • 1
    A quick perusal of this site or the raspberrypi.org forums will show you that unsafe shutdown is one of the major causes of SD card corruption - which can lead to data loss and the Pi failing to boot. Why unplug it? The Pi consumes very little electricity some back of the envelope calculations can be seen at the following http://raspberrypi.stackexchange.com/questions/5033/how-much-energy-does-the-raspberry-pi-consume-in-a-day and https://www.raspberrypi.org/forums/viewtopic.php?t=18043. Compare that against the cost to replace an SD card, system downtime, your time to fix any problems. – Steve Robillard Jul 31 '15 at 09:05
  • If the switch off is outside your control you could minimise the risk of failure by writing as little as possble to the SD card, preferably nothing. For instance I switch off as much logging as I can in /etc/rsyslog.conf by using the rule "\*.\* ~" – joan Jul 31 '15 at 11:33
  • "then plugged out at night". If the display closes at 5, and the janitor yanks on the plug at say 5:15 (or whatever), why not set the RPi to automatically shutdown at 5pm? – Jacobm001 Jul 31 '15 at 21:25

2 Answers2

1

How likely is it that there will be an problem?

If the system is idle, most likely it won't be a problem. An unclean power-off is like rolling dice -- snake eyes and you lose. But most of the time you won't. So if you are asking, "Is there a way I can guarantee this is okay?", the answer is no (but see the final paragraph, below). If you are asking "Is this worth the risk?" when it sounds like you don't have a choice, the answer is if you don't have a choice then it is a risk you will have to take.

In ideal terms, I do not believe the pi is any more prone to corrupting a filesystem when the power is cut than a normal computer, and the same factors apply: If the system is very busy at the time, the chance of corruption is greater. I say "in ideal terms" because I think if some of the power problems associated with the pi contribute to corruption, then the story may get a little different. The solution to that presuming there's not also some quality control issue, is to use a proper power supply.

I have not done a formal survey, but I think reports of problematic corruption have diminished a bit this year. There's then this issue to consider, which I have not investigated further. It's no longer an issue and may never have been (but it may also have been very significant).

Note that the kernel bug issue doesn't depend on cutting the power and the insufficient power/possibly defective hardware issue probably doesn't either, meaning that might have been coincidentally blamed in a lot of the cases online.

You might be interested in this recent answer from someone who claims to be involved with some decent scale commercial application where they cut the power all the time and have not had any problems. This hints at the fact that people who don't have a problem will not post a Q&A online, "Everything worked fine again today: Why?".

If feasible, using read-only filesystems should (again: in "ideal terms"1) eliminate the risk. But this may be another thing about which you don't have a choice.


1. We've had at least a few people here report corruption when killing the power even with a read-only filesystem, which should not happen. This implies a hardware or software defect, as outlined above, is responsible in some cases, which will probably never affect most people.

goldilocks
  • 56,430
  • 17
  • 109
  • 217
  • This is a very clear and detailed answer. The `Is this worth the risk?` you described is the major factor of decision. Our Pi's are Terminators, end-points showing information, they're not generating any important information. We deploy a new SD card with 10 keystrokes. If the Pi blows up, we replace it within 1 minute. And then Murphy's law works in reverse: thousands of hard unplugs and not a single issue. – EDP Jul 31 '15 at 14:24
  • I don't think I can really make it read only, I have a web interface communicating with a Python script, so I'll have to figure out the logistics of setting it to turn off automatically like @Jacobm001 suggested. Thanks lads, great answer. – Strawhare Aug 04 '15 at 07:58
0

The rpi is likely to survive powerloss (99/100 times?)

The rpi is more susceptible than normal computers.

the problem was really bad for the first year until a firmware update stabilized it. (it would even die under high cpu load)

Using a read only or journaled file system would be enough on a normal computer but the rpi sdcard is still more susceptible so keep stuff on usb and it should be ok.

user1133275
  • 2,167
  • 12
  • 30