At home, you can’t make assumptions that your home server (whatever it is a simple laptop, from NFS point of view it is a server) will run all the time and you will just plug and unplug rest of your workstation.
The normal situation is that all your workstation is server/client at the same time.
Usually, I was used to using the autofs software to dynamically mount NFS and CIFS resources in my home. Autofs most time works as it should BUT now another big player came in to, systemd. As systemd do almost everything in Linux system nowadays than why do not use it to mount remote NFS/CIFS resources (well there is several reasons but it is subject for another discussion).
Anyway, configuring systemd to mount remote resources is quite simple.
-
- Update your fstab file with additional option: noauto and x-systemd.automount. My fstab line looks like this:
home1:/data/drawer /mnt/nfs/home1_drawer nfs noauto,x-systemd.automount,x-systemd.device-timeout=10,timeo=14,soft,intr,noatime,_netdev 0 0 home2:/data/media /mnt/nfs/media nfs noauto,x-systemd.automount,x-systemd.device-timeout=10,user,timeo=14,soft,intr,noatime,_netdev,x-systemd.idle-timeout=1min 0 0
The importance of individual options:
-
-
-
- noauto — do not mount share until it is accessed (auto to mount during start)
- x-systemd.idle-timeout=1min — unmount NFS share automatically if it is not used (good for laptop)
- x-systemd.requires=network-online.target — if reboot, shutdown takes too much time; also enable NetworkManager-wait-online.service
- noatime, nodiratime, noac, nocto — for speed
- user — user can mount resource; this automatically adds another option, like noexecute
- timeo — The time in deciseconds (tenths of a second) the NFS client waits for a response before it retries an NFS request (from fstab manual)
- intr/nointr – ignore in kernel > 2.6.25; behaviour in case of signal to interrupt file operations on mount NFS filesystem
- soft/hard — NFS behaviour in case the NFS request timeout; soft causing the NFS client to return an error to the application
- x-systemd.device-timeout=10 — by default timeout for NFS is 90 second; so without this system would wait for resource for that time (especially with option nofail)..
-
- reload systemd daemon: sudo systemctl daemon-reload
- step above create new files in /run/systemd/generator directory; files are called like mount point directory with the dash instead of the slash in the middle and “automount” at the end.
- you can restart automount (sudo systemctl restart XXX-XXX.automount <- tab should help you in this case)
-
https://www.freedesktop.org/software/systemd/man/systemd.mount.html
No Comments