RPIZW
Posts: 63
Joined: Sat Sep 28, 2019 5:54 pm

how to turn it off?

Thu Feb 20, 2020 8:38 pm

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.

User avatar
DougieLawson
Posts: 39121
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: how to turn it off?

Thu Feb 20, 2020 8:46 pm

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.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

LTolledo
Posts: 3430
Joined: Sat Mar 17, 2018 7:29 am
Location: Anime Heartland

Re: how to turn it off?

Thu Feb 20, 2020 9:02 pm

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...
"Don't come to me with 'issues' for I don't know how to deal with those
Come to me with 'problems' and I'll help you find solutions"

Some people be like:
"Help me! Am drowning! But dont you dare touch me nor come near me!"

jahboater
Posts: 5759
Joined: Wed Feb 04, 2015 6:38 pm
Location: West Dorset

Re: how to turn it off?

Thu Feb 20, 2020 9:35 pm

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.
Pi4 8GB running PIOS64

RPIZW
Posts: 63
Joined: Sat Sep 28, 2019 5:54 pm

Re: how to turn it off?

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

ejolson
Posts: 5375
Joined: Tue Mar 18, 2014 11:47 am

Re: how to turn it off?

Fri Feb 21, 2020 5:31 pm

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.

Heater
Posts: 15949
Joined: Tue Jul 17, 2012 3:02 pm

Re: how to turn it off?

Fri Feb 21, 2020 6:09 pm

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.
Memory in C++ is a leaky abstraction .

ejolson
Posts: 5375
Joined: Tue Mar 18, 2014 11:47 am

Re: how to turn it off?

Fri Feb 21, 2020 6:24 pm

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.

Heater
Posts: 15949
Joined: Tue Jul 17, 2012 3:02 pm

Re: how to turn it off?

Fri Feb 21, 2020 6:45 pm

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.
Memory in C++ is a leaky abstraction .

RPIZW
Posts: 63
Joined: Sat Sep 28, 2019 5:54 pm

Re: how to turn it off?

Sat Feb 22, 2020 1:43 pm

Thanks for the advice! :)
I’ll check now for watchdog and gpio switch

Return to “General discussion”