Page 1 of 1
how to turn it off?
Posted: Thu Feb 20, 2020 8:38 pm
by RPIZW
Hi all,
I've seen this question before when I tried to search, but not sure what is the solution.
I understand that it's not recommended to just unplug RPI from the power.. however, what is the other option if it's stuck?
what is the recommended 'hard' but safe poweroff/restart?
Thanks.
Re: how to turn it off?
Posted: Thu Feb 20, 2020 8:46 pm
by DougieLawson
If you RPi is completely unresponsive and the green LED is not winking then pulling the power isn't going to do anything bad (and is your only option).
Occasionally I've found that it will set the "dirty bit" on the /boot partition and refuse to boot. But I just stuff the SDCard in a USB reader and insert that in another RPi. It's simple to run fsck -f -y /dev/sdbX for each partition on the SDCard before swapping it back to the original system and booting normally.
Re: how to turn it off?
Posted: Thu Feb 20, 2020 9:02 pm
by LTolledo
RPIZW wrote:
I understand that it's not recommended to just unplug RPI from the power.. however, what is the other option if it's stuck?
what is the recommended 'hard' but safe poweroff/restart?
how about cutting off from the mains breaker supplying power to the AC socket powering the PSU of the RPi...
Re: how to turn it off?
Posted: Thu Feb 20, 2020 9:35 pm
by jahboater
Is it really "stuck"?
Perhaps try Ctrl-Alt-F1 (or F2 or F3 ...)
It just might come up with a cleared screen and a login prompt.
Then its easy to sync and shut it down cleanly.
However, as noted above, if its really crashed, then there is no possibility of an orderly shutdown (saving anything that's in memory), so just switch it off.
The default commit interval for the main ext4 partition is every five seconds, and ext4 has a journal, so a crash or power outage has a good chance of being recoverable.
Re: how to turn it off?
Posted: Fri Feb 21, 2020 3:52 pm
by RPIZW
The scenario is this
my RPI is connected without HDMI - it's only had power and wifi so I can connect remotely.
sometimes I can't get access to it using SSH and it's not very easy for me to connect it with HDMI and keyboard as it's not located next to a TV
Re: how to turn it off?
Posted: Fri Feb 21, 2020 5:31 pm
by ejolson
RPIZW wrote: ↑Fri Feb 21, 2020 3:52 pm
The scenario is this
my RPI is connected without HDMI - it's only had power and wifi so I can connect remotely.
sometimes I can't get access to it using SSH and it's not very easy for me to connect it with HDMI and keyboard as it's not located next to a TV
Since WiFi can lose connection while the rest of the Pi is still working, you could
- Create a script to automatically reset the WiFi interface if it goes down.
- Add a switch with the GPIO and use it to signal shutdown.
Note, there are tutorials how to connect a switch to GPIO without destroying your Pi. Please find one and understand it before proceeding along that route.
Re: how to turn it off?
Posted: Fri Feb 21, 2020 6:09 pm
by Heater
I think you should investigate the watchdog capability on the Pi.
Assume anything can fail at any time. Due to your software bugs, network interruptions, even bugs in the OS or drivers or device firmwares.
At the end of the day if the thing you need to be running is not working you need to reboot the whole machine.
Which is what the Pi SoC hardware watchdog is all about.
In extreme cases I have found that even a software reboot whilst powered up is not enough to clear a fault. In that case you need an external hardware watchdog that can cycle power to the machine and thus reset whatever hardware is playing up.
Re: how to turn it off?
Posted: Fri Feb 21, 2020 6:24 pm
by ejolson
Heater wrote: ↑Fri Feb 21, 2020 6:09 pm
Assume anything can fail at any time. Due to your software bugs, network interruptions, even bugs in the OS or drivers or device firmwares.
Keeping WiFi working seems particularly troublesome with the Pi. If there are not enough packets regularly traveling back and forth, the WiFi radio appears to switch into power saving mode. At this point packets routed through the access point can no longer can reach the Pi. In turn, some access points appear to forget the cryptographic secret. Then, even if the WiFi interface on the Pi leaves low power mode, there is no connection.
One solution, out of desperation, is to create a ridiculous keep-alive process on the Pi that sends packets to and fro (like Nagios) and thereby prevents the WiFi radio from entering low-power mode.
Re: how to turn it off?
Posted: Fri Feb 21, 2020 6:45 pm
by Heater
Nagios and such are very useful.
But it goes like this:
1) I have a bug in my application and it crashes. That is OK systemd can restart it again.
2) I have a bug in my application and it hangs in a loop. Hmm... now I need nagios or some such to check it is still responding and restart it if not.
3) There is a bug in the OS or drivers I depend on such that communication fails. Hmm... now I need nagios or something to reboot the machine and get the OS and drivers working again.
4) Some weird event locks up the hardware of a WiFi chip or whatever. Hmm... now I need a power cycle to unstick that hardware. I have seen this happen.
5) My hardware actually fails permanently and nothing can make it work again. Hmm... now I need a multiple redundant system with other hardware that can continue the work.
How far up this chain of failure one wants to protect oneself against is a value judgement.
Re: how to turn it off?
Posted: Sat Feb 22, 2020 1:43 pm
by RPIZW
Thanks for the advice!

I’ll check now for watchdog and gpio switch