Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
Installing and Administering NFS Services with 10.20 ACE and HWE: HP 9000 Networking > Chapter 2 Configuring and Administering NFS

Configuring and Administering AutoFS

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Index

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.

NOTE: SAM does not support specifying maps or directories on the automount command line. SAM finds AutoFS maps only if they are listed in the master map. SAM recognizes automounted directories only if they are listed in an AutoFS map.

To Migrate from the Automounter to AutoFS

The 10.20 ACE and HWE replace the old automounter with AutoFS, which has the following advantages over the old automounter:

  • AutoFS can be used to mount any type of file system, including NFS Protocol Version 3. (The old automounter can be used only for NFS PV2.)

  • With AutoFS the configured mount points are the actual mount points. (The old automounter mounted directories under /tmp_mnt and creates symbolic links from the configured mount points to the actual ones under /tmp_mnt.)

  • You do not have to stop AutoFS to change your automounter maps. The AutoFS daemon, automountd, runs continuously. When you make a change to an automounter map, you run the automount command, which reads the maps and then exits. (The old automounter had to be killed and restarted whenever you made a change to an automounter map.)

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:

  1. Move the /etc/rc.config.d/nfsconf file to /etc/rc.config.d.nfsconf.old.

  2. Copy the /usr/newconfig/etc/rc.config.d/nfsconf file to /etc/rc.config.d/nfsconf.

  3. Copy any options you had specified in the AUTO_OPTIONS variable to either the AUTOMOUNT_OPTIONS or the AUTOMOUNTD_OPTIONS variable. Remove obsolete options.

    The old automount daemon is replaced by the automount(1M) command and the automountd(1M) daemon. Each has its own set of options. Table 2-4 “Old Automount Command-Line Options Used By AutoFS” lists the options to the old automount command and the equivalent AutoFS command options. It also indicates which automount options are obsolete with AutoFS.

    Table 2-4 Old Automount Command-Line Options Used By AutoFS

    Old automount OptionEquivalent AutoFS Command OptionPurpose
    -D variable=valueautomountd -D variable=valueAssign value to environment variable.
    -f master_fileautomount -f master_fileUse master_file as local master map.
    -M mount_directoryObsolete with AutoFS.Automount directories under mount_directory instead of /tmp_mnt.
    -mObsolete with AutoFS.Ignore NIS auto.master map.
    -nObsolete with AutoFS.Allow automounts only of previously mounted target file systems.
    -Tautomountd -TEnable automount tracing.
    -tl durationautomount -t durationSpecify time before unmounting idle directories.
    -tm intervalObsolete with AutoFS.Specify interval between mount attempts.
    -tw intervalObsolete with AutoFS.Specify interval between unmount attempts.
    -vautomount -v
    automountd -v
    Verbose mode.

     

  4. Modify any scripts you have that kill and restart automount. The new AutoFS daemon, automountd, rarely needs to be restarted. If you need to make changes to your automounter maps, just run the automount program after modifying the maps. It is not a daemon, like the old automount process; it is a program that runs once to read the maps and then terminates.

For more information, see the automount(1M) or automountd(1M) man page.

To Understand How AutoFS Works

AutoFS consists of the following components:

  1. The automount command, for reading automounter maps into memory.

  2. The AutoFS file system.

  3. The automountd daemon, which automounts file systems when they are requested by users.

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.

To Automount All Exported Directories from Any Host Using the -hosts Map

  1. If you are using local files for your automounter maps, use an editor to add the following line to the automounter master map file, /etc/auto_master:

    /net      -hosts      nosuid

    If you are using NIS to manage your automounter maps, add the line to the master map file on the NIS master server, and then issue the following commands to rebuild the map and push it out to slave servers:

    cd /var/yp
    /usr/ccs/bin/make auto_master
  2. On each host that will use the map you have just modified, issue the following command to force AutoFS to read the modified map:

    /usr/sbin/automount

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.

CAUTION: Because the -hosts map allows NFS access to any reachable remote system, a user may inadvertently cause an NFS mount over X.25 or SLIP, which is unsupported, or through a slow router or gateway. Mounts over slow links may cause excessive retransmissions and degrade performance for all users.

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,

cd /net/sage/opt/frame

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.

Figure 2-4 Automounted Directories from -hosts Map—One Server

Automounted Directories from -hosts Map—One Server

