Auto Mounting a Single Directory at the Root of the Filesystem with Autofs

Tags: , , , , , , , , , , ,

Recently I wanted to ensure that /pub on my server automatically mounted an NFS export using autofs. As it turns out this is very easy to do, but took me some research to figure out how autofs handles this use case.

Autofs refers to a single mount point as a “direct map”. Direct maps look something like this:

#/etc/auto.master
 
/-	/etc/auto.direct
#/etc/auto.direct
 
/pub        -fstype=nfs             nfsserver.example.com:/pub/

After an autofs restart, nfsserver.example.com:/pub/ is auto mounted on /pub when used.