Joan M
Posts: 7
Joined: Sat Oct 21, 2017 11:02 am

Worried with power outages and abrupt power loss

Mon Dec 31, 2018 2:53 pm

Hi all,

I want to use a Raspberry Pi 3 B+ to monitor several sensors and show some counters in a big TV that will be placed at 3 meters height.

That Pi won't have any keyboard neither a mouse connected.

I want to be able to remove power to shut it down.

My Questions are:

1. USB DRIVE SAFER THAN SDCARD?
I know that I can corrupt the SDCard and therefore have problems if I remove power without shutting the OS down before. Some IT guy has told me that if I use a USB drive to boot from that risk is eliminated and that I can remove power directly.

Is that right? from my point of view that has no sense, but it's worth asking it here where the real experts in Pi are.

2. APC UPS SYSTEM?
I can put an APC UPS system to power the raspberry and put a selector that removes power from the UPS system... If I do this I'll get the APC ups shutting down the PI and then shutting down itself... That would keep the Pi safe.


That APC UPS would be connected to a USB port of the Pi.

3. ANY OTHER OPTION?
I want it to be able to shut down properly in case of a power loss.

Thank you very much!

pfletch101
Posts: 336
Joined: Sat Feb 24, 2018 4:09 am

Re: Worried with power outages and abrupt power loss

Mon Dec 31, 2018 3:46 pm

Joan M wrote:
Mon Dec 31, 2018 2:53 pm
Hi all,

I want to use a Raspberry Pi 3 B+ to monitor several sensors and show some counters in a big TV that will be placed at 3 meters height.

That Pi won't have any keyboard neither a mouse connected.

I want to be able to remove power to shut it down.

My Questions are:

1. USB DRIVE SAFER THAN SDCARD?
I know that I can corrupt the SDCard and therefore have problems if I remove power without shutting the OS down before. Some IT guy has told me that if I use a USB drive to boot from that risk is eliminated and that I can remove power directly.

Is that right? from my point of view that has no sense, but it's worth asking it here where the real experts in Pi are.
It is never a good idea to shut a computer down by turning off the power, unless it is specifically designed to tolerate this (i.e. runs from a readonly file system and does not write to any files other than 'throwaway' temporary ones on a ramdisk). SD Cards are particularly prone to problems if powered off while (or very shortly after) being written to, but files written on any storage device can end up corrupted and/or unreadable if write operations are not completed properly before the device is powered down. If you are only interested in displaying current data, and are not planning to store anything (or are storing what you need to store remotely), there are a number of ways of setting Raspbian up to boot from an SD card but run with a readonly file system.
2. APC UPS SYSTEM?
I can put an APC UPS system to power the raspberry and put a selector that removes power from the UPS system... If I do this I'll get the APC ups shutting down the PI and then shutting down itself... That would keep the Pi safe.

That APC UPS would be connected to a USB port of the Pi.
That would certainly work, but is a more expensive and space-occupying option, and also depends on no-one deciding to turn off the UPS from its power switch, if it is within reach, and/or requires the installation of a shelf or something similar to support the UPS if it is right next to the TV.
3. ANY OTHER OPTION?
I want it to be able to shut down properly in case of a power loss.
There are some specifically Pi-oriented mini-UPSes available, but they are not hugely cheaper than the smaller APC models.

Joan M
Posts: 7
Joined: Sat Oct 21, 2017 11:02 am

Re: Worried with power outages and abrupt power loss

Tue Jan 01, 2019 10:50 am

Hi pfletch101,

The readonly option seems great, in my case this would make it even better than any other option.

I had discarded this option in the past as there were plenty of people telling me that was not possible in a Raspberry PI Linux based OS.

Do you know of any reliable link where I can get information about how to make the file system readonly?

In my case I'll need X11 graphical interface... is that possible if I'm using that?

I could even put an usb drive to store data if I needed it, but the OS, software developed... would always remain there without issues.

Thank you very much!

User avatar
neilgl
Posts: 371
Joined: Sun Jan 26, 2014 8:36 pm
Location: Near Aston Martin factory

Re: Worried with power outages and abrupt power loss

Tue Jan 01, 2019 3:18 pm

Ah what is the reason we need to shut down by removing power? Could we not do a normal shutdown via a remote login or other means? e.g. I stand in the room and use my phone to shutdown the pi3 over wifi

pfletch101
Posts: 336
Joined: Sat Feb 24, 2018 4:09 am

Re: Worried with power outages and abrupt power loss

Tue Jan 01, 2019 4:10 pm

Joan M wrote:
Tue Jan 01, 2019 10:50 am
Hi pfletch101,

