Certification Objective 12.03Working with AutoFS


Certification Objective 12.03—Working with AutoFS

Exam Objective 2.5: Explain and manage AutoFS and use automount maps (master, direct, and indirect) to configure automounting.

The clients can mount the file systems that the NFS servers share through the NFS service, either by using the mount utility or by using the automatic mounting offered by AutoFS, a client-side service. As a system administrator, you should understand how this service works and how to manage it.

Understanding AutoFS

AutoFS is a kernel file system that supports automatic mounting and unmounting of remote file systems. It is initialized by the automount service, which is started automatically when a system is booted. The automount daemon, automountd, runs continuously, mounting and unmounting remote file systems as necessary. An NFS resource (the remote file system) is automatically mounted when you access it, and it is automatically unmounted when it is left idle (i.e., not accessed) for a certain period. AutoFS offers the following benefits:

  • NFS resources (the shared file systems) don't need to be mounted during the system boot, which saves booting time.

  • Because mounting is done automatically, it avoids the problem of giving users the root password to mount and unmount NFS resources.

  • Network performance might improve, because network traffic is being reduced by mounting the resources only when they are in use.

AutoFS allows you to specify multiple servers to provide the same file system. This way, if one of the specified servers is down, AutoFS can try to mount the file system from another server machine. This provides fault tolerance.

Note that the following three components work together to accomplish the task of automatic mounting:

  • The autofs file system

  • The automountd daemon

  • The automount command

The automount service is managed by SMF under the identifier svc:/system/filesystem/autofs; it is automatically started when the system is booted. It reads the master map file named auto_master to create the initial set of autofs mounts, which are the points under which the file systems will be mounted in the future. These autofs mounts are also called trigger nodes, because when a file system request on one of these points is made, it triggers the file system mounting process. When autofs (the service that was started at the system boot time) receives a request to access a file system that is not currently mounted, it calls the automountd daemon, which mounts the requested file system. Although initial autofs mount points are set up during system boot time, the automount command is used to update the autofs mount points when necessary, after the system is up and running. The command makes the necessary changes after comparing the list of mounted file systems in the mount table file /etc/mnttab with the list of mount points in the auto_master map. It allows you to change mount information in the auto_master file and have those changes used by the autofs processes without stopping and restarting the autofs daemon.

In summary, the automount daemon automountd is started at boot time by the service svc:/system/filesystem/autofs. This service also uses the automount command to update the autofs mount points when the system is up and running. When a request is made to access a file system at an autofs mount point, it triggers the following process:

  1. The autofs service intercepts the request and sends a message to the automountd daemon to mount the requested file system.

  2. The automountd daemon locates the file system information in a map, creates the trigger nodes (autofs mount points) if necessary, and performs the mount.

  3. The autofs service allows the intercepted request to proceed.

  4. The autofs service unmounts the file system after a predetermined period of inactivity.

On the Job 

You should not manually mount or unmount the mounts that are managed through the autofs service. Even if your manual operation is successful, it may possibly generate inconsistencies, because the autofs service does not check whether the object has been unmounted. In addition, note that a reboot clears all of the autofs mount points.

Suppose you want to use AutoFS. How do you configure it?

Configuring AutoFS Using Maps

You configure the AutoFS environment by assigning values to keywords in the following file:

    /etc/default/autofs 

The behavior of autmounting is determined by the entries in the configuration files called maps used by autofs. These files (or the maps in them) fall into three categories: master maps, direct maps, and indirect maps. Sometimes the files themselves are referred to as maps. However, you will figure out from the context whether the term map refers to the file or to an entry in the file.

The Master AutoFS Maps

The master maps reside in the /etc/auto_master file, which contains the master list that specifies all the maps that autofs should check. The entries in the auto_master file looks like the following:

    /net -hosts -nosuid,nobrowse    /home auto_home -nobrowse    /- auto_direct -ro 

The syntax of an entry is:

    <mountPoint> <mapName> [mountOptions] 

These fields of an entry are described here:

  • <mountPoint>. This specifies the path to a directory to which a file system will be mounted in the future. If the directory does not exist, autofs will create it. If it exists and has a content, autofs will hide this content when it mounts a file system to it. The value /- for the <mountPoint> may mean that this map is a direct map or that no particular mount point is specified for this map.

  • <mapName>. This specifies the map name that the autofs service uses to find directions to locations or the mount information. The name is interpreted as a local file if it is preceded by a slash (/). Otherwise, autofs uses the /etc/nsswitch.conf file to search for the mount information.

  • <mountOptions>. This specifies an optional, comma-delimited list of options that apply to the mounting of the entries that are specified in the <mapName>, unless the entries in the <mapName> list other options. Options obviously depend on the specific type of file system being mounted.

