autofs is the linux automounter. It's a daemon that automatically mounts filesystems as they are accessed on demand.


The primary configuration file used by automount is /etc/auto.master which defines what mounts automount is responsible for.

# /etc/auto.master
/home   /etc/auto.home

In the example above, automount is responsible for mounting directories under /home and the configuration for it is under /etc/auto.home. The configuration under /etc/auto.home will define directories in /home and their corresponding mount locations.

# /etc/auto.home
leo    file1:/export/home/leo

Anyone going to /home/leo will cause automount to mount /home/leo from file1:/export/home/leo.

You may specify mount options by placing them before the mount location:

# /etc/auto.home
leo   -fstype=nfs4    file1:/export/home/leo

Dynamic Automount Rules[edit]

The automount configuration can be made as a script to make mounting more intelligent. automount will pass in the mounting point to your auto mount configuration.

For example, if home directories are stored on multiple file servers, we can make /home the mounting point for all users by doing something like so:

# cat /etc/auto.home

# Automount will pass in the username as the first parameter since we are
# mounting /home/<username>

# The default fileserver is 'file1'

# The path to the mount for this user

# As a proof of concept, we can make a specific user use a different filesersver
# Eg: leo's home directory will be mounted from file2
if [ "$Username" = "leo" ] ; then

# Echo out the configuration for automount
echo "-fstype=nfs4,sec=krb5,soft,rsize=8192,wsize=8192,rw   $Server:$Path"