Automate Mounting of File Systems

Introduction to Autofs

The Autofs package contains userspace tools that work with the kernel to mount and un-mount removable file systems. The primary use is to mount external network file systems like NFS (see NFS Utilities-1.1.2) or Samba (see Samba-3.0.30) on demand.

It may also be useful for allowing users to mount floppies, cdroms and other removable storage devices without requiring the system administrator to mount the devices although this capability is now generally provided by HAL (see HAL-0.5.9.1). This may not be ideal for all installations, so be aware of the risks before implementing this feature.

Package Information

Additional Downloads

Recommended Patches: There are frequent patches issued for Autofs. One method you can use to get the current patches requires first installing the Wget-1.10.2 package. After ensuring the wget command is installed in a directory identified in the PATH variable, start in the same directory as the main tar file and issue the following commands:

wget http://ftp.kernel.org/pub/linux/daemons/autofs/v5/patch_order-5.0.3 &&
sed 's;autofs;http://ftp.kernel.org/pub/linux/daemons/autofs/v5/autofs;' \
    patch_order-5.0.3 > wget-list &&
wget -i wget-list

Autofs Dependencies

Optional

OpenLDAP-2.3.39 and Cyrus SASL-2.1.22

User Notes: http://wiki.linuxfromscratch.org/blfs/wiki/autofs

Kernel Configuration

Verify that kernel support has been compiled in or built as modules in the following areas:

File systems ⇒
    Kernel automounter version 4 support  Y or M
    Network File Systems ⇒
        NFS file system support     Y or M (optional)
        SMB file system support     Y or M (optional)

Recompile and install the new kernel, if necessary.

Installation of Autofs

Install Autofs by running the following commands:

for f in `cat ../patch_order-5.0.3`; do
  patch -Np1 -i ../$f
done &&
./configure --prefix=/ --mandir=/usr/share/man &&
make

This package does not come with a test suite.

Now, as the root user:

make install &&
ln -sf  ../init.d/autofs /etc/rc.d/rcsysinit.d/S52autofs

Command Explanations

for f in `cat ../patch_order-5.0.3`; do patch -Np1 -i ../$f; done: This command applies all the patches downloaded earlier in the correct order.

ln -sf ../init.d/autofs /etc/rc.d/rcsysinit.d/S52autofs: This command sets the link to properly start autofs upon boot.

Configuring Autofs

Config Files

/etc/sysconfig/autofs.conf, /etc/auto.master, /etc/auto.misc, and /etc/auto.net

Configuration Information

The installation process creates auto.master, auto.misc, auto.smb, and auto.net. Replace the auto.master file with the following commands:

mv /etc/auto.master /etc/auto.master.bak &&
cat > /etc/auto.master << "EOF"
# Begin /etc/auto.master

/media/auto  /etc/auto.misc  --ghost
#/home        /etc/auto.home

# End /etc/auto.master
EOF

This file creates a new media directory, /media/auto that will overlay any existing directory of the same name. In this example, the file, /etc/auto.misc, has a line:

cd   -fstype=iso9660,ro,nosuid,nodev :/dev/cdrom

that will mount a cdrom as /media/auto/cd if that directory is accessed. The --ghost option tells the automounter to create “ghost” versions (i.e. empty directories) of all the mount points listed in the configuration file regardless whether any of the file systems are actually mounted or not. This is very convenient and highly recommended, because it will show you the available auto-mountable file systems as existing directories, even when their file systems aren't currently mounted. Without the --ghost option, you'll have to remember the names of the directories. As soon as you try to access one of them, the directory will be created and the file system will be mounted. When the file system gets unmounted again, the directory is destroyed too, unless the --ghost option was given.

[Note]

Note

An alternative method would be to specify another automount location such as /var/lib/auto/cdrom and create a symbolic link from /media/cdrom to the automount location.

The auto.misc file must be configured to your working hardware. The loaded configuration file should load your cdrom if /dev/cdrom is active or it can be edited to match your device setup. Examples for floppies are available in the file and easily activated. Documentation for this file is available using the man 5 autofs command.

In the second line, if enabled, a user's home directory would be mounted via NFS upon login. The /etc/home.auto would need to exist and have an entry similar to:

joe  example.org:/export/home/joe

where the directory /export/home/joe is exported via NFS from the system example.org. NFS shares are covered on the next page.

This package could also be used to mount SMB shares, however that feature is not configured in these instructions. For additional configuration information, see the man pages for auto.master(5). There are also web resources such as this AUTOFS HOWTO available.

Contents

Installed Program: automount
Installed Libraries: lookup_file.so, lookup_hosts.so, lookup_multi.so, lookup_nisplus.so, lookup_program.so, lookup_userhome.so, lookup_yp.so, mount_afs.so, mount_autofs.so, mount_bind.so, mount_changer.so, mount_ext2.so, mount_generic.so, mount_nfs.so, parse_sun.so
Installed Directories: /lib/autofs and /var/run/autofs

Short Descriptions

automount

is the daemon that performs the mounting when a request is made for the device.

Last updated on 2008-08-11 15:01:37 -0500