/etc/auto.[dir]

The /etc/auto.[dir] files are used in conjunction with the autofs service for dynamic filesystem mounting. The [dir] in the filename typically represents a specific mount point or category, and these files provide detailed mappings for the filesystems or directories that should be automatically mounted by autofs.

Here’s a detailed breakdown of how these files work and how they are used:

General Structure

The naming convention for these files is generally /etc/auto.<dir>, where <dir> is the name of the directory or mount point that corresponds to the map file. For example, you might have files like /etc/auto.home, /etc/auto.misc, or /etc/auto.nfs.

Purpose

These map files define what should be mounted under the directories specified in /etc/auto.master. They contain the detailed configuration for each mount point, such as filesystem type, options, and source paths.

Example Format

Each entry in an /etc/auto.[dir] file typically consists of a line in the following format:

<key> <options>
  • <key>: The subdirectory under the mount point where the filesystem will be mounted.

  • <options>: Mount options or details specifying what and how to mount.

Examples of /etc/auto.[dir] Files

Example: /etc/auto.home

If you have a line in /etc/auto.master like:

/home /etc/auto.home

The /etc/auto.home file might contain:

# /etc/auto.home
user1 -fstype=nfs,rw server:/export/home/user1
user2 -fstype=nfs,rw server:/export/home/user2

In this example:

  • /home/user1 and /home/user2 will be dynamically mounted to the NFS shares provided by server.

  • The -fstype=nfs,rw specifies that the filesystems are NFS with read-write permissions.

Example: /etc/auto.misc

If you have a line in /etc/auto.master like:

/mnt/auto /etc/auto.misc

The /etc/auto.misc file might look like:

# /etc/auto.misc
share -fstype=nfs,rw,soft server:/path/to/share

In this example:

  • /mnt/auto/share will be dynamically mounted to the NFS share at server:/path/to/share.

  • The -fstype=nfs,rw,soft specifies that the filesystem type is NFS, with read-write access and soft mount options.

Key Options and Parameters

  • -fstype=<type>: Specifies the filesystem type (e.g., nfs, cifs, ext4).

  • rw: Read-write access.

  • ro: Read-only access.

  • soft: Allows the mount to fail softly if the server is unavailable.

  • hard: Causes the mount to retry indefinitely if the server is unavailable.

  • timeout: Specifies the duration in seconds after which the mount should be unmounted if not accessed.

Configuration and Usage

  1. Configuration: Add appropriate entries to /etc/auto.master to specify mount points and map files. Define detailed mount options in the corresponding /etc/auto.[dir] file.

  2. Dynamic Mounting: When a directory under the specified mount point is accessed, autofs will automatically mount the filesystem according to the map file's configuration.

  3. Unmounting: Filesystems are unmounted after a period of inactivity, reducing resource usage.

Summary

The /etc/auto.[dir] files are integral to configuring autofs for automatic and dynamic filesystem mounting. They provide detailed instructions for what and how to mount, facilitating the management of network shares and other filesystems without manual intervention. Proper configuration of these files ensures efficient resource usage and seamless access to mounted filesystems.

Last updated