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.



Activate the following kernel options:

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

USE flags

Optiona USE flags for net-fs/autofs:
USE flag (what is that?) 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.


Install net-fs/autofs:

root #emerge --ask net-fs/autofs




Start and add AutoFS to the default runlevel:

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


The configuration files are found in the following locations:

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


General configuration files for AutoFS.

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. The default location for the master map is (/etc/autofs/auto.master). It can be changed by setting the MASTER_MAP_NAME configuration variable in /etc/conf.d/autofs.

The following examples of configuration files take into account the default location for 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
/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.


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              
# nework share mounted via CIFS on /mnt/auto/data1
data1           -fstype=cifs,credentials=/root/smb.txt       ://
# memory stick used regulary with known UUID, for example a kindle
kindle          -fstype=vfat,rw,uid=1000                     :UUID="4CBF-23A2"
There are several more examples in the auto.misc that comes with the package

Simple Windows-like SMB shares usage

If you want to use network SMB shares easily you can try the following configuration. You will be able to automount, for example, by issuing "cd /net/" command in shell or "/net/" in a browser or commander and work with the files inside as they were located on local machine. Make the following modifications:

FILE /etc/autofs/auto.master
/net file:/etc/autofs/auto.smbm --ghost --nonstrict
FILE /etc/autofs/auto.smbm
* -fstype=autofs,-Dhost=& file://etc/autofs/auto.share
FILE /etc/autofs/auto.share
* -fstype=cifs,username=guest,password=,file_mode=0664,dir_mode=0775,uid=netmount,gid=netmount,port=139 ://${host}/&

Restart autofs daemon and you are ready to use simple automount.

External resources