| United States-English |
|
|
|
![]() |
NFS Services Administrator's Guide: HP-UX 11i version 2 > Chapter 2 Configuring
and Administering NFS ServicesConfiguring 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 (10 minutes, by default). This section documents the tasks involved in configuring AutoFS to get AutoFS up and running on your system. Before configuring AutoFS, see “Deciding Between Standard-Mounted Directories and Automounted Directories”. The following topics are covered in this section: AutoFS has been enhanced to provide the features of the SUN ONC+ version 2.3 AutoFS product on HP-UX release 11i version 2. These new features include the following:
With AutoFS 2.3 implementation, both performance and scalability are significantly improved. Beginning with the HP-UX Extension Pack Release, August 1998 (for HP-UX 11.0), the new automounting utility, AutoFS, was available. Now, AutoFS has been enhanced to include the features of the SUN ONC+ 2.3 AutoFS on the HP-UX release 11i verison 2 (release 11.23). The old automounter is obsoleted from the HP-UX release 11i version 2. AutoFS mounts directories automatically when users or processes request access to them. It unmounts them automatically after they have been idle for a period of time (10 minutes, by default). AutoFS has the following advantages over old Automounter:
AutoFS 2.3 has the following advantages over AutoFS 1.2:
With AutoFS 2.3 implementation in HP-UX release 11i verion 2, the following tasks are automatically done to update all users from the Automounter configuration to AutoFS with no user intervention necessary:
AutoFS consists of the following components:
The automount command is invoked at system startup. It reads the AutoFS 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. 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 automountd daemon is completely independent from the automount command. Because of this separation, it is possible to add, delete, or change AutoFS 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 AutoFS 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 10 minutes, AutoFS unmounts it. See the following man pages for more information on AutoFS: automount (1M), automountd (1M).
Previous releases of AutoFS would mount an entire set of file systems if they were hierarchically related. With AutoFS 2.3 implementation, only the file systems that are being accessed are mounted. Other file systems hierarchically related to these file systems are mounted when they are needed. For example, if you have the following AutoFS master and direct maps on NFS client sage:
and a user on NFS client, sage, types the following command:
Only /auto/project/specs subdirectories are mounted as on-demand mounting. Figure 2-4 shows the automounted file structure after the user’s command is issued. AutoFS 2.3 allows a user to see the potential mount points for indirect maps without having to actually mount each file system.Browsing is turned on by default for all indirect AutoFS maps.To disable browsing, you can specify the -nobrowse option for each indirect map that you do not want to be browseable. The automountd with -n option is used to disable browsing for all indirect maps without having to specify the -nobrowse option for each indirect map. For example, if you have the following AutoFS master and indirect maps on NFS client sage:
and you issue the following commands,
the ls command will diplay
because the test and apps subdirectories are the potential mount points (browsability), but not currently mounted. However, if you issue the following commands,
Now, both test and apps subdirectories are mounted. By default, AutoFS uses the loopback LOFS mount for locally mounted file systems. AutoFS 2.3 provides an option to allow the loopback NFS mounts for the local mount. The automountd command with -L option is used to enable the loopback NFS mounts for locally mounted file systems. This option should be used in the HA NFS environments. Table 2-5 lists the options for the automount command available for AutoFS 2.3. Table 2-5 Automount Command-Line Options available for AutoFS 2.3
Table 2-6 lists the automountd command line options available for AutoFS 2.3. Table 2-6 Automountd Command-Line Options available for AutoFS 2.3
You must enable AutoFS before any directories can be automounted. The -hosts map is a built-in AutoFS map; you do not have to create it. The -hosts map causes AutoFS to mount exported directories from any NFS server found in the hosts database 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 AutoFS master map. (The conventional mount point for the -hosts map is /net.) Then AutoFS mounts the exported directories from that server which are accessed with on-demand mounting. Directories will stay mounted until they are left idle for ten minutes. The ten minute default can be changed by adding the -t duration option to the AUTOMOUNT_OPTIONS variable in the /etc/rc.config.d/nfsconf file or by running the automount command with the -t option from the command line. 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 6 “Configuring the Name Service Switch”. 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 is mounted under /sage using on-demand mounting. Figure 2-5 “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 using on-demand mounting. Figure 2-6 “Automounted Directories from -hosts Map—Two Servers” shows the automounted directory structure after the user’s second command. Before you automount a remote directory, decide whether you want to use a direct or indirect AutoFS map. Table 2-7 “Direct vs. Indirect AutoFS Map Types” lists the advantages and disadvantages of each type of map. 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 AutoFS mount points. However, if your automounted directory must share the same parent directory with local or standard-mounted directories, you should choose a direct map. Table 2-7 “Direct vs. Indirect AutoFS Map Types” lists the advantages and disadvantages of direct and indirect AutoFS maps. Table 2-7 Direct vs. Indirect AutoFS 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-7 “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 configured as the mount point is not empty, any local files or directories in it will be hidden and inaccessible while the automounted filesystem is mounted over it.
The mount options that you can specify in the AutoFS maps are the same ones that you would use for the type of filesystem you attempt to automount. The mount options are the same ones used for standard NFS mounted directories. For detailed mount options, see “Changing 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 AutoFS maps, you can have only one direct map in your configuration. If you plan to use NIS to manage your AutoFS 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 AutoFS master map begins with 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 6 “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. Automounted directories stay mounted until they are left idle for ten minutes. The ten minute default can be changed by adding the -t duration option to the AUTOMOUNT_OPTIONS variable in the /etc/rc.config.d/nfsconf file or by running the automount command with the -t option from the command line. 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. For more information on AutoFS configuration, see man page automount(1M).
Following are example lines from an AutoFS direct map on NFS client sage. The sharp sign (#) indicates a comment line.
Following are example lines from the AutoFS master map on NFS client sage.
Figure 2-8 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 that you can specify in the AutoFS maps are the same ones that you would use for the type of filesystem you attempt to automount. The mount options are the same ones used for standard NFS mounted directories. See “Changing 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 AutoFS 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 AutoFS 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 AutoFS master map begins with 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 6 “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 ten minutes. The ten minute default can be changed by adding the -t duration option to the AUTOMOUNT_OPTIONS variable in the /etc/rc.config.d/nfsconf file or by running the automount command with the -t option from the command line. You must enable AutoFS before any directories can be automounted. See “Enabling 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. For more information on AutoFS configuration, see man page automount(1M).
Following are example lines from an AutoFS 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 AutoFS master map on NFS client sage. The master map also includes an entry for the direct map /etc/auto_direct.
Figure 2-9 “How AutoFS Sets Up NFS Indirect Mounts” illustrates how AutoFS sets up the indirect mounts for this configuration. An executabe map has its entries generated dynamically by a program or a script. 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. When AutoFS daemon locates a map and its execute bit is set, then intead of opening the file and searching for an entry, the AutoFS daemon executes the file as a program and passes the key to be located within the map as an argument. The executable AutoFS maps return a map entry on the standard output . If they cannot supply a map entry for the key, they should return nothing.You can list executable AutoFS maps in the master map, or include them in local AutoFS map files. For example,the following executable map, implemented as a shell script, emulates the AutoFS built-in -hosts map for /net. It obtains a list of exported filesystems from an NFS server (its name given as the key argument), formats the pathnames into a multiple-mount map entry, and sorts the list to order the mounts correctly into a top-down hierarchy:
Directories with multiple servers should be mounted read-only to ensure that the versions remain the same on all the servers. The server chosen for the mount is the one with the strongest preference based on a sorting order. The sorting order used gives strongest preference to servers on the same local subnet, servers on the local net are given the second strongest preference.So, 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. Among servers equally far away, response times will determine the order if no wighting factors are used. 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 poll than one that is heavily loaded, so the directory will be mounted from the server that is not busy. If the list of multiple servers contains some servers using the NFS Version 2 Protocol and some servers using the NFS Version 3 Protocol, then AutoFS chooses a subset of the list having only servers with the same protocol. This subnet is formed of servers using the NFS Version 3 Protocol, unless there are no such servers on the list or there is a server using NFS Version 2 Protocol that has the strongest preference.
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 AutoFS 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 AutoFS 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 AutoFS 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 AutoFS master map /etc/auto_master that lists the indirect map /etc/auto_home.
Following is the line from the AutoFS 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, see man page automount(1M).
Before you can automount home directories, you must enable AutoFS. See “Enabling 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-10 “Home Directories Automounted with Wildcards” illustrates this configuration: Use an editor to create an entry with the following format in a direct or indirect AutoFS map. (Create the map, if necessary, and add it to the AutoFS master map.)
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 whenever anyone requests access to both of them, they are mounted for on-demand mounting.
Here is another example from an indirect map. In this example, the same mount option (nosuid) applies to all three automounted directories.
Assume the /etc/auto_home map is listed in the master map with the following line:
This example causes the following: 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 directory 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 6 “Configuring the Name Service Switch”. You can include an AutoFS map inside a local file but not inside an NIS map. See the following man pages for more information: automount(1M) or nsswitch.conf(4). 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 AutoFS map. Each department administers its own AutoFS map for its subdirectory. The AutoFS master map needs only 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 AutoFS 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 AutoFS 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. To use a local AutoFS master map, make sure the AUTOMOUNT_OPTIONS variable in /etc/rc.config.d/nfsconf includes the string -f $AUTO_MASTER, and make sure the AUTO_MASTER variable is set to the name of your local AutoFS master map file. For more information, see man page automount(1M). AutoFS 2.3 now supports the integration with HP CIFS Client to enable the automatic mounting and unmounting of CIFS filesystems. HP CIFS Client must be installed and configured on the system along with AutoFS 2.3 for this feature to be enabled. More information on CIFS Client installation and configuration can be found in HP CIFS Client Administrator’s Guide. AutoFS 2.3 only supports the automatic mounting of CIFS filesystems with direct and indirect map; it does not support CIFS filesystem mounts with special or executable map files, or with multiple (replicated) servers. The following procedures must be used to use AutoFS with the HP CIFS Client:
Following are example lines from an AutoFS direct map on CIFS client mamoth. The sharp sign (#) indicates a comment line.
Following are example lines from the AutoFS master map on CIFS client mamoth:
Figure 2-11 “Example of CIFS Direct Mounts” illustrates how the AutoFS sets up the direct mounts for this configuration. Following are example lines from an AutoFS indirect map on CIFS client mamoth. 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 AutoFS master map on CIFS client mamoth. The master map also includes an entry for the direct map /etc/auto_direct.
Figure 2-12 illustrates how AutoFS sets up the indirect mounts for this configuration.
When AutoFS starts up, if your AUTOMOUNT_OPTIONS variable specifies a master map file with the -f filename option, AutoFS will look for a file by that name on the local host. It can also use the Name Service Switch to determine which name services you are using and find the master maps that are available from those name services. If your AUTOMOUNT_OPTIONS variable does not specify the -f filename option, AutoFS will consult the Name Service Switch configuration to determine where to look for your AutoFS master map. See the following man pages for more information: nsswitch.conf(4) or automount(1M).
If the directory is configured in an indirect map, issuing the ls command from the parent directory will display potential mount points (browsability). 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 diplay
because the draw and write subdirectories are the potential mount points(browsability), but not currently mounted. However, if you issue the following commands,
Now, both draw and write subdirectories are mounted(on-demand mounting). If AutoFS is not mounting your configured directories, see Chapter 8 “Troubleshooting NFS Services”.
AutoFS rarely needs to be restarted. In case there is a need to restart AutoFS, please use the following procedures to do it:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||