If server thyme exports the directory /exports/proj1, and a user types the following command,

more /net/thyme/exports/proj1/readme

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.

Figure 2-5 Automounted Directories from -hosts Map—Two Servers

Automounted Directories from -hosts Map—Two Servers

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”.

To Decide Between Direct and Indirect NFS Automounts

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

Direct Map

Indirect Map

Advantage: A user can see the contents of a direct-mounted directory with the ls command. If the contents are not currently mounted, ls causes them to be mounted.

Disadvantage: If a user types ls to see the contents of an indirect-mounted directory, it appears empty unless its subdirectories are currently mounted. The user must cd to a subdirectory or type ls subdirectory to cause it to be mounted.

Advantage: Direct-mounted automounted directories can share the same parent directory with local or standard-mounted files and directories.

Disadvantage: An indirect map hides any local, standard-mounted, or direct-mounted files or directories underneath the mount point for the map.

Disadvantage: If you add or remove mounts in a direct map, or if you change the local mount point for an existing mount in a direct map, you have to force AutoFS to reread its maps or reboot your system before AutoFS sees the changes you made.

Advantage: If you modify an indirect map, AutoFS will see the changes the next time it mounts the directory, so you don't have to force AutoFS to reread its maps.

Disadvantage: When a user or program accesses a directory containing many direct mount points, all the directories are mounted, whether they are needed or not. This can cause a flurry of mount activity.

Advantage: When a user or program accesses a directory containing many indirect mount points, only directories that are already mounted appear.

Disadvantage: When automount reads a direct map, it creates an entry for each automounted directory in the internal mount table, /etc/mnttab. This can cause the mount table to become very large.

Advantage: When automount reads an indirect map, it creates only one entry for the entire map in the internal mount table, /etc/mnttab. Additional entries are created as directories are actually mounted. The mount table takes up no more space than necessary, because only mounted directories appear in it.

 

How AutoFS Sets Up Direct and Indirect Mounts

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.

Figure 2-6 The Difference Between Direct Mounts and Indirect Mounts

The Difference Between Direct Mounts and Indirect Mounts

To Mount a Remote Directory Using a Direct Automounter Map

  1. If you are using local files for your automounter maps, use an editor to open or create a direct map in the /etc directory. The direct map is commonly called /etc/auto_direct. Add a line to the direct map with the following syntax:

    local_directory [mount_options] server:remote_directory

    If you are using NIS to manage your automounter maps, add the line to the direct map on the NIS master server.

  2. If you are using local files for your automounter maps, use an editor to open or create the automounter master map in the /etc directory. The master map should be called /etc/auto_master. If you are using NIS, open the master map on the NIS master server.

    If the direct map you just modified is not listed in the automounter master map, add the following line to the master map:

    /-  direct_map_name  [mount_options]
  3. If you are using NIS to manage your automounter maps, issue the following commands on the NIS master server to rebuild the maps and push them to the slave servers:

    cd /var/yp
    /usr/ccs/bin/make auto_master auto_direct
  4. On each host that will use the map you have just modified, issue the following command to force AutoFS to read the modified map:

    /usr/sbin/automount

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.

CAUTION: Do not automount a remote directory on a local directory that is a symbolic link.

If you are using NIS to manage your automounter maps, make sure the local mount point is different from the exported directory on the server. If they are the same, the server may attempt to mount its exported directory over itself, and the directory will become unavailable.

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.

Example File Entries for Direct Automounts

