In a previous post we looked at sharing folders with NFS. Now we take a step further to look at a client-only configuration that allows on demand mounting / unmounting of various filesystems. There is no need for /etc/fstab entries and resources are preserved better. The automounter is provided by the autofs package. After installing it, check that the autofs service has been started, before proceeding with the configuration.
The main configuration is done in the master map file, located at
/etc/auto.master. Its format is:
mount-point = base location for the autofs filesystem to be mounted. For indirect maps this directory will be created (as with mkdir -p) and is removed when the autofs filesystem is umounted.
map-type = map type used for this mount point. A map file can be given here
options = mount options
Here are the contents of my /etc/auto.master file:
The map file can have any name of your choosing. The auto.share file has the following format:
I made one with these values:
The name refers to the autofs mount point. I didn’t specify an absolute path, so the share will be mounted under the directory specified in the master map (/mnt in this case). I had a quick share served by an NFS server, and after all the above configuration, I restarted autofs and looked under /mnt:
Done! No need for manually adding entries to /etc/fstab and mounting them.
1 2 3 4 5 6 7 8 9