The automounter daemon automatically mounts filesystems in response to access requests by processes. To run the automounter we need to make sure we have 2 packages installed: nfs-utils & autofs. Once installed, we have to start & enable the autofs daemon with:
# dnf install nfs-utils autofs
# systemctl start autofs
# systemctl enable autofs
With the automounter installed and running, we can have a look at its default main configuration file:
# cat /etc/auto.master
The /etc/auto.master will rarely be much more complex than the example above. The syntax of the file is simple enough:
<mount point> <map file> <options>
The options are usually added to the map file rather than to the auto.master. In the example before we have 4 lines:
– the 1st line deals with any directories that might need to be auto-mounted in /home by checking the map-file /etc/auto.home
– the 2nd line deals with any directories that might need to be auto-mounted in /mnt/ftp by checking the map-file /etc/auto.ftp
– the 3rd line instructs autofs to look at /etc/auto.shared and set the mount point according to what is said in that file
– finally, the 4th line instructs autofs to look at shared file systems in the given server and make them available in /net . For example, if we run…
# ls -l /net/ftpserver.domain.net
… autofs will check what filesystems are being shared in ftpserver and mount them all underneath /net/ftpserver.domain.net/.
If the map-file is remote (NIS, NIS+ or LDAP), we have to use the plus sign rather than the full path (“+auto.home ” instead of “/etc/auto.home”) and we have to make sure that the entry “automount:” in /etc/nsswitch.conf is properly configured. Alternatively, we can state directly in auto.master where to source the information from:
# cat /etc/auto.master
/home /etc/auto.home → nsswitch.conf will be used to determine source
/mnt/ftp files:/etc/auto.ftp → local file is used
/mnt/share yp:/etc/auto.share → NIS will be used
/- ldap:/etc/auto.cifs → LDAP will be used
Let’s have a look at /etc/auto.ftp to get an idea of what a map file looks like:
# cat /etc/auto.ftp
ftpserv1 -fstype=nfs4,ro ftpserv1.bogomips.net:/var/ftp/pub
The 1st parameter is the name of the local directory underneath which the automount will occur. The 2nd parameter states the file system type and any options we deem necessary. The 3rd states the NFS server name and the NFS shared directory to be mounted.
So given /etc/auto.master and /etc/auto.ftp , if we run “ ls -l /mnt/ftp ”… the contents of ftpserv1.bogomips.net:/var/ftp/pub would be mounted and visible in the localhost:/mnt/ftp/ftpserv1 directory.
The /etc/auto.shared file differs slightly from /etc/auto.ftp in the sense that the mount is direct (full mount path stated in the map-file) rather than indirect (map-file states the directory name of a mount-point chosen by auto.master).
# cat /etc/auto.shared
/sharedarea -fstype=nfs4,rw sharedserv1.bogomips.net:/export/shared
In the first parameter of the file we see clearly that the full path to the mount-point is stated (as required in those map-files whose mount-point in /etc/auto.master is set to “ /- ”).
Finally, the format of /etc/auto.home is different from the previous 2 map-files:
# cat /etc/auto.home
The only line in the file is instructing autofs to replace the “*” and “&” with the required username. For instance, user john logs in to his workstation that has the autofs configuration laid out above and lacks the local /home/john directory. At login time, autofs will see an attempt to access /home/john and will mount it by exporting the NFS share nfshome.bogomips.net:/export/home/john .
If we need LDAP to store automounter maps, we should make sure that the openldap package is installed (and it should be as it is a dependency of autofs !) and that /etc/openldap/ldap.conf is properly configured.
Additionally, in the file /etc/sysconfig/autofs we should comment in the following lines and leave the rest of schema entries commented out:
The configuration file for the automounter can be found in /etc/autofs.conf with all the parameters nicely explained in the file itself.
For all the nitty gritty details on automounter file options you can go to…
… or type man -s5 autofs in your terminal.