Following are example lines from an automounter direct map on NFS client sage. The sharp sign (#) indicates a comment line.

# /etc/auto_direct file
# local mount point mount options remote server:directory

/auto/project/specs -nosuid thyme:/export/project/specs
/auto/project/budget -nosuid basil:/export/FY94/proj1

Following are example lines from the automounter master map on NFS client sage.

# /etc/auto_master file
# local mount point map name mount options

/- /etc/auto_direct

Figure 2-7 “Example of Direct Mounts” illustrates how the AutoFS sets up the direct mounts for this configuration.

Figure 2-7 Example of Direct Mounts

Example of Direct Mounts

To Mount a Remote Directory Using an Indirect Automounter Map

  1. If you are using local files for your automounter maps, use an editor to open or create an indirect map in the /etc directory. Add a line with the following syntax to the indirect map:

    local_subdirectory [mount_options] server:remote_directory

    If you are using NIS to manage your automounter maps, add the line to an indirect map on the NIS master server.

  2. If you are using local files for your automounter maps, use an editor to open or create the automounter master map in the /etc directory. The master map should be called /etc/auto_master. If you are using NIS, open the master map on the NIS master server.

    If the indirect map you just modified is not listed in the automounter master map, add the following line to the master map:

    local_parent_directory indirect_map_name [mount_options]
  3. If you are using NIS to manage your automounter maps, issue the following commands on the NIS master server to rebuild the maps and push them to the slave servers:

    cd /var/yp
    /usr/ccs/bin/make auto_master indirect_mapname
  4. If you modified the automounter master map, issue the following command on each host that will use the map, to force AutoFS to read the modified master map:

    /usr/sbin/automount

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.

CAUTION: The local_subdirectory and local_parent_directory must not be symbolic links.

If you are using NIS to manage your automounter maps, make sure the local mount point is different from the exported directory on the server. If they are the same, the server may attempt to mount its exported directory over itself, and the directory will become unavailable.

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.

Example File Entries for Indirect Automounts

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.

# /etc/auto_desktop file
# local mount point mount options remote server:directory

draw -nosuid thyme:/export/apps/draw
write -nosuid basil:/exprort/write

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.

# /etc/auto_master file
# local mount point map name mount options

/- /etc/auto_direct
/nfs/desktop /etc/auto_desktop

Figure 2-8 “How AutoFS Sets Up Indirect Mounts” illustrates how AutoFS sets up the indirect mounts for this configuration.

Figure 2-8 How AutoFS Sets Up Indirect Mounts

How AutoFS Sets Up Indirect Mounts

To Configure Multiple (Replicated) Servers for an Automounted Directory

  1. Follow the instructions in “To Mount a Remote Directory Using a Direct Automounter Map” or “To Mount a Remote Directory Using an Indirect Automounter Map”.

  2. In the direct or indirect map, modify the line that mounts the remote directory so that multiple servers are listed.

    • If the remote directory has a different name on the different servers, use a syntax like the following example from a direct map:

      /nfs/proj2/schedule -ro  broccoli:/export/proj2/schedule \
      cauliflower:/proj2/FY94/schedule

      AutoFS reads this entry as one line. The line has been broken for readability, and the backslash (\) tells AutoFS that the line continues after the line break.

    • If the remote directory has the same name on every server, use a syntax like the following example from an indirect map:

      man  -ro  broccoli,cabbage,cauliflower:/usr/share/man
    • You can assign weights to the various servers, by specifying a number in parentheses after each server name. The lower the weight number, the more likely the server is to be selected.

      man -ro broccoli(1),cabbage(2),cauliflower(3):/usr/share/man

      Servers with no weight specified have a default weight of zero (most likely to be selected).

      Server proximity is more important than the weights you assign. A server on the same network segment as the client is more likely to be selected than a server on another network segment, regardless of the weights you assign.

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.

To Use Environment Variables as Shortcuts in Automounter Maps

  1. Use an environment variable anywhere in a direct or indirect automounter map except the first field, which specifies the local mount point. An environment variable must be preceded by a dollar sign ($) or enclosed in curly braces {}. The following direct map uses a variable called HOST:

    /private_files  sage:/export/private_files/$HOST
  2. Add the -D option to the AUTOMOUNTD_OPTIONS variable in the /etc/rc.config.d/nfsconf file to assign a value to the variable, as in the following example:

    AUTOMOUNTD_OPTIONS="-D HOST='hostname'"

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.

To Use Wildcard Characters as Shortcuts in Automounter Maps

  1. Use the asterisk (*) in an indirect map as a wildcard character to represent the local subdirectory, when you want the local subdirectory to be the same as the remote system name or the remote subdirectory.

  2. Use the ampersand (&) in a direct or indirect map as the remote system name or the remote subdirectory. Whatever is in the local directory name field will replace the ampersand. If you have used an asterisk to represent the local subdirectory, whatever replaces the asterisk (*) in the local subdirectory field also replaces the ampersand (&) in the remote system name or remote subdirectory field.

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.

# /etc/auto_master file
# local mount point map name mount options

/home /etc/auto_home nosuid

Following is the line from the automounter indirect map /etc/auto_home that mounts users' home directories on demand.

# /etc/auto_home file
# local mount point mount options remote server:directory

* basil:/export/home/&

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:

*         &:/export/home/&

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,

*           basil:/export/home/& 
charlie thyme:/export/home/charlie

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,

charlie     thyme:/export/home/charlie 
* basil:/export/home/&

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.

To Automount Users' Home Directories

NOTE: This configuration requires that users' home directories be located under the same directory on all systems in the network. On HP-UX release 9.x or earlier, home directories are usually located under /users. On HP-UX release 10.0 or later, home directories are usually located under /home. For this reason, you should not set up this configuration until all of your systems are running HP-UX release 10.0 or later.
  1. Make sure the machines where users' home directories are located are set up as NFS servers and are exporting the home directories. See “Configuring and Administering an NFS Server”.

  2. In the /etc/passwd file on the NFS clients, or in the NIS passwd map or NIS+ passwd table, configure the home directory of each user as the NFS mount point where the user's home directory will be moutnted. For example, if home directories are mounted under /home, Claire's home directory would be configured as /home/claire in the /etc/passwd file.

  3. If you are using local files for your automounter maps, create a file called /etc/auto_home on the NFS clients, and add a line to it for each user, like the following example. If you are using NIS to manage your automounter maps, add the lines to the /etc/auto_home file on the NIS master server.

    sammy       thyme:/export/home/&     nosuid

    The ampersand (&) character takes the value of the user name in each line. In the example above, user sammy's home directory is physically located on host thyme in /export/home/sammy.

  4. If you are using local files for your automounter maps, add the following line to the automounter master map, /etc/auto_master, on the NFS clients:

    /home  /etc/auto_home

    If you are using NIS to manage your automounter maps, add the line to the /etc/auto_master file on the NIS master server.

  5. If you are using NIS to manage your automounter maps, issue the following commands on the NIS master server to rebuild the maps and push them to slave servers:

    cd /var/yp
    /usr/ccs/bin/make auto_master
  6. Issue the following command, on each NFS client that will use these automounter maps, to force AutoFS to reread the maps:

    /usr/sbin/automount

Before you can automount home directories, you must enable AutoFS. See “To Enable AutoFS”.

Example of Automounting a User's Home Directory

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:

howard:MILQ3N1tBHXhM:828:Howard:/home/howard:/bin/ksh

When Howard logs into any NFS client, AutoFS recognizes /home as an AutoFS mount point, because it is configured in the master map:

/home  auto_home

AutoFS reads the auto_home map to find out how to mount Howard's home directory. It finds the following line:

howard       basil:/export/home/&     nosuid

AutoFS substitutes howard for the ampersand (&) character in that line:

howard    basil:/export/home/howard   nosuid

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:

Figure 2-9 Home Directories Automounted with Wildcards

Home Directories Automounted with Wildcards

To Automount Multiple Directories Simultaneously (Hierarchical Mounts)

  • Use an editor to create an entry with the following format in a direct or indirect automounter map. (Create the map, if necessary, and add it to the automounter master map.)

    local_dir   /local_subdirectory [-options] server:remote_directory \
    /local_subdirectory [-options] server:remote_directory \ . . .

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.

/our_project   /source   -ro    broccoli:/opt/proj1/src  \
/datafiles cauliflower:/opt/proj1/samples/data

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.

chap2 -nosuid   /text       sage:/our_book/chap2  \
/graphics basil:/our_book/artwork/chap2 \
/old sage:/our_book/oldfiles/chap2

To Automount a Directory Using CacheFS

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:

  1. On the NFS client host, issue the following command to create a CacheFS directory with the data structures necessary to allow a CacheFS mount:

    /usr/sbin/cfsadmin -c /cache_directory

    For example, if you had a mounted file system called /disk2, you could create a CacheFS directory called /disk2/cache with the following command:

    /usr/sbin/cfsadmin -c /disk2/cache
  2. Add a line for the automounted file system to the appropriate automounter direct or indirect map, as in the following examples:

    # direct map example:
    /usr/dist -ro,nosuid,fstype=cachefs,backfstype=nfs, \
    cachedir=/disk2/cache distserver:/export/dist
    # indirect map example:
    proj1 -nosuid,fstype=cachefs,backfstype=nfs,\
    cachedir=/disk2/cache \
    /src testbox1:/export/proj1/src
    /data testbox2:/export/proj1/data
  3. If you modified a direct map or the automounter master map, issue the following command, on each NFS client that will use the map, to force AutoFS to reread its maps:

    /usr/sbin/automount

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)”.

