Automounter

There are two automounter implementations available for Linux: one based on the Berkeley automounter daemon (amd), and one based on the Solaris automounter (automount). Both are configured in a similar manner: Both are given mount points and map files that define the characteristics of the file systems mounted on those mount points. Although its mount points can be defined in / etc/amd.conf, amd mount points and map files are often defined on the command line:

This command line tells amd that its working directory, in which the real physical mounts are made, is /amd. The mount point for the user directory is /mnt/wren. Like any NFS mount point, this directory must already exist. The map file that defines the filesystem that is mounted on / mnt/wren is named /etc/nfs/wren.map.

This section covers automount in more detail than amd. It does so for two reasons. First, our sample Red Hat 7.2 Linux system runs the autofs script by default, but it will only run the amd script if you enable it. These chkconfig commands from our sample Red Hat system show the following:

$ chkconfig —list amd amd 0:off 1:off 2:off 3:off 4:off 5:off 6:off

$ chkconfig —list autofs autofs 0:off 1:off 2:off 3:on 4:on 5:on 6:off

Second, I personally use automount because the syntax and structure more closely resemble the original Sun implementation, which I have used for years. This makes it easier to move configuration files between systems and to use Sun skills to implement a Linux server. To learn more about amd, see the book Linux NFS and Automounter Administration (Sybex, 2001). Written by Erez Zadok, who has been the amd maintainer for the last five years, it is the most comprehensive source of information about amd.

For automount, the mount points are usually not defined on the automount command line. Instead, automount mount points are defined in the auto.master file, which lists all of the maps that are used to define the automatically mounted filesystems. The format of entries in the auto.master file is mount-point map-name options

The options are standard mount command options. Generally, they are not defined here. Most administrators put options in the map file. Most auto.master entries contain only a mount point and a map file. To reproduce the amd configuration shown previously, the auto.master file would contain

/mnt/wren /etc/nfs/wren.map

This entry tells automount to mount the filesystem defined in the map file /etc/nfs/wren.map at / mnt/wren whenever a user refers to this directory. On Red Hat systems, the automount daemon is started by the /etc/rc.d/init.d/autofs script. Run autofs reload to load automounter after you change the file.

Note In addition to using the autofs script to reload the automounter configuration, you can run autofs start to start automount, and run autofs stop to shut it down.

The map file contains the information needed to mount the correct NFS filesystem. The format of a map file entry is key options filesystem

For NFS entries, the key is a subdirectory name. When anyone accesses this subdirectory, the filesystem is mounted. The options are the standard mount command options, and filesystem is the pathname of the filesystem being mounted. The map file for our example contains doc -ro wren:/usr/local/doc man -ro wren:/usr/local/man

This tells the automounter to mount wren:/usr/doc with read-only permission when any user tries to access /mnt/wren/doc, and to mount wren:/usr/local/man read-only if anyone accesses /mnt/ wren/man.

Automounting Home Directories

So far, you've seen automounter handle some simple NFS examples, but it can do much more. For instance, it can automatically mount the home directory of any user based on a single entry in the map file. Assume you have this entry in the auto.master file:

/home/owl /etc/nfs/home.map

With this entry, any request for a subdirectory in /home/owl will cause the automounter to check /etc/nfs/home.map for a directory to mount.

Assume that the entry in home.map is

This entry can mount any home directory found in the /home directory exported by owl to a like-named mount point on the local host. The * is a wildcard character that tells automounter to match anything the user types in. The & is a special character, which is replaced by the value typed in by the user. For instance, if the user tries to access /home/owl/daniel, automounter mounts owl:/home/daniel. If the user enters /home/owl/kristin, it mounts owl:/home/kristin. When constructing a path to the remote filesystem, automounter uses whatever value the user enters as the "key." This is a very useful feature, particularly when users log in to multiple systems and need access to their home directories from those systems.

NFS is a useful server for your Unix and Linux clients. But on most networks, the majority of clients are Microsoft Windows PCs. Those clients can be made to run NFS with optional client software. However, a better and more natural file-sharing service for Microsoft Windows PCs is provided by Samba. Samba is an implementation of the NetBIOS and Server Message Block (SMB) protocols for Linux.

Was this article helpful?

0 0

Post a comment