Autofs how-to for Mandriva 2007

By: moonie

Contact: mooniesdl3@yahoo.com

To install autofs perform the following command:

urpmi autofs

Once autofs is installed you will need to create/edit your /etc/autofs/auto.master file, mine looks like this on this machine:

# $Id: auto.master,v 1.4 2005/01/04 14:36:54 raven Exp $
#
# Sample auto.master file
# This is an automounter map and it has the following format
# key [ -mount-options-separated-by-comma ] location
# For details of the format look at autofs(5).
#/misc  /etc/autofs/auto.misc --timeout=60
#/smb   /etc/autofs/auto.smb
#/misc  /etc/autofs/auto.misc
#/net   /etc/autofs/auto.net
/auto /etc/autofs/auto_direct --ghost
/mnt /etc/autofs/auto.misc --ghost
/smb /etc/autofs/auto.windows --ghost

I'll explain some of the options in here, the first bit (/auto) is the directory that the following file controls. The -timeout=60 that is listed in the commented out part is the umount timeout, the default is either 60 or 120 seconds but can be adjusted either here or in the autofs config file (/etc/sysconfig/autofs) in the DAEMONOPTIONS="--timeout=30" line (I use 30 seconds myself). Without the -ghost line it will not show you the name of the folder underneath the autofs mount point and tab completion will not function, its a handy option to use, it also makes it easier for file managers to function with it.

These are my example mount files auto_direct, auto.misc and auto.windows:

/etc/autofs/auto_direct:

backup  -rw,soft,intr   perforce:/home/backup
backup2 -rw,soft,intr   10.16.0.110:/data/mondobackup

These mount my backup directories on 2 of my servers and you can use either IP address or server name (if /etc/hosts or dns lists them). These are NFS mounts.

/etc/autofs/auto.misc:

cdrom           -fstype=iso9660,ro,nosuid,nodev :/dev/cdrom
data3           -fstype=vfat,umask=0            :/dev/sdb1
usb             -fstype=vfat            :/dev/sdc1

Obviously cdrom is for my cdrom device, data3 is an external fat32 300GB USB2 HD and usb is for my USB2 thumb drives. With this setup I have 3 things that show up in my /mnt directory cdrom, data3 and usb. It is important to note that if you use this directory for autofs then you can not manually mount anything in here, autofs takes control of this directory.

/etc/autofs/auto.windows:

Test    -fstype=smbfs,credentials=/etc/smb.auth ://wc-anima/Tech
isostorage -fstype=smbfs,credentials=/etc/smb.auth ://wc-anima/ISOStorage

These are smb shares on a windows 2003 file server, they are only available to certain users hence the credentials=/etc/smb.auth bit, I'll show you what that looks like as an example to use private shares in your autofs mounts:

/etc/smb.auth:

username=domainname\username
password=password

This smb.auth is setup to connect to an Active Directory file server with centralized authentication and it works very well.

The only thing left to do is to start autofs, as root issue the following command and it should start up:

service autofs start

service autofs status will show you lots of information on your newly setup autofs directories.