The readonly option seems great, in my case this would make it even better than any other option.

I had discarded this option in the past as there were plenty of people telling me that was not possible in a Raspberry PI Linux based OS.

Do you know of any reliable link where I can get information about how to make the file system readonly?

In my case I'll need X11 graphical interface... is that possible if I'm using that?

I could even put an usb drive to store data if I needed it, but the OS, software developed... would always remain there without issues.

Thank you very much!
People are certainly using Raspbian with readonly file systems. See, for example viewtopic.php?f=63&t=161416 and https://yagrebu.net/unix/rpi-overlay.md. The thread in the first link starts in 2012, but most of the last two pages are relevant to the current (Stretch) Raspbian version. However, as far as I can tell, the setups discussed are all based on the Lite version of Raspbian, without a gui. Memory limitations may preclude your desired setup with X11, but advising you on that is well above my pay grade! :) Some of the published descriptions do, indeed, include the use of separate, read/write, devices to store data.

pfletch101
Posts: 336
Joined: Sat Feb 24, 2018 4:09 am

Re: Worried with power outages and abrupt power loss

Tue Jan 01, 2019 4:16 pm

neilgl wrote:
Tue Jan 01, 2019 3:18 pm
Ah what is the reason we need to shut down by removing power? Could we not do a normal shutdown via a remote login or other means? e.g. I stand in the room and use my phone to shutdown the pi3 over wifi
The problem is usually not the owner/administrator of the system not being able to shut it down properly, but protecting a system being used in a public or semi-public place from others who either cannot (don't have or otherwise need the credentials for access to it) or will not do so. There is (generally speaking) no need for a readonly file system on a Pi to which only the owner has access, but this is not the only use case for the device.

Joan M
Posts: 7
Joined: Sat Oct 21, 2017 11:02 am

Re: Worried with power outages and abrupt power loss

Tue Jan 01, 2019 6:51 pm

neilgl wrote:
Tue Jan 01, 2019 3:18 pm
Ah what is the reason we need to shut down by removing power? Could we not do a normal shutdown via a remote login or other means? e.g. I stand in the room and use my phone to shutdown the pi3 over wifi
This is a closed system: a TV will show data, and the Pi will gather that data.
No keyboard, no mouse, no touch screen, no wifi, no LAN... Only plant operators that will shut the system down once they end they job.
even I could connect the Pi to a WiFi, the operators would not do it... not always at least, and I would still have problems if there is a power outage.

Then I have two options:

- Protecting the file system from being corrupt making it read only (what would be the best from my point of view).
- Use an UPS that protects the system.

PiBurner
Posts: 15
Joined: Wed Mar 23, 2016 2:34 pm

Re: Worried with power outages and abrupt power loss

Thu Jan 03, 2019 8:54 pm

Perhaps a 'shutdown' script ("shutdown now" or such) that runs when a pair of GPIO pins are closed?
Still, you would need to remove all power and apply again to restart.

User avatar
Imperf3kt
Posts: 1785
Joined: Tue Jun 20, 2017 12:16 am
Location: Australia

Re: Worried with power outages and abrupt power loss

Thu Jan 03, 2019 9:01 pm

PiBurner wrote:
Thu Jan 03, 2019 8:54 pm
Perhaps a 'shutdown' script ("shutdown now" or such) that runs when a pair of GPIO pins are closed?
Still, you would need to remove all power and apply again to restart.
There is a set of pinholes you can add a reset switch to so you can avoid that. Be careful to not short it to the wrong pin (ground only) as the Pi3B+ and Pi3A+ have global_en beside the pin, and other models have ground.
Google is ubiquitous - learn to use it!
https://opensource.com/life/16/10/how-ask-technical-questions

epoch1970
Posts: 2276
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Worried with power outages and abrupt power loss

Thu Jan 03, 2019 9:24 pm

Joan M wrote:
Tue Jan 01, 2019 6:51 pm
Only plant operators that will shut the system down once they end they job.
Power the Pi from the TV so that the Pi will start afresh every morning when the guys power up the screen.
Install piCore on an SD, set it to use X11, install your custom programs, set piCore to run entirely off RAM (cf the strangely named copy2fs option).

Assuming the X11 packages are sufficient for your needs (never used X on piCore) and the whole stack can run in 1GB, you’ll get a working system which uses the SD/USB only during boot.
This reduces the window for system corruption to about 30 seconds per session, if power is cut during boot.

I’ve used TCE/piCore for a couple of years, and I have yet to see a case of system corruption.
Very rugged and repeatable platform (and full Pi hardware support)
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Return to “Advanced users”