Using AutoFS to automatically mount a file system

AutoFS relies on the use of the automount command to propagate the automatic mount configuration information to the AutoFS kernel extension and start the automountd daemon.

Through this configuration propagation, the extension automatically and transparently mounts file systems whenever a file or a directory within that file system is opened. The extension informs the automountd daemon of mount and unmount requests, and the automountd daemon actually performs the requested service.

Because the name-to-location binding is dynamic within the automountd daemon, updates to a Network Information Service (NIS) map used by the automountd daemon are transparent to the user. Also, there is no need to premount shared file systems for applications that have hard-coded references to files and directories, nor is there a need to maintain records of which hosts must be mounted for particular applications.

AutoFS allows file systems to be mounted as needed. With this method of mounting directories, all file systems do not need to be mounted all of the time; only those being used are mounted.

For example, to mount an NFS directory automatically:

  1. Verify that the NFS server has exported the directory by entering:
    showmount -e ServerName

    where ServerName is the name of the NFS server. This command displays the names of the directories currently exported from the NFS server.

  2. Create an AutoFS master file and map file. AutoFS mounts and unmounts the directories specified in these map files.
    For example, suppose you want AutoFS to mount the /local/dir1 and /local/dir2 directories as needed from the serve1 server onto the /remote/dir1 and /remote/dir2 directories, respectively. The auto_master file entry would be as follows:
    /remote		/tmp/mount.map
    The /tmp/mount.map file entry would be as follows:
    dir1	-rw	serve1:/local/dir1
    dir2	-rw	serve1:/local/dir2
  3. Ensure that the AutoFS kernel extension is loaded and the automountd daemon is running. This can be accomplished in two ways:
    1. Using the automount command: Issue /usr/sbin/automount -v.
    2. Using SRC: Issue lssrc -s automountd. If the automountd subsystem is not running, issue startsrc -s automountd.
      Note: Starting the automountd daemon with the startsrc command will ignore any changes that have been made to the auto_master file.
  4. To stop the automount daemon, issue the stopsrc -s automountd command.

    If, for some reason, the automountd daemon was started without the use of SRC, issue:

    kill automountd_PID
    where automountd_PID is the process ID of the automountd daemon. (Running the ps -e command displays the process ID of the automountd daemon.) The kill command sends a SIGTERM signal to the automountd daemon.