automount and autofs Hint
automount is a useful daemon that mounts automatically devices to directories when the directory is accessed. It's started with
# automount dir maptype map
where
- dir
-
is the directory where the automounts should appear, this directory does not have to exist,
- maptype
-
is the type of the map map, and
- map
- is some kind of map explaining what to mount to which directory under dir.
The maptype file is not too difficult. Each non comment line looks like
subdir [options] parameter
- subdir
-
is the name of the directory in dir from above where this particular mount should appear,
- options;
are mount-specific options, and
- parameter
- is the parameter for the real mount program,
The manpage autofs(5) explains this in more detail and gives examples for the standard file systems one might want to mount. For lufs' ftp filesystem a small map would be
#/etc/automount.map - mapfile for automounter other mount definitions can go here # some lufs FTP mounts ariane -fstype=lufs,fs=ftpfs,quiet,host=192.168.1.4 / ftp.qe -fstype=lufs,fs=ftpfs,quiet,host=ftp.quietsche-entchen.de /
Starting automount like
# mkdir /net # automount /net file /etc/automount.map
would the give the directories ariane and ftp.qe under /net where the FTP server appears automatically when the directory is accessed.
Notice for ftpfs that
- The above setup assumes anonymous FTP and
- that the lufs modules is already loaded.
You might perhaps want to add the line
fs lufs
to your /etc/modules.conf. For ftpfs there's also a map program. Start automount with
# mkdir /net # automount /net program /etc/autofs.map
and do a
# cd /net/sunsite.unc.edu # ls -l
More general you may do a "cd [username[:password]@]ftpserver". The only thing which is perhaps not so nice with this is that the password is displayed as part of the directory name (not in the process list). For sshfs is works similary, the directory name has however always to be of the form "username@sshserver" and requires SSH key authentication.
The mapper program /etc/autofs.d/auto.mapper maps it's parameter for ftpfs, that is it can decode username, password and server from it. But this script reads also the file /etc/autofs.d/netrc for additional information about the server. Each non-empty and non-comment line is expected to hold the following colon separated fields:
- label
-
is the server's directory name under the automount main directory,
- username
-
is the login name for the server,
- password
-
the password for username,
- hostname
-
the IP address or name of the FTP server (if required), and
- options
- optional mount options.
The fields are optional, they migt be empty or omitted. If the login information is missing auto.mapper will use anonymous authentication and if the hostname is not given the label will be used. If auto.mapper can't find a server in the netrc it uses the parameters from the directory name.
ariane can start automount automatically, set the autofs switch in /etc/options.conf to yes if you want that. The start script reads information from /etc/auto.master and starts an automount for each directory found there. Each line gives the directory name followed by a filename. The file might be executable in which case /etc/init.d/autofs assumes a program map type and file map type otherwise (file is not executable). The map filename can be followed my automount options (see it's manpage).
#/etc/auto,master /net /etc/autofs.d/auto.mapper
starts one automount listening on requests for directories under /net resolving them which calls to /etc/autofs.d/auto.mapper.