systemctl – add nfs mountpoint

  • By :
  • Category : Linux
Linux

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.

    1. 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)..
    1. reload systemd daemon: sudo systemctl daemon-reload
    2. 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.
    3. 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

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Free(BSD)
Search for duplicated files

This will be short (but hopefully I will find more time to show entire process to search duplicated files together with some examples). In case you are searching for duplicated files I can recommend two software which actually rocks in openSource world

Linux
2
“Gaming laptop”, steam link and rustdesk.

Not really related to this article, but just wanted to describe the situation.  Most of the time I am working on Linux or Mac. Not a big deal, but last year we bought my daughter a kind of gaming laptop. I am saying kind of, because IMHO there is no …

Azure
NFS issue, cannot be mounted or is not visible

The same kind of issue I have encountered numerous times while working across different environments and with various customers. The problem with NFS mounts connected from remote locations is so common. This issue extends beyond communication solely over WAN and also include connections between datacenters (DC) where we lack control …