Automounter
-
allows automatic and transparent mounting of directories
-
makes it possible to have a single home directory for all
your users
-
instead of one on each machine they log into
-
can setup redundant filesystems in case one server goes down
-
access to many filesytems but only mounts them on demand
-
not configured in /etc/fstab file!
Requirements
-
filesystems to be automounted must be exported on the server
-
a map is required on each machine
-
contains the list of filesystems to be mounted
-
the portmapper must be running before starting the automounter
daemon
-
NIS can be used to push the automount maps to client machines
Lets get started...
Package requirements
-
autofs or amd
-
check to see if you have autofs installed on your RedHat
systems
# rpm -qa | grep autofs
autofs-3.1.7-21
Amd is also an excellent rubust automount package, however,
since we have autofs installed on our systems we will proceed using autofs.
-
Check that your kernel supports autofs
# cat /proc/filesystems | grep autofs
nodev autofs
^^^^^^
Recap of the /etc/exports file
Any filesystem you wish to automount must be exported by
its local server
# cat /etc/exports
/home 192.168.1.0/24(rw)
/mnt/cdrom 192.168.1.0/24(ro)
/distro 192.168.1.0/24(ro)
The Master Map
-
default map file read by the automounter
-
has a list of all automounter map files
# cat /etc/auto.master
/nethome auto.home --timeout 60
/prj auto.prj --timeout 60
/misc auto.misc
/net -hosts -nosuid,soft
Indirect Map file
There is an entry for each of these indirect map files
in the master map file.
# cat /etc/auto.home
pattyo -rw,noquota ponto:/home/pattyo
joel -rw,noquota ponto:/home/joel
conner -rw,noquota ponto:/home/conner
dylan -rw,noquota ponto:/home/dylan
# cat /etc/auto.prj
doc -rw,noquota
ponto:/home/oreilly/Linux/Doc
teaching -rw,noquota ponto:/home/patty/Teaching/MCC
Samba Example but not recommeded
# cat /etc/auto.misc
oaxaca -fstype=smbfs,login=pattyo,passwd=xxxxx ://oaxaca/teaching
You will need to start the automount process
# /etc/rc.d/init.d/autofs start
Starting automount:
[ OK ]
-
You can restart this daemon to reload your maps after adding
new mount points
Now, lets try an ls on a automount filesystem
# ls /prj/doc
afs
amd
automounter
backups
bootfloppy
certification
chroot
clock
debian-inst
dhcp
disk-part
Other files used by the automounter
/etc/mtab
-
automatically generated
-
kernel uses it to tracks all mounted filesystems
# tail /etc/mtab
//oaxaca/TEACHING /mnt/teaching smbfs 0 0 0
automount(pid16329) /prj autofs rw,fd=5,pgrp=16329,minproto=2,maxproto=3
0 0
automount(pid16306) /nethome autofs rw,fd=5,pgrp=16306,minproto=2,maxproto=3
0 0
/var/log/messages or /var/log/syslog
(depending on your syslog.conf )
# tail /var/log/syslog
Apr 4 18:45:15 ponto automount[16116]: expired
/nethome/joel
Apr 4 18:45:57 ponto autofs: automount -USR2
succeeded
Apr 4 18:46:03 ponto autofs: automount startup
succeeded
Apr 4 18:48:42 ponto automount[16354]: expired
/prj/doc
Integrating automounter into NIS
-
Nis maps are compiled on the NIS Master server and pushed
to the slave servers
-
Simply add the automount map files and master map file to
the NIS Makefile
-
located in /var/yp and build
vi /var/yp/Makefile
add the NIS maps to appropriate locations
make
build the NIS database
in /var/yp/<NIS Domain>
ls -lt /var/yp/example.com
total 400
-rw------- 1 root root 12554 Apr
4 19:13 auto.home
-rw------- 1 root root 12526 Apr
4 19:13 auto.master
-rw------- 1 root root 12531 Apr
4 19:13 auto.misc
-rw------- 1 root root 12508 Apr
4 19:13 auto.prj
-rw------- 1 root root 13074 Apr
4 19:13 mail.aliases
-rw------- 1 root root 12569 Apr
4 19:13 netgroup
-rw------- 1 root root 12522 Apr
4 19:13 netgroup.byhost
-rw------- 1 root root 12470 Apr
4 19:13 netgroup.byuser
-rw------- 1 root root 29201 Apr
4 19:13 protocols.byname
ypcat -k auto.home
dylan -rw,noquota ponto:/home/dylan
conner -rw,noquota ponto:/home/conner
pattyo -rw,noquota ponto:/home/pattyo
joel -rw,noquota ponto:/home/joel