1

There are a number of Questions/Answers about safely shutting down a Pi which offer conflicting advice on shutdown and poweroff.

What are the pro/cons of these methods.

1 Answer 1

3

shutdown and poweroff use the same code and have similar options, but poweroff causes the activity LED to flash 10 times at 1 second intervals on shutdown, shutdown schedules a shutdown at a given time (default 1 minute).
The flash 10 times is an indicator that shutdown has successfully completed and it is safe to remove power.
It is difficult to determine with shutdown as the Pi often continues to run for some time unless the -f option is used.
I use the dtparam=act_led_trigger=heartbeat to show if Pi is running.

(The Pi400 has internal power management circuitry and a power button so the following does not fully apply.)


I have a file .bash_aliases which contains the following to provide alias to common commands:-

alias update='sudo apt update'
alias updates='apt list --upgradable'
alias upgrade='sudo apt full-upgrade -y'
alias reboot='history -w && sudo reboot -f'
alias halt='sudo poweroff -f'

I use commands reboot or halt.

The first 3 are just single word shortcuts for common operations.

The reboot & halt needs some explanation;
history -w forces recent history to be written to .bash_history otherwise recent command history may be lost;
sudo reboot -f or sudo poweroff -f results in an immediate but clean shutdown by the system. The system will not wait for services to stop. Shutdown delays are occasionally caused by running services e.g. pigpiod can delay shutdown.


It is simple to connect a pushbutton to the GPIO pins to perform a clean poweroff. See https://raspberrypi.stackexchange.com/a/42945/8697

I have it on all my Pi in case I need to shutdown a headless Pi (or one without keyboard attached), although my Pi are rarely shutdown, unless I am adding hardware.

dtoverlay -h gpio-shutdown will display the latest help.

I use dtoverlay=gpio-shutdown,gpio_pin=21 so I can shutdown by bridging pins 39/40

NOTE After shutdown, the system can be powered up again by driving GPIO3 low. The default configuration uses GPIO3 with a pullup, so if you connect a button between GPIO3 and GND (pin 5 and 6 on the 40-pin header), you get a shutdown and power-up button.

Your Answer

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

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