To Include an Automounter Map in Another Automounter Map

  • To include the contents of an automounter map in another automounter map, add a plus sign (+) before the map name, as in the following example:

    # /etc/auto_home file
    # local mount point mount options remote server:directory

    basil -nosuid basil:/export/home/basil
    +auto_home

Assume the /etc/auto_home map is listed in the master map with the following line:

/home           /etc/auto_home

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.

To Create a Hierarchy of Automounter Maps

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:

# auto_master map
# Directory Map Name

/org auto_org

The auto_org map looks like this:

finance    -fstype=autofs    auto_finance
marketing -fstype=autofs auto_marketing
legal -fstype=autofs auto_legal
research -fstype=autofs auto_research
eng -fstype=autofs auto_eng

And the engineering department's map, auto_eng, looks like this:

releases                      bigiron:/export/releases
tools mickey,minnie:/export/tools
source -fstype=autofs auto_eng_source
projects -fstype=autofs auto_eng_projects

A user in the "blackhole" project within engineering might use the following path:

/org/eng/projects/blackhole

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.

To Turn Off an Automounter Map with the -null Map

  1. Add a line with the following syntax to the automounter master map:

    local_directory -null
  2. If AutoFS is running, issue the following command, on each client that will use the map, to force AutoFS to reread its maps:

    /usr/sbin/automount

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,

