Network File Services  «Prev  Next»

Lesson 8 Automounting NFS filesystems
Objective Use automounter to mount remote filesystems automatically

Automounting NFS Filesystems(Use Automounter to mount remote filesystems)

The Linux automounter automatically mounts filesystems the first time you access them. You can configure the automounter to mount remote filesystems as well, using NFS. If network activity is costly, such as when you pay by the minute, you might want to configure the automounter to mount NFS filesystems. The automounter works by monitoring a particular directory (called an automount point) and taking action whenever a user changes into one of its subdirectories.

The automount Process

What is the process for Automounting NFS filesystems in Red Hat Linux?
In Red Hat Linux, automounting NFS filesystems can be achieved using the autofs service. Here are the general steps to configure automounting of NFS filesystems in Red Hat Linux:
  1. Install the autofs package using the package manager of your choice, if it's not already installed.
  2. Edit the "/etc/auto.master" file to add a line that specifies the mount point for the NFS filesystems. For example, to mount the NFS filesystem at "/mnt/nfs", add the following line to the end of the file:
    /mnt/nfs /etc/auto.nfs

  3. Create a new file named "/etc/auto.nfs" (or whatever name you specified in step 2) and add a line for each NFS filesystem that you want to mount.
    Each line should specify the mount point, the server and path of the NFS share, and any options that should be passed to the NFS client. For example:
    sharename -fstype=nfs server:/path/to/share

    Note that "sharename" can be any name that you want to use to identify the share.
  4. Save the changes to the "/etc/auto.nfs" file.
  5. Start the autofs service using the following command:
    systemctl start autofs
    You can also enable the service to start automatically at boot time using the following command:
    systemctl enable autofs
After completing these steps, the NFS filesystem should be automatically mounted at the specified mount point when accessed by a user or application. If there are any issues with the configuration, you can check the logs in "/var/log/messages" or use the "systemctl status autofs" command to view the status of the autofs service.

The following SlideShow illustrates how the automount process works:
1) Auto Mount 1 2) Auto Mount 2 3) Auto Mount 3 4) Auto Mount 4
  1. When a user accesses an automount directory, the system consults the /etc/auto.master file
  2. The system looks up the automount point in /etc/auto.master file, then consults the associated map file. In this example
  3. The map file pairs keys to locations. When the user accesses on the listed keys, the automounter pulls files from the associated location.
  4. In this example, the files were located on a network server.

mount NFS automatically

Configuring the automounter

To get automounting working, you need to:
  1. Configure /etc/auto.master to monitor directories you wish to automount. The format for this file is: automount_point map_file. To monitor /proj for accesses, you'd put /proj /etc/auto.proj.
  2. Configure each map file. For example, /etc/auto.proj might contain docs serv:/proj/docs and
    open serv:/proj/open_projects
    . Whenever a user accesses /proj/docs or /proj/open, automounter will mount the filesystems via NFS.
The next lesson discusses how to resolve NFS problems.

Using NFS Automounter

Before moving on to the next lesson, click the Exercise link below to practice using the Automounter to configure automatic remote file access.
Using NFS Automounter