To the original question "shutdown" vs. "poweroff": As the names imply, "shutdown" ends in something like "cli(); while(1);" while "poweroff" communicates somehow with the power supply before ending execution in a similar or same loop like "shutdown".
(Only for the case that there is a problem with the power supply.)
In case of Raspberry Pi, by default, it is the same. However, there is a standard kernel overlay available, which can be loaded by modifying /boot/config.txt:
dtoverlay = gpio-poweroff
which changes (by default) GPIO26 (Pin 37) to an Output driving High.
As this pin is not used by default, and unused pins are inputs without pullup/pulldown, a simple circuitry can cut power supply at High level.
Note (for the designer of circuitry): This pin will revert to Low after power cut, of course! So use a flipflop.
As the overlay name "gpio-poweroff" should imply, it is called (somehow by systemd) on "poweroff", not on "shutdown" or "halt".
poweroff
is just an alias forshutdown now
, so it will initiate a graceful shutdown process. At the end of this process,poweroff --force
is called, which actually powers the motherboard off. – Riccardo Murri Jun 23 '21 at 13:52poweroff
is justshutdown
(sometimes?), doesn't that bring us back to the same question? What is the difference betweenpoweroff
andshutdown
and why do we need both? – AlexPi Nov 03 '22 at 02:58shutdown
command, and action (2) is what commandshalt
/poweroff
/reboot
would do. However, for ease of use and to prevent errors,halt
/poweroff
/reboot
will invokeshutdown -h/-P/-r
instead of powering off / rebooting immediately. (The latter requires--force
and is done byshutdown
at the end.) – Riccardo Murri Nov 04 '22 at 13:34poweroff
is an alias ofshutdown now
? Is there other reason to have this alias apart of typing less? – Manuel Jordan Aug 24 '23 at 13:53systemctl start {halt,poweroff,reboot}.target
, immediately in the case ofhalt
/poweroff
/reboot
, and with a configurable delay in the case ofshutdown
. – Riccardo Murri Aug 28 '23 at 06:22