I have a directory on a remote machine which I always mount to a folder on my home directory.
I have a line in fstab to mount this on each boot up and the first option on that line after fs-type (CIFS in this case) I have _netdev, which I have read will ensure it is unmounted before the network service goes down on reboots and power downs.
But this leads to a 90 second count down when unmounting.
I am wondering if
Have I misunderstood how to use _netdev or maybe the info I read was out of date?
Would I be better off create a small script that is executed at the beginning of the shutdown/reboot process to unmount that directory?
I looked into option two, and I read a lot about /etc/init.d/ directory being used to setup such a script to unmount, but this was for initv systems and not systemd?
While I understand it could still work on a systemd install, I am hoping there is a “more correct” way to implement a shutdown script for systemd and if so, can someone please guide me on how to do this or to a simple guide for dimwits like me that I can follow?
_netdev
The filesystem resides on a device that requires network access (used to prevent the system from attempting to mount these filesystems until the network has been enabled on the system).
So in my opinion the _netdev does the opposite thing:
ensures that the network is up before mounting.
AFAIK none of the mount options deals with un-mounting.
OK, big thanks for this as autofs was not something I’ve come across before. It’s impressively fast and suddenly my shutdown/restart timing is very fast now!
Not sure why I’m getting 2 objects showing up in nautilus, but I’ll figure that out another day.
My next challenge will now be to auto mount shares which can only be reached when I activate a VPN, and disconnect them when the VPN is stopped. Exciting challenge!
Yes, _netdev means that during boot, the filesystem is mounted after the network is up, and when shutting down, the filesystem is unmounted before the network is down. If you saw timeouts during shutdown, this means that something went wrong with the ordering. (Most likely, the network connection was destroyed too early. But it’s hard to say without looking at logs and knowing the details of your network configuration.)
Autofs is a way to work around the issue… Good that it works for you.