I have a systemd service that uses After=local-fs.target to ensure that all mount points are established (if possible) before the service is started.
Not being too familiar with the systemd infrastructure, I assumed that the service will be stopped before the mounts are unmounted during shutdown. To my surprise this does not seem to be the case though.
I could see multiple times that my service failed to write its configuration (done during shutdown) because the location that's being used for it was already unmounted.
After some research I think I have narrowed it down to the unit type of local-fs.target which seems to not be considered in the shutdown order - I might be wrong though. There was no definitive answer to my question yet.
How can I make sure that my service is stopped before the mount points are unmounted during shutdown phase?
After=local-fs.target, but not aRequires=local-fs.target?Afteronly specifies the order of starting, should two units be started together,Requiresactually defines the dependency)