Tune and Tweak NFS for Top Performance - Page 2
The automounter will allow a remote file system to be mounted on-demand, so that the client doesn't need to keep hundreds of NFS mounts open all the time. This feature adds to NFS's scalability, making it possible to have thousands of remote file systems accessible from a client.
In some Linux distributions, an automounter may already be running. When you insert a CD, the directory /cdrom magically contains the contents of the CD. This is basically how autofs works.
To set it up, automount maps need to be created. This is basically a listing of directory (to mount it in) and server:directory to mount. A common setup will have /etc/auto.master referencing files or NIS maps that list the directories to mount. NIS is a wonderfully complex beast that can synchronize users and centralize things like automounter maps, and is way beyond the scope of this NFS article.
Back to NFS, let's view a common setup. In auto.master we have:
This tells autofs to look at auto.import when something needs to be accessed in the file system's /import. In the auto.import file, we'd have:
So, when autofs realizes that /usr from the server is not mounted in /import/test, it will simply go ahead and mount it for us. Using the command
ls /import will not cause it to be mounted, leading to some confusion at first. Running
cd /import/test will cause it to be mounted, however. When sharing all user's home directories to all clients, automounting becomes very important, so that clients don't have too many open NFS mounts unnecessarily. Autofs is highly configurable, but this is the basic method of how it operates.