Automounting is an alternative to creating NFS mount entries in /etc/fstab or using the mount command from the command line to mount NFS shares. Automounting mounts remote file systems when they are accessed, rather than maintaining these remote mounts at all times. When the remote file systems are inactive, they are unmounted. This frees up system resources and improves overall system performance.

 

To implement automounting, first install the autofs package:

# yum install autofs

 

To start the autofs service:

# systemctl start autofs

 

 The main configuration file, known as the master map file, is /etc/auto.master. This file lists mount points, known as keys, and corresponding map files that indicate which remote file systems can be mounted on the key. The format for entries in /etc/auto.master is:

To implement automounting, first install the autofs package:

/key      map-file      [options]

 

 Automounting supports direct maps, indirect maps, and host maps. Direct maps use a special key, /-, in /etc/auto.master. Indirect maps specify a relative path name in their map files. Host maps use a special map, -hosts, in the /etc/auto.master file. Entries preceded with a plus sign (+) include a map from its source as if it were present in the master map.

 

Direct Maps

 

The following entry in the /etc/auto.master file is an example of a direct map:

/-          auto.direct

 

Direct maps always have a key of /-. The map file in this example is auto.direct. With direct maps, the map file contains the absolute path name of the directory to be mounted. The following is an example of the contents of the auto.direct file: 

/usr/man    -ro,soft     host01:/usr/man

 

This entry mounts the file system /usr/man from the server host01 on the local /usr/man mount point. automount creates the /usr/man directory if it does not already exist. If /usr/man does exist and is not empty, the mounted file system hides the local existing file system. Direct map files and indirect map files have the following format:

key    [options]     location

 

 The key can be a single directory name for an indirect map or the absolute path name of the mount point for direct mounts. Mount options can be included in map files. Any options specified in map files override options specified in the master map file. The location is the exported NFS file system, a local file system, or any other supported file system type.

 

Indirect Maps

 

The following entry in the /etc/auto.master file is an example of an indirect map: 

/misc        /etc/auto.misc

 

Indirect maps are more common than direct maps. The following is an example of an indirect map file named /etc/auto.misc:

# cat /etc/auto.misc
xyz         -fstype=nfs                           host01:/xyz
cd          -fstype=iso9600,ro,nosuid,nodev       :/dev/cdrom
abc         -fstype=ext3                          :/dev/hda1
kernel      -ro,soft,intr                         ftp.kernel.org:/pub/linux
windoz      -fstype=smbfs                         ://windoz/c

 

The key field is relative to the actual location of the autofs mount point, /misc, from the master map file, /etc/auto.master. For example, entering the cd /misc/xyz command mounts the /xyz directory from machine host01 locally on /misc/xyz. Only the /misc mount point needs to exist on the local machine. For indirect maps, the key is created when the file system is accessed and then removed when the file system is unmounted.

The second and third entries are examples of automounting local file systems: 

cd          -fstype=iso9600,ro,nosuid,nodev       :/dev/cdrom
abc         -fstype=ext3                          :/dev/hda1

 

The location field is the local file system path preceded by a colon (:). Entering the ls /misc/cd command would display the contents of the iso file on the cdrom. Entering the ls /misc/abc command would display the contents of the ext3 file system on the hda1 device.

kernel      -ro,soft,intr                         ftp.kernel.org:/pub/linux

 

The last line mounts a share exported from a Windows machine on /misc/windoz:

 

windoz      -fstype=smbfs                         ://windoz/c

 

Host Maps

 

The following entry in the /etc/auto.master file is an example of a host map:

/net      -hosts

 

When –hosts is given as the map, the automount daemon creates a subdirectory under the “key” directory, /net, for every server listed in the /etc/hosts file. For example, entering the following command mounts all exports from host03 over the /net/host03 directory:

# cd /net/host03

 

All exports are mounted with the “no-suid,nodev,intr” options by default.

 

Bu cavab sizə kömək etdi? 0 istifadəçi bunu faydalı hesab edir (0 səs)