[systemd-devel] What is the shutdown sequence with systemd and dracut?

Lennart Poettering lennart at poettering.net
Mon Aug 15 09:32:38 UTC 2022


On Sa, 13.08.22 20:46, Patrick Schleizer (patrick-mailinglists at whonix.org) wrote:

> 2. /lib/systemd/system-shutdown (shutdown.c) runs

Still, this binary is called systemd-shutdown, i.e. with one more 'd'.

> 4. /lib/systemd/system-shutdown performs further cleanup (similar to
> dracut, probably some functionality duplicated with dracut, includes
> kill all remaining processes, unmount remaining file systems)

I am not sure dracut has another killing spree.

> 6. /run/initramfs/shutdown (which is at time of writing only implemented
> in dracut) attempts to kill all remaining processes, unmount remaining
> file systems and calls kernel.

I think the arch initrd also implements this scheme. And IIRC they use
a neat trick, and chainload systemd-shutdown from the initrd, so that
it runs again, and does the actual final shutdown, but that time
without transitioning back into an initrd env. Hence for them PID 1 during
shutdown first transitions from the service manager into
systemd-shutdown, and then from there into into the initrd script, and
then back into systemd-shutdown. I like their approach.

Lennart

--
Lennart Poettering, Berlin


More information about the systemd-devel mailing list