AutoFS

From Gentoo Wiki
Jump to: navigation, search

AutoFS uses the Linux kernel Automounter to automatically mount several types of media like memory sticks, network shares, CD-Rom/DVD/BR etc. on demand.

Installation

Kernel

You need to activate the following kernel options:

Kernel configuration

File systems --->
    <*> Kernel automounter version 4 support (also supports v3)

Software

Install net-fs/autofs:

→ Information about USE flags
USE flag Default Recommended Description
dmalloc No Enable debugging with the dmalloc library
hesiod No Install hesiod module
ldap No Install LDAP module
libtirpc No Use libtirpc lib support
sasl No Enable SASL support in the LDAP module
mount-locking No Enable locking to prevent corruption of /etc/mtab in the presence of concurrent auto-mounting. If enabled, recursive auto-mounting (eg. using autofs to bind or loop mount a filesystem which is itself auto-mounted) is not possible.
root # emerge --ask autofs

Configuration

Service

Start and add AutoFS to the default runlevel:

root # /etc/init.d/autofs start
root #
rc-update add autofs default

Files

The configuration files are located in:

  • /etc/conf.d/autofs
  • /etc/autofs/auto.master
  • /etc/autofs/auto.misc

Usage

General configuration files for AutoFS.

Important
You probably need to install additional software and modules to mount DVD, NFS, CIFS etc. The mount helpers need to be available for each file system you configure.

autofs configuration

The default options for autofs can be changed by setting the proper configuration variables located in /etc/conf.d/autofs; in the following example, the default location for the master map (/etc/auto.master) is changed by setting the MASTER_MAP_NAME configuration variable:

File/etc/conf.d/autofs

#
# Define default options for autofs.
#
# MASTER_MAP_NAME - map name for the master map;
#                   default is /etc/auto.master
#
MASTER_MAP_NAME="/etc/autofs/auto.master"
#
Note
The following examples of configuration files take into account the new location for auto.master set above.

auto.master

In this configuration file is defined what other configuration files should be included as root mount-point. Here is one example with one additional mount-point on /mnt/auto:

File/etc/autofs/auto.master

+auto.master # extry needed for NIS mapping
# Here are the files listed, that should be included
# mount-point | config file | options
/mnt/auto   /etc/autofs/auto.misc    --timeout=15 --ghost
Note
/mnt/auto is the root mount-point for all file systems defined in auto.misc. --timeout defines how many seconds to wait before the file system is unmounted. --ghost creates empty folders for each mount-point in auto.misc, this prevents timeouts if a network share cannot be contacted.

auto.misc

Here is our example for the file auto.misc. The folders for the mount-points are automatically created

File/etc/autofs/auto.misc

# mount-point below /mnt/auto | mount options | device, network share etc.

# CD-Rom on /mnt/auto/cd
cd              -fstype=iso9660,ro,nosuid,nodev              :/dev/cdrom
# nework share mounted via NFSv3 on /mnt/auto/data
data            -rw,vers=3,soft,async                        192.168.0.254:/tank1/data
# nework share mounted via CIFS on /mnt/auto/data1
data1           -fstype=cifs,credentials=/root/smb.txt       ://192.168.0.254/data1
# memory stick used regulary with known UUID, for example a kindle
kindle          -fstype=vfat,rw,uid=1000                     :UUID="4CBF-23A2"
Note
There are several more examples in the auto.misc that comes with the package

External resources