{"id":1663,"date":"2013-10-25T18:26:27","date_gmt":"2013-10-25T16:26:27","guid":{"rendered":"http:\/\/raftaman.net\/?p=1663"},"modified":"2021-05-15T11:46:38","modified_gmt":"2021-05-15T09:46:38","slug":"mounting-nfs-share-with-autofs","status":"publish","type":"post","link":"https:\/\/possiblelossofprecision.net\/?p=1663","title":{"rendered":"Mounting NFS share with autofs"},"content":{"rendered":"<p>Statically mounting remote filesystems via <code>\/etc\/fstab<\/code> can be quite impractical on mobile devices such as notebooks that are frequently used in different network environments where the share is not always available. To take care of this, there&#8217;s a great tool called <a href=\"http:\/\/www.autofs.org\/\">autofs<\/a> that let&#8217;s you mount remote filesystems on demand.<\/p>\n<p>Let&#8217;s assume, there&#8217;s an NFS server running in our network that exports a certain directory:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n$ showmount -e Server\r\nExport list for Server:\r\n\/data Client\r\n<\/pre>\n<p>To install and enable the <code>autofs<\/code> daemon, run:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n# yum install autofs\r\n&#x5B;...]\r\n# systemctl enable autofs.service\r\n# systemctl start autofs.service\r\n<\/pre>\n<p>As soon as you try to access the remote filesystem, it should get automagically mounted:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n# ls -lh \/net\/Server\/data\/\r\n&#x5B;...]\r\n<\/pre>\n<p>Note that the subdirectory for the host isn&#8217;t created until you access it. You can also use so-called direct maps, that can&#8217;t be changed on the fly but require a HUP signal to refresh.<\/p>\n<p>To use a <strong>direct map<\/strong>, edit <code>\/etc\/auto.master<\/code> and include the following line:<\/p>\n<pre class=\"brush: plain; highlight: [2]; title: \/etc\/auto.master; notranslate\" title=\"\/etc\/auto.master\">\r\n&#x5B;...]\r\n\/- \/etc\/auto.data\r\n&#x5B;...]\r\n<\/pre>\n<p>Add <code>\/etc\/auto.data<\/code> with the following content:<\/p>\n<pre class=\"brush: plain; title: \/etc\/auto.data; notranslate\" title=\"\/etc\/auto.data\">\r\n\/data   -soft,rw,exec,intr      Server:\/data\r\n<\/pre>\n<p>The options should be quite self-explanatory. For a more comprehensive list, have a look at the <a href=\"http:\/\/linux.die.net\/man\/5\/autofs\">autofs manpage<\/a>.<\/p>\n<p>Resources:<br \/>\n<a href=\"http:\/\/marcofalchi.blogspot.de\/2013\/05\/fedora-19-autofs-nfs-share-from-centos.html\">http:\/\/marcofalchi.blogspot.de\/2013\/05\/fedora-19-autofs-nfs-share-from-centos.html<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Statically mounting remote filesystems via \/etc\/fstab can be quite impractical on mobile devices such as notebooks that are frequently used in different network environments where the share is not always available. To take care of this, there&#8217;s a great tool called autofs that let&#8217;s you mount remote filesystems on demand. Let&#8217;s assume, there&#8217;s an NFS server running in our network&#8230; <a href=\"https:\/\/possiblelossofprecision.net\/?p=1663\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[64],"class_list":["post-1663","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-nfs"],"_links":{"self":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts\/1663","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1663"}],"version-history":[{"count":5,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts\/1663\/revisions"}],"predecessor-version":[{"id":1668,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts\/1663\/revisions\/1668"}],"wp:attachment":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1663"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1663"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1663"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}