The goetia-shutdown service
goetia-shutdown is the service that starts system-shutdown-daemon. goetia-shutdown is down by default. Starting it initiates the shutdown procedure.
goetia-shutdown consists of three scripts:
run
- This script just executes system-shutdown-daemon.
stage3b
-
stage3b tries to execute
./stage4, which is by default not executable. If it can not execute./stage4, and only in this case, it continues with the following. -
It makes
./stage4executable. - It sends SIGCONT to all processes.
- It sleeps for 1 second.
- It writes a banner to its standard out.
- It send SIGKILL to all processes.
-
This also stops the system-shutdown-daemon process.
It is automatically restarted by the system supervision tree,
but this time, both the files
./stage3band./stage4are executable. Which leads to the execution of./stage4.
stage4
-
stage4 reads the envdir at the
shutdown-directivesubdirectory of the system runtimedirectory using s6-envdir. -
It reads the
DIRECTIVEevironment variable, defaulting to-r, ifDIRECTIVEis not specified. -
It runs
umount -a. - It remounts the root filesystem read-only.
-
It runs
linux-powertool ${DIRECTIVE}.
Notes
The entire shutdown procedure roughly works as follows:
- This service, running system-shutdown-daemon gets the instructions from system-shutdown to shutdown.
- system-shutdown-daemon does most of the shutdown procedure. Part of it is to make stage3b executable. In the end, system-shutdown-daemon sends SIGTERM to all processes but PID 1, including itself.
- this service gets restarted automatically. system-shutdown-daemon now instantly executes into stage3b.
- stage3b makes stage4 executable. Followed by sending SIGKILL to all processes but PID 1, including itself.
- The final restart of this service causes system-shutdown-daemon to instantly execute into stage3b which instantly executes into stage4, which instructs the Kernel to do the actual halt, poweroff or reboot.
