Almost Zero Configuration NFS Network Shares using AutoFS
AutoFS is a great and easy way to mount file-systems automatically, on-demand, when available. It works great for both networked and non-networked drives.
I have a HP Laptop which I use as my development machine and a (highly-)upgraded Compaq CQ 3329-IX that doubles as my development as well as file-server. I want my files to be available automatically, whenever I am connected to my home-network. I cannot add a fstab entry as I am not always connected to the same network.
AutoFS to the rescue
If you have a laptop and separate file-server where you store files, AutoFS is a great way to ensure automatic, on-demand mounting and un-mounting of network shares. It even allows for auto-discovery and auto-mounting, so that file-sharing on the client is almost zero-configuration.
This assumes you already have a working NFS share setup, in a machine with host name —
theserver, and let’s say your client is named as -
AutoFS needs domain names, thus you need a DNS stack such as Avahi/mDNS, a DHCP server or appropriate entries in
My home network uses mDNS. My host and my client are assigned
theclient.local respectively. mDNS sets up domain names with zero configuration, and works in a variety of devices, including mobile.
Installing and configuring AutoFS
The process is very simple. Use your package manager to install the
Now you will be automatically be able to access files at
/net/theserver.local/share, where share is the path configured at
In Fedora and CentOS, the
/etc/autofs.net file comes enabled out-of-the-box. For other distributions, you may need to add:
/net -hosts to
In addition to NFS, you can also access SAMBA shares under (/smb) in a similar fashion, unless they require authentication.
AutoFS in Ubuntu wiki describes various setup options for AutoFS.
There are other alternatives such as systemd-automount and gvfs-automount, however, they involve much more complicated configuration.
Originally published at amitosh.in on June 26, 2017.