You are not logged in.

#1 2021-01-09 20:15:34

Registered: 2018-02-22
Posts: 4

NFS, shutdown/reboot, A stop job is running for /mnt/foo


I have the following NFS mount in /etc/fstab:

nas.mynet.local:/mnt/storage /mnt/storage nfs4 _netdev,noauto,noatime,sec=krb5p 0 0

I mount this filesystem manually when I need it. I don't use x-systemd.automount because if I'm on different network listing /mnt hangs, probably because automounter kicks when /mnt/storage is stat()ed. Adding this option also doesn't help the issue I'm having in any observable way.

The issue is: Every time I shutdown or reboot the system with a NFS (or CIFS) filesystem mounted, systemd waits 90 seconds for something with message:

A stop job is running for /mnt/storage (1s / 1min 30s)

What is the problem? How can I fix it?

Note that I have sec=krb5p in mount options. I'm using Kerberos for authentication, and (authenticated) encryption of NFS traffic. The old-style authentication via UIDs can be enabled by sec=sys, which also doesn't have any effect on the issue. What may be different from other reported issues on Internet is that I'm using NFSv4.

This is how my mount point looks on running system:

nas.mynet.local:/mnt/storage on /mnt/storage type nfs4 (rw,noatime,vers=4.2,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=krb5p,clientaddr=,local_lock=none,addr=,_netdev)

Systemd unit metadata (dependencies, ordering, ...) obtained from systemctl show mnt-storage.mount:

I use NetworkManager and NetworkManager-wait-online.service is enabled and active after boot.

Adding to mount options has no effect.

I have quite strict firewall rules for incoming traffic set up by nftables.service, but I don't see how that would be affecting this problem.

It happens with both NFS and CIFS, so I assume it's problem with ordering of service shutdowns. I don't seem to have the ability to scroll in systemd boot log but hopefully I see everything it prints from shutdown to the wait for unmount, and I see no network unit is stopped there. After the timeout expires and systemd gives up on the mount, bunch of other units are stopped but it happens too fast before reboot to read anything.

It's really frustrating. I learned to manually unmount network filesystem before shutdown but sometimes I forget, and generally it's inconvenient. It seems I'm not the only one having this problem but there's not much useful information to track this problem down. Thanks for all your suggestions.


#2 2021-01-12 20:02:02

Registered: 2016-01-06
Posts: 57

Re: NFS, shutdown/reboot, A stop job is running for /mnt/foo

I'd rather suspect, some process may still access the mount, than an ordering problem, but I am no expert, so I may be completely off track

But first I would try to add following to /etc/systemd/logind.conf:

# User settings:

Be aware, this also may kill tmux or screen sessions after logout.

You may also create an unit file, that does an "lsof | grep storage > somelog" during shutdown, to see, wether not some process will use this path.

Not an ideal solution, but what if you create a mnt-storage.mount unit instead of an fstab entry? This way you could easily control the ordering and see, wether this is the reason.

Or, just create an unit file, that will come up with ExecStart=/bin/true (RemainAfterExit=yes) and with an ExecStop=/usr/bin/umount /mnt/storage and order it the way you want. Just an idea to play around.

No real help, I know, but perhaps hints for troubleshooting.


Board footer

Powered by FluxBB