| United States-English |
|
|
|
![]() |
Installing and Administering NFS Services with 10.20 ACE and HWE: HP 9000 Networking > Chapter 2 Configuring and Administering
NFSConfiguring and Administering AutoFS |
|
This section tells you how to configure AutoFS. AutoFS mounts directories automatically when users or processes request access to them, and it unmounts them automatically after they have been idle for a period of time (five minutes, by default). Following are the tasks involved in configuring AutoFS. Tasks 3 and 16 alone will get AutoFS up and running on your system. Before configuring AutoFS, see “To Decide Between Standard-Mounted and Automounted Directories”.
This section tells you how to perform these tasks, by editing files and issuing HP-UX commands. However, Hewlett-Packard recommends that you use SAM to configure and administer AutoFS. SAM (System Administration Manager) is Hewlett-Packard's windows-based user interface for performing system administration tasks. To run SAM, type sam at the HP-UX prompt. SAM has an extensive online help facility.
The 10.20 ACE and HWE replace the old automounter with AutoFS, which has the following advantages over the old automounter:
If you were using the automounter before you installed the 10.20 ACE or HWE, you must perform the following tasks to migrate your automounter configuration to AutoFS:
For more information, see the automount(1M) or automountd(1M) man page. AutoFS consists of the following components:
The automount command is invoked at system startup. It reads the automounter master map to create the initial set of AutoFS mount points in the internal mount table, /etc/mnttab. The automounted file systems are not automatically mounted at startup. They are points under which file systems will be mounted later, when users request access to them. When AutoFS receives a request to mount a file system that is not currently mounted, it calls the automountd daemon, which actually mounts the requested file system. Once the file system is mounted, further access does not require any action from the automountd daemon. Unlike the old automounter, AutoFS mounts file systems at the configured mount points. It does not maintain its own directory of mount points with symbolic links into it the way the old automounter does. The automountd daemon is completely independent from the automount command. Because of this separation, it is possible to add, delete, or change automounter map information without having to stop and restart the automountd daemon. After system startup, when the AutoFS mount points are set up, you can modify the set of mount points by modifying the automounter maps and running the automount command to read them and modify the mount table accordingly. You do not have to stop and restart AutoFS. If an automounted file system has been idle for 5 minutes, AutoFS unmounts it. For more information on AutoFS, type man 1M automount or man 1M automountd at the HP-UX prompt.
The local mount point (/net) should not exist. You must enable AutoFS before any directories can be automounted. See “To Enable AutoFS”. The -hosts map is a "built-in" automounter map; you do not have to create it. The -hosts map causes AutoFS to mount all the exported directories from any NFS server on the network whenever a user or process requests access to one of the exported directories from that server.
When a user or process requests a directory from an NFS server, AutoFS creates a subdirectory, named after the NFS server, under the local mount point you configured in the automounter master map. (The conventional mount point for the -hosts map is /net.) Then AutoFS mounts all the exported directories from that server under the subdirectory it created. Directories will stay mounted until they are left idle for five minutes. The five minute default can be changed by adding the -t duration option to the AUTOMOUNT_OPTIONS variable in the /etc/rc.config.d/nfsconf file. For example, if server sage exports /opt and /apps, and a user on your NFS client types the following command,
the subdirectory /sage is created under /net, and /opt and /apps are mounted under /sage. Figure 2-4 “Automounted Directories from -hosts Map—One Server” shows the automounted file structure after the user's command. If server thyme exports the directory /exports/proj1, and a user types the following command,
the subdirectory /thyme is created under /net, and /exports/proj1 is mounted under /thyme. Figure 2-5 “Automounted Directories from -hosts Map—Two Servers” shows the automounted directory structure after the second user's command. The -hosts map is an indirect map. It uses the hosts database (the /etc/hosts file, the NIS hosts map, or BIND [DNS]) to find a host on the network. The Name Service Switch configuration determines which name services will be searched for host information. See Chapter 5 “Configuring the Name Service Switch”.
In general, an indirect map is better than a direct map, because it is easier to modify while AutoFS is running, and because it does not cause "mount storms" in directories with many automount points. However, if your automounted directory must share the same parent directory with local or standard-mounted directories, or if users must always get a complete list of available files and directories when they issue the ls command, you should choose a direct map. Table 2-5 “Direct vs. Indirect Automounter Map Types” lists the advantages and disadvantages of direct and indirect automounter maps. Table 2-5 Direct vs. Indirect Automounter Map Types
The automounts configured in a direct map may be mounted in various places in the local file system; they do not have to be located under the same parent directory. The automounts configured in an indirect map are all mounted under the same local parent directory. Figure 2-6 “The Difference Between Direct Mounts and Indirect Mounts” shows the difference between direct mounts and indirect mounts on an NFS client.
The local directory you configure as the mount point should be empty or non-existent. AutoFS will create any non-existent directories between the root directory and the configured mount point. If the local directory you configure is not empty, any local files or directories in it will be hidden and inaccessible while the remote directory is mounted over it.
The mount options are the same ones used for standard NFS-mounted directories. See “To Change the Default Mount Options” for a list of mount options. The bg option cannot be used for an automounted directory. The mount options configured in the direct map override the ones in the master map if there is a conflict. You can configure all your direct automounts in the same map. Many people use the file name /etc/auto_direct for their direct map. If you plan to use NIS to manage your automounter maps, you can have only one direct map in your configuration. If you plan to use NIS to manage your automounter maps, and your file system does not allow file names longer than 14 characters, keep the map name to 10 characters or fewer. If the direct map name in the automounter master map contains a slash (/), AutoFS assumes it is a local file. If it does not contain a slash, AutoFS uses the Name Service Switch to determine whether it is a file or an NIS map. See Chapter 5 “Configuring the Name Service Switch”. Before you can mount a remote directory on your system, the remote system where the directory is located must be configured as an NFS server and must export the directory. You must enable AutoFS before any directories can be automounted. See “To Enable AutoFS”. Automounted directories stay mounted until they are left idle for five minutes. The five minute default can be changed by adding the -t duration option to the AUTOMOUNT_OPTIONS variable in the /etc/rc.config.d/nfsconf file. If you change the mount options, the remote server name, or the remote directory name for an existing direct mount while AutoFS is running, the changes you made will take effect the next time the directory is mounted. However, if you change the local directory name in the direct map, or if you change the master map, these changes will not take effect until you issue the automount command to force AutoFS to reread its maps. You can list executable automounter maps in the master map, or include them in local automounter map files. Executable automounter maps return a map entry on standard output when automountd supplies them with a key to look up. If they cannot supply a map entry for the key, they should return nothing. AutoFS determines whether a map is executable by checking whether the execute bit is set in its permissions string. If a map is not executable, make sure its execute bit is not set. Automounted directories in the /etc/mnttab file contain the keyword ignore to prevent them from being mounted at boot time. For more information on AutoFS configuration, type man 1M automount at the HP-UX prompt. Following are example lines from an automounter direct map on NFS client sage. The sharp sign (#) indicates a comment line.
Following are example lines from the automounter master map on NFS client sage.
Figure 2-7 “Example of Direct Mounts” illustrates how the AutoFS sets up the direct mounts for this configuration.
The local_subdirectory specified in the indirect map is the deepest subdirectory in the local directory pathname. For example, if you were mounting a remote directory on /nfs/apps/draw, the local_subdirectory specified in the indirect map would be draw. The local_parent_directory specified in the master map is all but the deepest subdirectory in the local directory pathname. For example, if you were mounting a remote directory on /nfs/apps/draw, the local_parent_directory specified in the master map would be /nfs/apps. The local_parent_directory and local_subdirectory should not exist; AutoFS will create them when it mounts the remote directory. If the local_parent_directory or local_subdirectory contains files or directories, they will be hidden beneath the remote directory when it is mounted.
The mount options are the same ones used for standard NFS-mounted directories. See “To Change the Default Mount Options” for a list of mount options. The bg option cannot be used for an automounted directory. The mount options configured in the indirect map override the ones in the master map if there is a conflict. You can configure indirect automounts in the same indirect map only if their local_parent_directory, as specified in the automounter master map, is the same. For example, indirect mounts with the local mount points /nfs/apps/draw and /nfs/apps/word could be configured in the same indirect map. Indirect maps are usually called /etc/auto_name, where name is something that helps you remember what is configured in the map. If you plan to use NIS to manage your automounter maps, and if your file system does not support file names longer than 14 characters, keep your indirect map names to 10 characters or fewer. If the indirect map name in the automounter master map contains a slash (/), AutoFS assumes it is a local file. If it does not contain a slash, AutoFS uses the Name Service Switch to determine whether it is a file or an NIS map. See Chapter 5 “Configuring the Name Service Switch”. Before you can mount a remote directory on your system, the remote system where the directory is located must be configured as an NFS server and must export the directory. Automounted directories stay mounted until they are left idle for five minutes. The five minute default can be changed by adding the -t duration option to the AUTOMOUNT_OPTIONS variable in the /etc/rc.config.d/nfsconf file. You must enable AutoFS before any directories can be automounted. See “To Enable AutoFS”. If AutoFS is already running when you add an indirect mount to your configuration, you do not have to run the automount command unless you change the master map. Any changes you make to an existing indirect map will take effect the next time AutoFS mounts the directory. However, changes to the master map will not take effect until you issue the automount command to force AutoFS to reread its maps. You can list executable automounter maps in the master map, or include them in local automounter map files. Executable automounter maps return a map entry on standard output when automountd supplies them with a key to look up. If they cannot supply a map entry for the key, they should return nothing. AutoFS determines whether a map is executable by checking whether the execute bit is set in its permissions string. If a map is not executable, make sure its execute bit is not set. Automounted directories in the /etc/mnttab file contain the keyword ignore to prevent them from being mounted at boot time. For more information on AutoFS configuration, type man 1M automount at the HP-UX prompt. Following are example lines from an automounter indirect map on NFS client sage. The sharp sign (#) indicates a comment. Everything from the sharp sign to the end of the line is ignored by AutoFS.
Following are example lines from the automounter master map on NFS client sage. The master map also includes an entry for the direct map /etc/auto_direct.
Figure 2-8 “How AutoFS Sets Up Indirect Mounts” illustrates how AutoFS sets up the indirect mounts for this configuration.
Directories with multiple servers should be mounted read-only to ensure that the versions remain the same on all the servers. When a user requests access to a directory with multiple servers configured, AutoFS polls all the servers simultaneously and mounts the directory from the server that responds first. Multiple servers give users reliable access to a mounted directory, because if one server is down, the directory can be mounted from another. Also, multiple servers provide some load balancing across the network; a server that is not busy will respond more quickly to AutoFS's poll than one that is heavily loaded, so the directory will be mounted from the server that is not busy. If you configure multiple servers on both sides of a gateway, a server on the same side of the gateway as the NFS client will always be used, because it will always respond to the client's poll before the servers on the other side of the gateway.
The example shown above assumes that NFS server sage has subdirectories in its /export/private_files directory that are named after the hosts in its network. Every host in the network can use the same automounter map and the same AUTOMOUNTD_OPTIONS definition to mount its private files from server sage. For example, when AutoFS starts up on host basil, it assigns the value basil to the HOST variable. Then, when someone requests access to the local /private_files directory on basil, AutoFS mounts /export/private_files/basil from server sage. Any environment variable that is set to a value may be used in an automounter map. If you do not set the variable with the -D option in /etc/rc.config.d/nfsconf, AutoFS uses the current value of the environment variable on the local host. You cannot use environment variables in the automounter master map.
You cannot use the asterisk (*) wildcard in a direct map. The following example automounts users' home directories. The home directories are physically located on NFS server basil, under the remote directory /export/home. On the local NFS client, the home directories will be mounted under /home. Following is the line from the automounter master map /etc/auto_master that lists the indirect map /etc/auto_home.
Following is the line from the automounter indirect map /etc/auto_home that mounts users' home directories on demand.
A user's home directory is configured in the /etc/passwd file as /home/username. For example, the home directory of user terry is /home/terry. When Terry logs in, AutoFS looks in the /etc/auto_home map and substitutes terry for both the asterisk and the ampersand. AutoFS then mounts Terry's home directory from /export/home/terry on server basil to /home/terry on the local NFS client. The ampersand character can be used to represent both the remote server and the remote subdirectory, in the same line of the indirect map. For example, if users' home directories are physically located on many different servers, but the directory under which the home directories are located is called /export/home/servername on all the servers, the following line in the /etc/auto_home map will mount all users' home directories from any server:
If the home directory of user terry is configured in the /etc/passwd file as /home/basil/terry, when Terry logs in, AutoFS will mount the remote directory /export/home/basil from server basil on the local directory /home/basil. The line with the asterisk and ampersand should be the last line in an indirect map. AutoFS reads the lines in the indirect map sequentially until it finds a match for the requested local subdirectory. The asterisk (*) matches any subdirectory, so AutoFS stops reading at the line with the asterisk, because it has found a match. Any lines after the asterisk are never read. For example, if the /etc/auto_home map contains the following lines,
AutoFS attempts to mount /export/home/charlie from host basil. The asterisk is a match for charlie, so AutoFS looks no further and never reads the second line. However, if the /etc/auto_home map contains the following lines,
AutoFS will mount Charlie's home directory from host thyme and everyone else's home directory from host basil. For more information on AutoFS configuration, type man 1M automount at the HP-UX prompt.
Before you can automount home directories, you must enable AutoFS. See “To Enable AutoFS”. User Howard's home directory is located on NFS server basil, where it is called /export/home/howard. On all the machines in the network, Howard has the following entry in the /etc/passwd file:
When Howard logs into any NFS client, AutoFS recognizes /home as an AutoFS mount point, because it is configured in the master map:
AutoFS reads the auto_home map to find out how to mount Howard's home directory. It finds the following line:
AutoFS substitutes howard for the ampersand (&) character in that line:
AutoFS mounts /export/home/howard from server basil to the local mount point /home/howard on the NFS client. Figure 2-9 “Home Directories Automounted with Wildcards” illustrates this configuration:
The backslash (\) characters tell AutoFS to ignore the line breaks, so this entry is effectively all one line. Map entries with this format cause all the remote directories on the line to be mounted at the same time. For example, the following entry from a direct map mounts the source code and the data files for a project at the same time; whenever anyone requests access to either one, they are both mounted.
Because the directories are always mounted simultaneously, you can use relative pathnames to move from one to another, for example, cd ../source Here is another example from an indirect map. In this example, the same mount option (nosuid) applies to all three automounted directories.
Before you mount a file system, you must decide whether to use CacheFS. CacheFS improves read performance for data that will be read more than once. It does not improve write performance at all. Good choices for cached file systems include man pages and executable programs, which are read multiple times and rarely modified. A bad choice is /var/mail, which is modified frequently but is typically read only once and then thrown away. Follow these steps to automount a directory with CacheFS:
You can specify caching in an NIS automounter map only if all clients who will use the map have their caching directory set up in the same location (/disk2/cache, in the examples). For more informationon CacheFS, see Chapter 3 “Configuring the Cache File System (CacheFS)”. Assume the /etc/auto_home map is listed in the master map with the following line:
This example has the following effect: If a user logs in whose home directory is in /home/basil, AutoFS will mount the directory /export/home/basil from host basil. If a user logs in whose home directroy is in /home/sage, /home/thyme, or any subdirectory of /home other than basil, AutoFS will consult the NIS map auto_home for information on mounting the user's home directory. The plus sign (+) tells AutoFS to look in a different map for the information it needs to mount the directory. If the map name following the plus sign begins with a slash, AutoFS assumes it is a local file. If the map name contains no slashes, AutoFS uses the Name Service Switch to determine whether it is a file or an NIS map. See Chapter 5 “Configuring the Name Service Switch”. You can include an automounter map inside a local file but not inside an NIS map. For more information, type man 1M automount or man 4 nsswitch.conf. An organization made up of many departments may wish to organize a shared automounted directory structure. In the following example, the shared top-level directory is called /org. The /org directory contains several subdirectories, listed in the auto_org automounter map. Each department administers its own automounter map for its subdirectory. The automounter master map needs just a single entry for /org:
The auto_org map looks like this:
And the engineering department's map, auto_eng, looks like this:
A user in the "blackhole" project within engineering might use the following path:
Beginning with the AutoFS mount at /org, the evaluation of this path would dynamically create additional AutoFS mounts at /org/eng and /org/eng/projects. Since AutoFS mounts are created only when needed, changes to maps require no action to become visible at the user's workstation. The automount command needs to be run only when changes are made to the master map or to a direct map. Hierarchical automounter maps provide a framework within which large shared filesystems can be organized. Together with NIS, which allows you to share information across administrative domains, the maintenance of the shared namespace can be effectively decentralized. The -null option "turns off" the map that is mounted on local_directory. For example, if the NIS auto_master map mounts the auto_home map on /home, and you include the following line in your local /etc/auto_master file,
the NIS auto_home map will not be used on your system. The -null option is useful for turning off NIS automounter maps that do not apply to your host. You can also replace NIS maps with local maps, as in the following example from /etc/auto_master:
Because AutoFS reads the local /etc/auto_master file before the NIS auto_master map, this entry causes AutoFS to look for mount information in the local file /etc/auto_ourhome instead of the auto_home NIS map. For more information, type man 1M automount. The nfs.client start script will start any NFS client processes that are not already running, including AutoFS. If you want to start only AutoFS, use the autofs start script. When AutoFS starts up, it uses the Name Service Switch to determine which name services you are using and to find the master maps that are available from those name services. For more information, type man 4 nsswitch.conf or man 1M automount at the HP-UX prompt.
If the directory is configured in an indirect map, issuing the ls command from the parent directory will display nothing. When you cd to a subdirectory configured in the indirect map, or issue the command ls subdirectory, the subdirectory will be mounted. Therefore, if you have the following indirect map configuration,
and you issue the following commands,
the ls command will produce no output, because the draw and write subdirectories are not currently mounted. However, if you issue the following commands,
the ls command will display
If AutoFS is not mounting your configured directories, see Chapter 7 “Troubleshooting NFS Services”.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||