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)
yt-dlp – download your data from youtube

Hi, this short article only to mention that there is a wonderful application that exists for a years for the purpose to download YOUR or maybe some other movies from youtube. I don’t want to go in to legal aspect too much, what can be downloaded from youtube, what not …

Linux
Migrate WordPress site to another hosting service.

IntroductionThis article details the migration of WordPress site (exactly this site you are now on) from one service provider to Amazon Lightsail. There might be various reason to do that (mine is outlined below) but in general I hope to share the message that especially with WordPress, migration can be …

Free(BSD)
Convert pdf file to jpeg – with imagemagic

Short article just to write down not-so frequently (for me) task: remove /opt/homebrew/bin from that command where using on other system than macOs Options: cheers