OK, let’s get this out in the open… systemd is *PANTS*
Phew! That’s better.
I’ve just spent most of the day trying to get a Linux system to reliably mount a disk attached via iSCSI over ethernet at boot time and, more importantly, to reliably get it to be unmounted at shutdown before the network rug is pulled from beneath it.
Now, in the days of the init scripts it was pretty easy to stuff a script in-between the networking coming up and nfs-server starting. It was also dead easy to make sure that your script ran at shutdown before the iSCSI and networking were closed down as well.
Now, with systemd the first part is more tricky as the program tries to do everything at once. If you want to have a native systemd service which starts before nfs-server then you have to modify that service description too. You might as well just have an init script which runs last which shuts down nfs-server before mounting the iSCSI disk and then starts it again when it finishes.
Now, it gets worse when the system is shutting down. Oh yes!
You see, systemd always tries to do things in a hurry. It seems that the design philosophy was better to do things quickly rather than correctly, and this is especially true at shutdown.
In a discussion thread on the systemd-devel mailing list titled “[systemd-devel] systemd and LSB Required/Should-Stop” it’s stated by Lennart Poettering:
On Fri, 24.06.11 14:04, Ville Skyttä (ville.skytta at iki.fi) wrote: > Hello, > > Am I right that systemd does currently have no support for the LSB > Required-Stop and Should-Stop keywords? If yes, are there plans to > support them in the future? That is true, we do not support this right now. In systemd the shutdown order is always the inverse startup order of two services. I am not entirely opposed to make this more flexible but so far I have not heard of a good usecase where the flexibility to detach the shutdown oder from the startup order was necessary.
Now, what this means is that any program or script called during the shutdown process is in a race to complete before the services it depends upon disappear. There is no ability to pause the shutdown to wait for vital events to happen, such as the synchronising and unmounting of disks. This is completely broken, by design.