Hello!
I have a laptop that runs Leap 15, with an OpenVPN connection that is started at boot time by systemd’s openvpn@.service. The device uses NetworkManager; once the user logs in and WiFi is connected, then OpenVPN finds its server and connects.
I have the following in /etc/fstab:
10.62.0.1:/srv/shared /mnt/shared nfs4 _netdev,noauto,user,exec 0 0
The 10.x.y.z subnet refers to the VPN. Yes, I know – DNS good, IPv6 good, hardcoded 10.x.y.z addresses bad. We’re working on it. :^)
The mount is “noauto” because a network connection may not be available at boot time (remember NetworkManager, wifi). It is also a “user” mount because the user needs to be able to remount the device without superuser privileges, e.g. if the network connection was lost and is restored. (The OpenVPN process keeps running even if the network goes down, and will reconnect automatically when the network is back.)
The problem with this setup occurs when shutting down. If the user remembers to unmount the shared folder, shutdown is clean and fast. If the user initiates shutdown while the shared folder is mounted, it appears that the network connection (and/or OpenVPN?) go down before the folder is unmounted. It is then not possible to cleanly unmount the folder. The device hangs for five minutes, until the folder is eventually hard-unmounted by timeout.
I am guessing there is something I need to add or change in the systemd module files (like adding a WantedBy=x or After=x line somewhere), but I could use some help here!
This is almost a “vanilla” Leap 15 install, by the way, and there haven’t been any manual changes to the systemd configuration. Could this count as a bug?
By the way: yes, I am aware that the user may fusemount an NFS4 share instead. The reason why we’re not doing that is because the /etc/fstab approach gives us root-level control of the mount point. This path is then used by other processes, e.g. a daily data back-up to the network drive.
Best,
/K.