/home -null

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:

/home /etc/auto_ourhome

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.

To Enable AutoFS

  1. In the /etc/rc.config.d/nfsconf file, make sure the NFS_CLIENT and AUTOMOUNT variables are set to 1, as follows:

    NFS_CLIENT=1 
    AUTOMOUNT=1
  2. Issue the following command to run the NFS client startup script:

    /sbin/init.d/nfs.client start

    or

    /sbin/init.d/autofs start

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.

To Disable AutoFS

  1. In the /etc/rc.config.d/nfsconf file, make sure the NFS_CLIENT and AUTOMOUNT variables are set to 1, as follows:

    NFS_CLIENT=1 
    AUTOMOUNT=1
  2. Issue the following command to run the AutoFS shutdown script:

    /sbin/init.d/autofs stop
CAUTION: Do not kill the automound daemon with the kill command. It does not die gracefully. It does not unmount AutoFS mount points before it dies. Use the autofs stop script to ensure that automound dies cleanly.

To Verify Your AutoFS Configuration

  1. Type the following command to change the current working directory to an automounted directory:

    /usr/bin/cd local_directory

    where local_directory is the configured mount point in the automounter map.

  2. Type the following command to verify that the contents of the remote directory have been mounted under the local mount point:

    /usr/bin/ls

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,

# /etc/auto_master file
# local mount point map name mount options

/nfs/desktop /etc/auto_desktop
# /etc/auto_desktop file
# local mount point mount options remote server:directory

draw -nosuid thyme:/export/apps/draw
write -nosuid basil:/export/write

and you issue the following commands,

cd /nfs/desktop
ls

the ls command will produce no output, because the draw and write subdirectories are not currently mounted. However, if you issue the following commands,

cd /nfs/desktop/write
cd /nfs/desktop/draw
cd ..
ls

the ls command will display

draw         write

If AutoFS is not mounting your configured directories, see Chapter 7 “Troubleshooting NFS Services”.

To Modify or Remove (Unmount) an Automounted Directory

  1. If you are planning to remove an automounted directory, issue the following command to determine whether the directory is currently in use:

    /usr/sbin/fuser -cu local_mount_point

    This command lists the process IDs and user names of everyone using the mounted directory.

  2. Warn any users to cd out of the directory, and kill any processes that are using the directory, or wait until the processes terminate. You can issue the following command to kill all the processes using the mounted directory:

    /usr/sbin/fuser -ck local_mount_point
  3. Use an editor to make your changes to the direct or indirect map.

  4. If you removed the last entry in the direct or indirect map, remove the line for that map in the automounter master map.

  5. If you made any changes to the master map, or if you added or modified a local mount point in a direct map, run the following command to force AutoFS to reread its maps:

    /usr/sbin/automount
Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1998 Hewlett-Packard Development Company, L.P.