UNIX System Administration Handbook - Evi Nemeth [303]
• amd is based on the concept that each server has one or more filesystems, with each filesystem containing one or more volumes (a coherent set of files). This makes the handling of subdirectories more straightforward than with automount.
• amd won’t eat all the popcorn or send you out to get Milk Duds.
amd maps
The amd map format is extremely flexible and allows the same configuration file to be used on many machines. Map entries can contain conditionals that activate them only in specific contexts (e.g., on a specific host or type of machine). Conditionals use built-in “selector variables” that are filled in with various pieces of information about the environment in which amd is running. The most commonly used selector variables are listed in Table 17.10.
Table 17.10 amd selector variables
The entry for a mount point can describe several different things that might be mounted there. For example, the following map file tells amd about two filesystems, /usr/man and /cs/tools. Each filesystem has one set of options that controls mounting on the machine where the filesystem actually lives and another that mounts the filesystem over the network.
/default opts:=rw,soft,timeo=10,retrans=5
usr/man host==chimchim;type:=ufs;dev:=/dev/sd1f \
host!=chimchim;rhost=chimchim;rfs:=/${key};\
type=nfs;fs:=${autodir}/${key}
cs/tools host==anchor;type:=ufs;dev:=/dev/sd3c \
host!=anchor;rhost=anchor;rfs:=/${key};\
type=nfs;fs:=${autodir}/${key}
Elements of the form name:=value define various attributes of the mount. For example, the first line sets the default mount options to “rw,soft,timeo=10,retrans=5”. Elements of the form name==value or name!=value are conditionals; subsequent elements are only used if the conditional evaluates to true. Notations like ${autodir} and ${key} insert the value of the appropriate variable.
The /default clause specifies defaults that apply to all map entries unless they are explicitly overridden. Table 17.11 describes the various options.
Table 17.11 amd map options
Starting amd
A running copy of amd manages one virtual filesystem directory beneath which all of its automounting action occurs. The name of the virtual directory and the map file that tells what to mount within it are specified on the command line.
amd can be started with a script such as this:
#!/bin/csh -f
cd /usr/local/etc/amd
exec /usr/local/bin/amd -x fatal,error,user -r -l syslog -a /tmp_mnt
/amd amd.master.map >& /dev/console
The options used in this script are described in Table 17.12.
Table 17.12 amd command-line options
a. The default is /a.
When a user references one of the filesystems defined in amd’s map file, amd mounts the filesystem and monitors subsequent use of the mount. After it has been inactive for a period of time (usually 5-15 minutes), amd unmounts the filesystem until it is referenced again.
Use the amq command to see the status of mounts.
Stopping amd
amd needs to be stopped gracefully so that it has a chance to untangle itself from the filesystem structure. Sending amd a SIGTERM is the polite way to ask it to leave.
1. Actually, Red Hat does allow you to UID-map accounts other than root; see page 497. Be careful that you don’t break standard software such as sendmail with such a mapping.
2. You’ll have to unblock TCP port 2049 if your site provides WebNFS service, however. Do not unblock this port for any machine that contains sensitive data!
3. Root access is also allowed from chimchim, the real owner of the filesystem.
4. Well, actually there is a fifth, =public, that’s used with WebNFS.
5. In reality, nfsd is usually a very simple program that makes a nonreturning system call to NFS server code embedded in the kernel.
6. Jeff Forys, one of our technical reviewers, remarked, “Most mounts should use hard, intr, and bg, because these options best preserve NFS’s original design goals (reliability