{"id":319,"date":"2018-02-24T13:21:29","date_gmt":"2018-02-24T13:21:29","guid":{"rendered":"http:\/\/labiol.xyz\/?p=319"},"modified":"2018-02-26T21:58:36","modified_gmt":"2018-02-26T21:58:36","slug":"systemctl-add-nfs-mountpoint","status":"publish","type":"post","link":"https:\/\/www.labiol.xyz\/index.php\/2018\/02\/24\/systemctl-add-nfs-mountpoint\/","title":{"rendered":"systemctl &#8211; add nfs mountpoint"},"content":{"rendered":"<p>At home, you can&#8217;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.<\/p>\n<p>The normal situation is that all your workstation is server\/client at the same time.<\/p>\n<p>Usually, I was used to using the autofs\u00a0software 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\u00a0do 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).<\/p>\n<p>Anyway, configuring systemd\u00a0to mount remote resources is quite simple.<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>\n<li>Update your fstab file with additional option: noauto\u00a0and x-systemd.automount. My fstab\u00a0line looks like this:<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<pre>home1:\/data\/drawer\u00a0 \/mnt\/nfs\/home1_drawer\u00a0 nfs\u00a0noauto,x-systemd.automount,x-systemd.device-timeout=10,timeo=14,soft,intr,noatime,_netdev 0 0\r\n\r\nhome2:\/data\/media\u00a0 \u00a0\/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<\/pre>\n<p>&nbsp;<\/p>\n<p>The importance of individual options:<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>\n<li style=\"list-style-type: none;\">\n<ul>\n<li>noauto\u00a0&#8212; do not mount share\u00a0until it is accessed (auto to mount during start)<\/li>\n<li>x-systemd.idle-timeout=1min\u00a0 &#8212; unmount NFS share automatically if it is not used (good for laptop)<\/li>\n<li>x-systemd.requires=network-online.target &#8212; if reboot, shutdown takes too much time; also enable NetworkManager-wait-online.service<\/li>\n<li>noatime,\u00a0nodiratime,\u00a0noac,\u00a0nocto\u00a0&#8212; for speed<\/li>\n<li>user &#8212;\u00a0user\u00a0can mount resource; this automatically adds another option, like\u00a0noexecute<\/li>\n<li>timeo\u00a0&#8212;\u00a0The time in deciseconds (tenths of a second) the NFS client waits for a response before it retries an NFS request (from\u00a0fstab\u00a0manual)<\/li>\n<li>intr\/nointr\u00a0&#8211; ignore in kernel\u00a0&gt; 2.6.25; behaviour in case of signal to interrupt file operations on mount NFS filesystem<\/li>\n<li>soft\/hard &#8212; NFS\u00a0behaviour in\u00a0case\u00a0the NFS request timeout; soft causing the NFS client to return an error to the application<\/li>\n<li>x-systemd.device-timeout=10 &#8212; by default timeout for NFS is 90 second; so without this system would wait for resource for that time (especially with option\u00a0nofail).<span style=\"color: #ffffff;\">.<\/span><\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<\/li>\n<li>reload systemd\u00a0daemon:\u00a0sudo systemctl daemon-reload<\/li>\n<li>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 &#8220;automount&#8221; at the end.<\/li>\n<li>you can restart automount (sudo systemctl restart XXX-XXX.automount &lt;- tab should help you in this case)<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/www.freedesktop.org\/software\/systemd\/man\/systemd.mount.html\">https:\/\/www.freedesktop.org\/software\/systemd\/man\/systemd.mount.html<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>At home, you can&#8217;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 &hellip; <\/p>\n","protected":false},"author":1,"featured_media":238,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-319","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.labiol.xyz\/index.php\/wp-json\/wp\/v2\/posts\/319","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.labiol.xyz\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.labiol.xyz\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.labiol.xyz\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.labiol.xyz\/index.php\/wp-json\/wp\/v2\/comments?post=319"}],"version-history":[{"count":14,"href":"https:\/\/www.labiol.xyz\/index.php\/wp-json\/wp\/v2\/posts\/319\/revisions"}],"predecessor-version":[{"id":333,"href":"https:\/\/www.labiol.xyz\/index.php\/wp-json\/wp\/v2\/posts\/319\/revisions\/333"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.labiol.xyz\/index.php\/wp-json\/wp\/v2\/media\/238"}],"wp:attachment":[{"href":"https:\/\/www.labiol.xyz\/index.php\/wp-json\/wp\/v2\/media?parent=319"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.labiol.xyz\/index.php\/wp-json\/wp\/v2\/categories?post=319"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.labiol.xyz\/index.php\/wp-json\/wp\/v2\/tags?post=319"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}