1

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?

3
  • I'm taking a guess here: though I haven't had a similar problem, is it possibly that you only specified After=local-fs.target, but not a Requires=local-fs.target? Dec 11, 2023 at 9:06
  • (After only specifies the order of starting, should two units be started together, Requires actually defines the dependency) Dec 11, 2023 at 9:07
  • @MarcusMüller I will check if this is the case and try to change it if not. Thanks for the input. Dec 11, 2023 at 13:01

0

You must log in to answer this question.

Browse other questions tagged .