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’s a great tool called autofs that let’s you mount remote filesystems on demand.
Let’s assume, there’s an NFS server running in our network that exports a certain directory:
$ showmount -e Server Export list for Server: /data Client
To install and enable the autofs
daemon, run:
# yum install autofs [...] # systemctl enable autofs.service # systemctl start autofs.service
As soon as you try to access the remote filesystem, it should get automagically mounted:
# ls -lh /net/Server/data/ [...]
Note that the subdirectory for the host isn’t created until you access it. You can also use so-called direct maps, that can’t be changed on the fly but require a HUP signal to refresh.
To use a direct map, edit /etc/auto.master
and include the following line:
[...] /- /etc/auto.data [...]
Add /etc/auto.data
with the following content:
/data -soft,rw,exec,intr Server:/data
The options should be quite self-explanatory. For a more comprehensive list, have a look at the autofs manpage.
Resources:
http://marcofalchi.blogspot.de/2013/05/fedora-19-autofs-nfs-share-from-centos.html