A line that begins with the pound sign (#) is considered to be a comment line and is ignored. The maximum number of characters allowed in an entry is 1024. You can use backward slash (\) as a continuation in order to split an entry into more than one line.

On the Job 

If the /etc/auto_master file contains more than one entry for the same mount point, the autamount command uses the first entry and ignores the other entries.

AutoFS runs on all computers on the network and supports /net and /home (the automounted home directories) by default. The /home mount point is the directory under which the entries that are listed in the /etc/auto_home file are to be mounted. The following entry in the auto_master file makes this happen:

    /home auto_home -nobrowse 

The auto_home directory is an example of the indirect maps that we will discuss later in this chapter. Now, consider the following entry in the /etc/auto_master file:

    /net -hosts -nosuid,nobrowse 

It means that autofs mounts all the entries in the hosts map under the directory /net. Suppose a computer howard is listed in the hosts file, and it exports a file system. Further suppose that a client machine has the foregoing entry in its auto_master file. You can go to the root directory of the exported file system of computer howard by issuing the following command on the client computer:

    cd /net/howard 

When the system is booted, the automount command reads the master map file /etc/auto_master in which each entry defines either a direct map file name or an indirect map file name, along with the path of the mount point associated with the name and the mount options.

You can define the name of the direct map file in the auto_master file by using the /- value for the <mountPoint> as shown here:

    /- auto_direct -ro 

The mount point /- specifies that this is an entry for the direct maps file and that the full path to the mount point for each direct map will be defined in the direct maps file.

The Direct AutoFS Maps

A direct map is an automount point on the client associated with a directory on the server. The maps reside in the direct map file, whose name you can define in the auto_master file, typically /etc/auto_direct. These maps are called direct maps because they explicitly express the relationship of the mount point to the directory by specifying the full path. Entries in the auto_direct file look like the following:

    /usr/local -ro    /bin senate:/export/local/sun4    /share senate:/export/local/share    /src senate:/export/local/src    /usr/man -ro blue:/usr/man    red:/usr/man \    white:/usr/man    /usr/games -ro congress:/usr/games 

These entries are according to the following syntax:

    <key> [<mountOptions>] <location> 

The fields in the syntax are described here:

  • <key>. This specifies the path name of the mount point to which file systems can be mounted.

  • <mountOptions>. This specifies the options that will be applied to this particular mount.

  • <location>. This specifies the full path of file systems that can be mounted to the mount point.

As in the master map file, a line that begins with the pound sign (#) is considered to be a comment line and is ignored, and you can use the backward slash (\) as a continuation to split an entry into more than one line.

On the Job 

A path name specified by <location> must be the legal absolute path to the file system on the server. For example, the location of a home directory for the user hdean on the senate computer should be listed as senate:/export/home/hdean, and not as senate:/home/hdean.

Note that the mount point /user/man in the example has three file systems associated to it. This feature can be used to implement fault tolerance. For example, you can associate multiple file systems configured as replicas to a mount point. In this case, if one file system fails, clients can be served from another one.

The mount points used in the direct maps file are specified in the named map, whereas the mount points defined in the master maps file are used by the indirect maps file.

The Indirect AutoFS Map

An indirect map uses the value of a key to identify the relationship of a mount point with a file system. Indirect maps are useful for accessing specific file systems, such as home directories. An example of an indirect map is the auto_home map that contains the entries to be mounted under /home. A typical auto_home file may look like the following:

    hdean dnc:/export/home/hdean    jedward dnc:/export/home/jedward    hclinton dnc:/export/home/hclinton    crice -rw,nosuid gop:/export/home/crice 

Entries in indirect maps file are in accordance with the following syntax:

    <key> [<mountOptions>] <location> 

The fields in the entry are described here:

  • <key>. Specifies a simple name without any slashes. This name combined with the mount point defined in the master map file will make the full path name for the mount point.

  • <mountOptions>. This specifies the options that will be applied to this particular mount.

  • <location>. This specifies the full path of file systems that can be mounted to the mount point.

Let's go through an example in order to demonstrate the use of indirect maps. The story of the indirect maps starts from the master maps file. Consider the following entry in the master maps file, /etc/auto_master:

    /home auto_home -nobrowse 

It states that the indirect maps for the mount point /home will be defined in the file /etc/auto_home. Now, consider the following entry in the /etc/auto_home file:

    crice -rw,nosuid gop:/export/home/crice 

The key crice here is a mount point path relative to the mount point defined in the auto_home entry in the auto_master file—that is, /home. Therefore, the full path to the mount point is /home/crice. Now, let's assume that this map file exists on the machine Washington where crice has her home directory listed in the passwd file as /home/crice. That means if crice logs into the Washington machine, the autofs mounts the /export/home/crice directory on the gop machine as her home directory.

The master map file has entries for the direct map and indirect map files. The mount point for the direct maps specified in the master map file (auto_master) is /-, which means the full path of the mount points for direct maps will be defined in the direct maps file. In an entry for an indirect map file in the master maps file, the root of the mount point path is defined, such as /home. The rest of the path will be defined in the indirect maps file, and both paths together will make up the full path of a mount point.

Although initially the automount service is started automatically, there will be situations when you may need to stop it and start it again.

Starting and Stopping the Automount Service

The automount service is started automatically when the system is booted. When the system is up and running, for some reason (e.g., changing the configuration), you may need to restart the service. To do that, all you need to know is that the autofs service, like many other services in Solaris 10, is managed by SMF and hence can be administered by the svcadm command.

The SMF service identifier for the autofs command is shown here:

    svc:/system/filesystem/autofs:default 

That means, for example, that you can restart the automount service by issuing the following command:

    svcadm restart system/filesystem/autofs 

To stop or start the service you can replace the action restart with enable or disable, respectively, as shown here:

    svcadm enable system/filesystem/autofs    svcadm disable system/filesystem/autofs 

The NFS service running on your system, like any other service, may run into problems, in which case you will need to troubleshoot it.




Sun Certified System Administrator for Solaris 10 Study Guide Exams 310-XXX & 310-XXX
Sun Certified System Administrator for Solaris 10 Study Guide Exams 310-XXX & 310-XXX
ISBN: N/A
EAN: N/A
Year: 2005
Pages: 168

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net