Autofs Automounter HOWTO (c) 1998 Linux Consulting All rights Reserved Written by Alvin Oga, alvin@Linux-Consulting.com v0.1, 11 August 1998 ------------------------------- ------- DO NOT DISTRIBUTE ----- ------- still being edited ---- ------------------------------- This Autofs HOWTO document is written to provide the basics of autofs to mount and unmount partitions for access by the system and users. An HTML version of this document is available at http://HOWTO.linux-consulting.com/AutoFS ( NOT YET ) 0. Tsble of Contents 1. Introduction 1.1 Feedback and Corrections 1.2 Disclaimer 1.3 Copyright 1.4 Trademarks 2. General info abour Linux 1. Introduction This original AutoFS-HOWTO is written by Alvin Oga, alvin@Linux-Consulting.com. I'd like to acknowledge Peter Anvin ( hpa@transmeta.com ) for writing autofs into the linux kernel and thousands of others whom are making linux a success. To get my local network setup, I've read many FAQs, HOWTOs and books on various aspects of its administration. Though admittedly too advanced for an average user and not enough for those with some experience or particular problem, in this case, setting up autofs. This is my attempt to help other linux professionals and enthusiasts to setup their lan using automounters. 1.1. Feedback & Corrections PLEASE REPORT ANY INACCURACIES IN THIS DOCUMENT to me ( alvin@linux-Consulting.com ) and I will correct the problem in the next release of this document. If you have questions, comments or suggestions about this document, please feel free to let me know. 1.2. Disclaimer WE ARE NOT RESPONSIBLE FOR ANY DAMAGES INCURRED DUE TO ACTIONS OR INACTIONS TAKEN BASED ON THIS DOCUMENT WHETHER EXPLICITLY STATED OR IMPLIED. This document is meant as an introduction to how automounter and your Linux filesystem work together. I am not, nor do I pretend to be a automounter expert. I am just some guy who has benefited from the expertise of others and wish to add my contribution to the Linux community. 1.3. Copyright Unless otherwise stated, Linux HOWTO documents are copyrighted by their respective authors. Linux HOWTO documents may be reproduced and distributed in whole or in part, in any medium physical or electronic, as long as this copyright notice is retained on all copies. Commercial redistribution is allowed and encouraged; however, the author would like to be notified of any such distributions. All translations, derivative works, or aggregate works incorporating any Linux HOWTO documents must be covered under this copyright notice. That is, you may not produce a derivative work from a HOWTO and impose additional restrictions on its distribution. Exceptions to these rules may be granted under certain conditions; please contact the Linux HOWTO coordinators: Greg Hankins, gregh@sunsite.unc.edu. Tim Bynum, linux-howto@sunsite.unc.edu In short, we wish to promote dissemination of this information through as many channels as possible. However, we do wish to retain copyright on the HOWTO documents, and would like to be notified of any plans to redistribute the HOWTOs. If you have any questions, please contact Alvin Oga at ( whois ao196 ). 1.4 Trademarks Trademarks are owned by their owners. There is no warranty about the information in this document. Use and distribute at your own risk. The content of this document is in the public domain, but please be polite and attribute any quotes. =================================================================== 2.0. General Info about Linux Linux is a completely free reimplementation of the POSIX specification, with SYSV and BSD extensions (which means it looks like Unix, but does not come from the same source code base), which is available in both source code and binary form. It is copyrighted by Linus B. Torvalds (Linus.Torvalds@Helsinki.FI) and other contributors, and is freely redistributable under the terms of the GNU Public License. 2.1 Brief History of Linux ( guessing ) --- I making this up... need more details... 1993 Linux 0.1 was released by Linus Trivolds 1994 Linux 0.9 was released 199x Linux 1.0 was released 199x Linux 1.2 Disk access speedups, TTY improvements, virtual memory enhancements, multiple platform support, quotas 199x Linux 2.0 Many performance improvements, new networking protocols, one of the fastest TCP/IP implementations in the world 1998 Jul Linux-2.0.34 distributed with redhat-5.1 ( one of the lastest commercial offerings, by one of many vendors, as of today ) 2.2 Where to get Linux ( Free distributions and commercial ones ) There are tons of reading material on how to get started, some of which might interest you are: For more general info about linux, please read all the linux documents including http://sunsite.unc.edu/pub/Linux/docs/faqs/linux-faq/Linux-FAQ Linux Installation HOWTO by Eric S. Raymon, esr@thyrsus.com http://sunsite.unc.edu/LDP/HOWTO/Installation-HOWTO.html Linux Linux Information Sheet by Michael K. Johnson. johnsonm@redhat.com http://sunsite.unc.edu/LDP/HOWTO/INFO-SHEET.html Linux META_FAQ http://sunsite.unc.edu/LDP/HOWTO/META-FAQ.html by Michael K. Johnson johnsonm@redhat.com Linux can be downloaded for FREE from several sites or http://sunsite.unc.edu/pub/Linux/distributions/ http://sunsite.unc.edu/LDP/HOWTO/Distribution-HOWTO.html by Michael K. Johnson johnsonm@redhat.com Linux is also distrributed on CDROM media, by several commercial vendors http://www.linuxresources.com/apps/ftp.html ..the list goes on and on... 2.3 Linux HOWTO Documents and FAQs The Linux Documentation Project ( LDP ) is writing a set of manuals and books about Linux, all of which are freely distributable on the net and available from the LDP home page. http://sunsite.unc.edu/LDP To contribute linux related documents join the mailing list linux-doc@vger.rutgers.edu mailing list. To: majordomo@vger.rutgers.edu Subject: subject line is ignored help end 2.3.1 Linux HOWTOs Linux HOWTO documents are part of the Linux Documentation Project ( LDP ) to help answer users common questions and issues. For more information about HOWTOs, please refer to HOWTO-INDEX maintained by Greg Hankins, gregh@sunsite.unc.edu You might have a local copy of the entire LDP HOWTO on your linux disk at /usr/doc/HOWTO HOWTOs are posted to comp.os.linux.answers HOWTOs are available in text, HTML, DVI and postscript formats from ftp://sunsite.unc.edu:/pub/Linux/docs/HOWTO ftp://tsx-11.mit.edu/pub/linux/docs/HOWTO http://sunsite.unc.edu/LDP/HOWTO Mirror sites http://sunsite.unc.edu/LDP/hmirrors.html Linux FAQs are at http://sunsite.unc.edu/pub/Linux/docs/faqs 2.3.2 Grep'ping the HOWTOs Because of the great volume of documents out there, a couple years ago I wrote a simple script that will search all the HOWTOs, FAQ and mini-HOWTOs for keywords and phrases. I keep a duplicate local copy of Sunsite's HOWTO can be found at: ftp.Linux-Consulting.com:/pub/HOWTO The simple grep based search engine is at: ( a way to do a shameful plug ) http://www.Linux-Consulting.com/HOWTO.Search -- needs cometic fixes 2.3.2 Linux Related Mailing List 2.3.2.1 To Subscribe to the Autofs mailing list There is an autofs mailing list at autofs@linux.kernel.org. Send email to majordomo@linux.kernel.org with "subscribe autofs" in the body of the email. And add "end" as the second line if you have a signature file appended to your outgoing emails From your email client: To: majordomo@linux.kernel.org Subject: Subscribe to autofs Mailing list subscribe autofs end or if you are a command line type of user ( the \ is there to indicate the following line is part of the same one line ) user> echo "subscribe autofs\nend" | \ elm -s "Subscribing to autofs" majordomo@linux.kernel.org 2.3.2.2 To unsubscribe, use the keyword "unsubsribe" instead. From your email client: To: majordomo@linux.kernel.org Subject: Subscribe to autofs Mailing list subscribe autofs end or if you are a command line type of user user> echo "unsubscribe autofs\nend" | \ elm -s "Unsubscribing to autofs" majordomo@linux.kernel.org 2.3.3 To join the Linux linux-net channel on the mail list server, send mail to: Majordomo@vger.rutgers.edu with the line: subscribe linux-net as the message body and you will be subscribed. The subject line is ignored. 2.3.4 Linux NewsGroups For more info, visit LDP at http://sunsite.unc.edu/LDP/usenet.html The newsgroup comp.os.linux.admin is an unmoderated newsgroup for discussion of administration of Linux systems. The newsgroup comp.os.linux.development.system is an unmoderated newsgroup specifically for discussion of Linux kernel development. The newsgroup comp.os.linux.development.apps is an unmoderated newsgroup specifically for discussion of Linux-related applications development. The newsgroup comp.os.linux.hardware is for Linux-specific hardware questions. The newsgroup comp.os.linux.networking is for Linux-specific networking development and setup questions. The newsgroup comp.os.linux.x is for Linux-specific X Windows questions. The newsgroup comp.os.linux.misc is the replacement for comp.os.linux, and is meant for any discussion that doesn't belong elsewhere. Linux.* newsgroups... 2.5 LINUX NETWORKING related documents A well written networking HOWTO is NET-2-HOWTO written by Terry Dawson, terry@perf.no.itg.telecom.com.au ftp://sunsite.unc.edu:/pub/Linux/docs/HOWTO/NET-2-HOWTO The Linux Network Administrators Guide is Copyright (c) by Olaf Kirch has written a substantial document as part of the Linux Documentation Project entitled the Linux Network Administration Guide It is freely available from the ftp site: ftp://sunsite.unc.edu/pub/Linux/docs/linux-doc-project/network-guide/ You should also read the other HOWTO documents relevant to networking with Linux. They are: The Ethernet-HOWTO , which you should read if you intend using an ethernet card with Linux. It includes a lot of detail on how to select, install and configure an ethernet card for Linux and on how to diagnose problems related to the ethernet driver. The PPP-HOWTO if you intend using PPP. The IPX-HOWTO if you would like information relating to IPX support for Linux. The Serial-HOWTO if you intend using SLIP or PPP in server mode. The NIS-HOWTO if you are interested in running a version of Sun's Network Information Service. The HAM-HOWTO if you are interested in configuring and running amateur radio software. The Mail-HOWTO and the News-HOWTO for some specific information on setting up Mail and News on your system. The UUCP-HOWTO if you will be connecting to the net via UUCP. The Firewall-HOWTO if you want to build a Linux based Firewall gateway for your network. If you are after some basic tutorial information on tcp/ip networking generally, then I recommend you take a look at the following documents: tcp/ip introduction text version , postscript version . tcp/ip administration text version , postscript version . 2.6 Other Websites The AutoFS HOWTO is maintained at: http://www.Linux-Consulting.com/HOWTO.Search with a simple "grep search engine" The NET-2/3-HOWTO is available at - just places I know of http://www.sunsite.unc.edu/LDP http://web.mit.edu/linux/Distributions/slackware/Slackware.3.1.0/docs/NET-2-HOWTO http://www.pa.msu.edu/people/wilkin49/faq/linux/NET-2-HOWTO http://cesdis.gsfc.nasa.gov/linux/linux-info/net-howto/NET-2-HOWTO.html and the automounter section is NET-2-HOWTO-11.html http://www.Linux-Consulting.com/HOWTO.Search with a simple "grep search engine" and a chinese(?) version of Netw-2/3-HOWTO is available at http://www.nease.net/~con/other/net2-3.txt 2.6. Linux Networking Related Books The Linux Network Administrators Guide is Copyright (c) by Olaf Kirch published by ??? TCP/IP Network Administration by Craig Hunt published by OReilly & Associates ( http://www.oreilly.com ) -- my wish list -->> get rights to do online "linux bookstore" 2.7 Autmounter Man Pages and source code 2.7.1 Man pages for amd user> man amd user> man amdxref user> man amd.conf -- not yet 2.7.2 Man pages for autofs user> man autofs user> man auto.master 2.7.3 Autofs source code is part of the linux kernel at /usr/src/linux/fs/autofs and some minimal documentation is at: /usr/doc/autofs-0.3.14 2.7.4 amd source code is ---- am-utils by Erez Zadok /usr/doc/am-utils-6.0a16//README /usr/doc/am-utils-6.0a16//README.autofs ======================================================================= 3. Automounter Please note there are lots of discussions and documentation about automounters on the various linux resources. Some of the text in this section has been plagerized from the NET-2-HOWTO maintained by Terry Dawson, terry@perf.no.itg.telecom.com.au As a beginner, I found it difficult to find the information I needed to setup the amd and autofs automounters. I hope that the examples in this document will help you configure your network with the autofs automounter. An automounter provides a convenient means of mounting filesystems on demand, i.e. when required by the system or the user. This will reduce both the server and the client load and provides a great deal of flexibility even for local server and it's filesystems. An automounter provides 4 key features: a. An automounter makes exported filesystems on all servers listed in /etc/hosts available to your local host machine b. Wildcarding in the automounter makes it easy to mount remote directories to like-named mount points on the local host machine c. The automounting features of the programs mounts only the exported filesystems that is used from the possibly huge list of servers d. Having multiple servers improves the reliability of the servers and the network by removing the dependency on teh network 3.1 what it allows you to do - transparently mount your home dir if you need it - transparently mount your backup directory as you need it - transparently mount your mail server for reading and deleting - compare files on the different servers - allows you to have a common home directory server for all users to login and be authenticated and able to work from and workstation using any server in the network. - increase the reliability of your LAN by removing the dependecies on a single server - allows you to have acces to have access to large numbers of filesystems and directories, and only those that are used will be mounted, minimizing your risk from those unused servers. -- is this a supported feature A rather useful mount called the union mount gives the automounter the ability to merge the contents of multiple directories into a single directory. 3.2 Some automounting tips excerpted from NET-2-HOWTO Automounters use "maps" which define the filesystem to mount. different automounters maps are not compatabible with each other, eg: amd maps are not compatible with Sun maps, which in turn are not compatible with HP maps ad infinitum. Sun automount maps can be converted to amd style maps by using the perl script in the contrib directory - automount2amd.pl which can be found at in the ?? amd utlities(??) amd-920824upl102-8/contrib ypcat -k auto.nfs | automount2amd.pl >/etc/auto.Linux -- check /etc/nsswitch.conf also -- note for me... You must have the portmapper running before starting the automounter UFS mounts, in the case of Linux only, do not timeout. UFS mounts have been extended to deal with all varieties of linux filesystems (i.e. minix, ext, ext2, xiafs ...) with the default being minix. <<--- ??? Do not mount the filesystem over existing local directories unless you use a direct automount option, otherwise you will NOT be able to access the contents of your local directory. Typical examples are /home, /var/spool/mail, /usr/local, etc Always turn on full logging with the `-x all' option to amd if you have any troubles /usr/sbin/amd -x all -l syslog -a /amd -- /net /etc/amd.net "amq -ms" reports, as it will indicate problems as they occur You do not configure the automounter from the /etc/fstab file, which you will already be using to contain information about your filesystems, instead it is command line driven. ================================================================================ 4. Setting up the Automounters It is hoped that by reading this document, you should be able to have one or both of these automounter running on your linux system. amd and autofs can co-exist together... ??? ??? can they have the same mount points ????? ??? 4.1 Autmounter Hardware requirements - nothing special - make sure the peripheral device is supported 4.2 Automounter Software requirements The amd automounter does NOT require any kernel support. Therefore you should be able to get it running with no problems. The autofs automounter on the otherhand does REQUIRE kernel level support. Check for the current versions of amd at: ftp://sunsite.unc.edu/pub/Linux/system/Misc/mount/amd920824upl67.tar.gz The current versions of autofs is available from ftp.kernel.org:/pub/linux/daemons/autofs/ Autofs is also included in the the Linux kernel source tree at /usr/src/linux/fs/autofs automount2amd.pl script in NET-2-HOWTO will convert Sun automounter map file format into amd map file format. 4.2.1 Check that your existing kernel supports autofs # cat /proc/filesystem ext2 ... nodev autofs <<---- required for autofs if autofs is not listed...you MUST recompile the kernel 4.2.2 if you need to recompile your kernel to support autofs try using amd first....unless you know how to define the various kernel options # grep -i autofs /usr/src/linux-2.0.3x/.config CONFIG_EXPERIMENTAL=y <<--- required for autofs ....etc... CONFIG_AUTOFS_FS=y <<--- required for autofs 4.3 Generic System Files for the Network 4.3.1 /etc/fstab the /etc/fstab is a file that defines your file system and is read at boot time. General syntax is filesystem mount_point options You may mount the partitions into your file system as defined by /etc/fstab at boot time or you can manually mount it as needed or use an automounter mounter that will transparently mount the partition you are accessing. fstab defines your various filesystem defining your disks such as a ext2 filesystem ( default ) or a msdos partition or a iso9660 filesystem for cdrom among many other options. see man pages for fstab Example 4.3.1.1 --------------- # # 10-Aug-98 amo Sample /etc/fstab file # # for ps and other runtime data none /proc proc defaults # /dev/sda1 swap swap defaults 0 2 /dev/sda2 / ext2 defaults 0 1 /dev/sda3 /tmp ext2 defaults 0 2 /dev/sda5 /var ext2 defaults 0 2 /dev/sda6 /usr ext2 defaults 0 2 # # Do not mount on reboots /dev/sdb0 /cdrom iso9660 noauto,default,ro 0 2 # # # If you want to be able to manually mount these filesystems # # make sure /mnt/kernel exists ( mkdir /mnt/kernel.org ) www.kernel.org:/tmp /mnt/kernel.org nfs noauto 0 0 # # Do not mount on reboots Mach:/Backup /Backup nfs defaults,noauto 0 0 # # end of file see Mount options for more info You do not configure the automounter from the /etc/fstab file, which you will already be using to contain information about your filesystems, instead it is command line driven. 4.3.2 /etc/mtab this file shows the active partitions currently mounted. Please do NOT edit this file When running commands like "df", it will list mounted directories listed in this file in order. If df hangs in the middle, it usually means the next mount point in the /etc/mtab file is the server that is not responding. 4.3.3 /etc/exports This file defines all your partitions that you are allowing the rmachines to have access to your filesystem. A machine that is a server for your home directories will have /home exported as rw to other client workstations A machine that is your mail server will have /var/spool/mail exported as rw to other client workstations and if were have such a servers Example 4.3.3.1 --------------- # # /etc/exports # # To reload changes to this file # ------------------------------ # /etc/rc.d/init.d/nfs stop ; /etc/rc.d/init.d/nfs start # check /var/log/messages for any errors # # # allow the primary Server to read the entire filesystem hierarchy / Primary.your_domain.com(ro,no_root_squash) # # allow users on other machines to pop and delete their emails /var/spool/mail #.your_domain.com(rw) # # # allow users on Home to read/write data on this machine /home Home.your_domain.com(rw) # # allow users on any machine to read the /home dirctory on this machine /home *.your_domain.com(ro) # # # To Export /home/$USR to particular users workstations # note: you should probably use NT1.your_domain.com to disallow # exporting the directory to NT1.evil_hacker.com # /home/usr1 NT1(rw) /home/usr2 NT2(rw) /home/usr3 NT3(rw) # # # To allow this machine's local disks to be the backup disk to Server # allow root@Server to be able to write to this backup disk # /Backup Server.your_domain.com(rw,no_root_squash) # # end of file Some mount options ro read only ( default?? ) rw read and write root_squash prevents root on the remote server from having root access to this machine ( the default on linux machine ) no_root_squash allows root on the remote server to manage this file system as if it was local to that remote server see Mount options for more info a loadable module or pre-compiled into the linux kernel. =========================================================================== 5.0 Automounter Examples These examples were taken from TCP/IP Network Admin by Craig Hung, published by O'Reilly and Associates 5.1 Solaris Automounter for comparason, for those of you that understand Solaris' NFS automounter, 5.1.1 Master Map file The Master Map configuration file is read by automount. It lists all the map files used by the automounter. # # Sample /etc/auto_master ( /etc/auto.master in linux ) # # mount_point map_name options # # comment out if you use NIS+ and centrally maintained files #+auto_master # # Does not apply if you use DNS #/xfn -xfn # # All machines listed in /etc/hosts are automatically mounted # ( a subdirectory ) under /net /net -hosts -nosuid # # directories listed in /etc/auto_home is mounted under /home /home auto_home # # special mount point defined by direct map file /- auto_direct # # end of file 5.1.2 Indirect Map file An Indirect map configuration file lists the pathnames and relative mount points, /home in this case # # Sample /etc/auto_home # # comment out if you use NIS+ and centrally maintained files #+auto_home # user_1 mach_1:/export/home/user_1 user_2 mach_2:/export/home/user_2 user_3 mach_3:/export/home/user_3 # # Export all the users home directory in Server * Server:/export/home/& # # end of file 5.1.3 Direct Map files # # Sample /etc/auto_direct ( Direct map file ) # # # mount it read/write /home/research -rw filbert:/home/research # # # mount it read only and soft timeout # if pecan does not respond in a specified period, use almond # if almond does not respond in a specified period, user filbert # /usr/man -ro,soft pacan,almond,filbert:/usr/share/man # # end of file --------------------------------------------------- 5.2 Amd Automounter Files amd is another popular automounter and I shall briefly describe it's files for similarity 5.2.1 /etc/amd.conf # # /etc/amd.conf # # To reload changes to this file # ------------------------------ # /etc/rc.d/init.d/amd stop ; /etc/rc.d/init.d/amd start # # /defaults opts:=rw;type=nfs # # where you have your home directory home type:=nfs;rhosts:=home;rfs:=/home # # where you have your incoming emails mail type:=nfs;rhosts:=mail;rfs:/var/spool/mail # # Replace with the server you have access to # server1 type:=nfs;rhosts:=server1;rfs:=/server1 server2 type:=nfs;rhosts:=server2;rfs:=/server2 server3 type:=nfs;rhosts:=server3;rfs:=/server3 # # end of file 5.2.2 Amd Automounter Directory tree /.automount This is your ??? mount directory ??? ....and is managed my the amd automount daemon. Please do NOT add or delete links, files, sub-directories from this direcotry This top level directory is defined in /etc/amd.conf If the desired top level director does not exit, please create it. mkdir /another_automount_dir 5.2.3 /net amd will create links to the /.automount directory Please do NOT create thes links...amd will do it dynamically for you... ls -la /net ... server1 -> /.automount/server1 ... server2 -> /.automount/server2 ... server3 -> /.automount/server3 5.2.4 /.automount amd will create subdirectories for "mount points" for the servers ls -la /.automount .... server1 .... server2 .... server3 5.2.5 Amd arguments usually amd is invoked by /etc/rc.d/init.d/amd stop /etc/rc.d/init.d/amd start the default arguments are: /usr/sbin/amd -a /.automount -l syslog -c 1000 /net /etc/amd.conf -a /.automount defines the mount directory -l syslog tells amd to log all messages via syslogd -c 1000 tells amd to ??? /net tells amd to put it's links here /etc/amd.conf tells amd where to find it's config files "amq -ms"... 5.2.6 To have amd autmount two directories that was manually mounted. Excerpted from Net-2-HOWTO To mount two nfs filesystems using your /etc/fstab file you would use two entries that looked like: server-1:/export/disk /nfs/server-1 nfs defaults server-2:/export/disk /nfs/server-2 nfs defaults i.e. you were nfs mounting server-1 and server-2 on your linux disk on the /nfs/server-1 and /nfs/server-2 directories. After commenting out, or deleting the above lines from your /etc/fstab file, you could amd to perform the same task with the following syntax: /etc/amd -x all -l syslog -a /amd -- /nfs /etc/amd.server | | | | | | | | | | | | | | | | | | | | | | | | | | `------' `----' `-------' `-----' -' `--' `-------------' | | | | | | | (a) (b) (c) (d) (e) (f) (g) Where: a. The full amd binary path (obviously optional) depending on your $PATH setting, so just `amd' may be specified here. b. `-x all' means turn full logging on. Read the documentation for the other logging levels c. `-l syslog' means log the message via the syslog daemon. This could mean put it to a file, dump it, or pass it, to an unused tty console. This (syslog) can be changed to the name of a file, i.e. `-l foo' will record to a file called foo. d. `-a /amd' means use the /amd directory as a temporary place for automount points. This directory is created automatically by amd and should be removed before starting amd in your /etc/rc scripts. e. `--' means tell getopt() to stop attempting to parse the rest of the command line for options. This is especially useful when specifying the `type:=' options on the command line, otherwise getopt() tries to decode it incorrectly. f. `/nfs' is the real nfs mount point. Again this is automatically created and should not generally contain subdirectories unless the `type:=direct' option is used. g. The amd map (i.e. a file) named `amd.server' contains the lines: # /etc/amd.server /defaults opts:=rw;type:=nfs server-1 rhost:=server-1;rfs:=/export/disk server-2 rhost:=server-2;rfs:=/export/disk 5.2.7 Starting the amd Automounter % /etc/rc.d/init.d/amd stop % /etc/rc.d/init.d/amd start - or - % /etc/rc.d/init.d/amd reload % amq -ms Check the log files and the status % /etc/rc.d/init.d/amd status cat /etc/mtab df tail -100 /var/log/messages Now if you say: % ls /nfs you should see no files. However the command: % ls /nfs/server-1 will mount the host `server-1' automatically. voila! amd is running. After the default timeout has expired, this will automatically be unmounted. Your /etc/password file could contain entries like: ... linus:EncPass:10:0:God:/nfs/server-1/home/linus:/bin/sh mitch:EncPass:20:10:Mitch DSouza:/nfs/server-1/home/mitch:/bin/tcsh matt:EncPass:20:10:Matt Welsh:/nfs/server-1/home/matt:/bin/csh which would mean that when Linus, Matt, or Mitch are logged in, their home directory will be remotely mounted from the appropriate server and unmounted when they log out. 5.3 Autofs Files 5.3.1 Autofs Automounter Directory tree /.autofs This is your mount point....and its contents are managed my the automount daemon, autofs. Please do NOT add or delete links, files, sub-directories from this direcotry This top level directory name is defined in /etc/auto.master If the desired top level director does not exit, please create it. mkdir /.autofs 5.3.2 /etc/auto.master Autofs Control file For more info and example, man auto.master This file is read by the autofs startup scripts usually at boot time to determine the mount points of the automounted file system. The autofs script can be stop and started at anytime to reload a new mount point. -- -- does NOT work if /home is busy ?? autofs fails to reload/restart ???? -- In the example below, /.autofs is the mount point and /etc/auto.misc is the map file defining the options for the mount point. # # 10-Aug-98 amo Sample /etc/auto.master file # # To Reload Changes to this file # ------------------------------ # /etc/rc.d/init.d/autofs stop ; /etc/rc.d/init.d/autofs start # # # format of this file: # mountpoint map options # For details of the format, look at autofs(8) # /.autofs /etc/auto.misc --timeout 60 # # end of file 5.3.3 /etc/auto.misc Autofs Mount Map File auto.misc is your mount point map file. It defines all your partions you want the automounter to mount and unmount for you and where to mount it onto your filesystem. A brief description of the mount point options used in the example below: -ro means read only from the ftp site -soft means if the ftp is unavailable...do this.. -intr means if the ftp is unavailable...do this.. -fstype defines your file system type ext2 for linux native, iso9660 for cdroms, nfs for NFS mounted filesystem Note that the CDROM have a ??? syntax to mount it as needed. Note that kernel is a fully qualified domain name while home, mail uses local host names without the DomainName.com CAUTION: When defining /home directories and partitions, please be aware of /home from your remote server being mounted over your local /home directory already on your machine. Typically, people use /home/users for mounting users or /u or /export/home to avoid confusion. # # 11-Aug-98 amo Sample /etc/auto.misc # # To Reload Changes to this file # ------------------------------ # /etc/rc.d/init.d/autofs stop ; /etc/rc.d/init.d/autofs start # # To see the Status and log messages # ---------------------------------- # /etc/rc.d/init.d/autofs status # tail -100 /var/log/messages # # kernel -ro,soft,intr ftp.kernel.org:/pub/linux # cdrom -fstype=iso9660,ro :/dev/cdrom # #floppy -fstype=auto :/dev/fd0 floppy -fstype=ext2 :/dev/fd0 # # Define your Home directory ( server ) # CAUTION: /home vs the local /home already on your system home -fstype=nfs home:/home # # hard mounted, keep trying to connect to the Mail server mail -fstype=nfs mail:/var/spool/mail # # # Define some backups disk on a different machine # # soft -- timeout and give up the server is unavailable # Backup_1 -fstype=nfs,soft mach1:/Backup Backup_0 -fstype=nfs,soft mach2:/Backup # # Try to mount mach1 first, if that fails, try mach2 # Backup -fstype=nfs mach1,mach2:/Backup ??? -- supported ?? # # end of file When the automounter is properly loaded and running, it will manage some directories in it's mount dirctory /.autofs. 5.3.4 /Net Network Directory NOTE: do NOT create any files or directories in /.autofs All files and links are created by the automounter. This directory is defined in /etc/auto.master. All the entries in /etc/auto.misc will be subdirectories relative to /.autofs If you wish to access directories and files on another server: root# cd /Net root# root# ln -s ../.autofs/Server1 . root# root# ln -s ../.autofs/Server2 . Create your links for your users home directory ( /home/$USER ): root# cd / root# root# ln -s .autofs/home . Create your links for incoming emails: root# cd /var/spool root# root# ln -s ../../.autofs/mail . When you run the following command, you should see the contents of the automounted filesystem To view the mail mount point root# ls -la /var/spool/mail To view the contents of the mail server root# ls -la /var/spool/mail/ To view the Servers on your local LAN root# ls -la /Net/* To compare timestamps, sizes on the passwd files root# ls -la /Net/*/etc/passwd 5.3.5 Starting and stopping the automounter ??? ??? WARNING: do NOT stop the daemon if you have /home mounted ???? ??? -- autofs daemon will not reload nor restart itself...therefore no -- new filesystems, partitions can be mounted... To stop the daemon /etc/rc.d/init.d/autofs stop To start the daemon /etc/rc.d/init.d/autofs start To stop and start the daeon with one command kill -HUP "pid_of_the_amd_daemon" View the log messages in /var/log/messages --------------------------------------------------- 6.0 Mount Options for more information, see the man pages: man mount General format for mount command mount remote_host:/remote_directory /local_mount_point The remote_directory must be exported by remote_host as defined in its /etc/hosts file. mount -a Linux mount everything allowed mountall Solaris equivalent -ro Read only -rw Mount the filesystem read and write, but can be restricted by the server, and a warning is flagged ????? -rbuff=4096,-wbuff=4096 ???? -intr allow keyboard interrupts to kill the process that is hung waiting for the server that is down. -noitr No keyboard interrupts allowed. -soft if the server fails to respond, return an error and don't bother to try again -hard if the server fails to respond, retry until it does respond ( Note that this is the default option ) Use with caution, can hang your LAN when that server goes down as all the other servers need to wait for it to come back. -bg do the retrys in background mode -fg dp the retrys in foreground mode -nosuid Do not allow executables on the mounted filesystem to run as setuid. -fstype file system type of the remote partition to mount ext2 linux native nfs NFS type iso9660 CDROM -async use asynchronous filesystem I/O -auto mount when -a is used -noauto Do NOT mount the filesystem even if -a is used -nouser Only root can mount the filesystem -user Allow users to mount the filesystem -noexec Don't allow execution of files from this filesystem -nosuid Don't allow programs in this filesystem to run as setuid or setgid -suid Allow programs to run as setuid or setgid -sync Use synchronous filesystem I/O -timeout=# length of time before an access times out used with soft 7. Testing your automounter CAUTION: Before killing your automount daemons, make sure no one is using the mounted filesystem Common problems such as "hung commands" and slow commands can be avoided by a well administered network policy. 7.1 To Kill your automounter /etc/rc.d/init.d/autofs stop To Start your automounter /etc/rc.d/init.d/autofs start To Reload your automounter root# /etc/rc.d/init.d/autofs reload Checking for changes to /etc/auto.master .... Start /usr/sbin/automount --timeout 60 /.autofs file /etc/auto.misc # # check the log file # Aug 14 01:18:24 xxx automount[764]: starting automounter version 0.3.14, path = /.autofs, maptype = file, mapname = /etc/auto.misc Aug 14 01:18:24 xxx automount[764]: >> mount: automount(pid764) already mounted or /.autofs busy Aug 14 01:18:24 xxx automount[764]: >> mount: according to mtab, automount(pid370) is already mounted on /.autofs Aug 14 01:18:24 xxx automount[764]: /.autofs: mount failed! ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B-A-D 7.2 Verify the log files for any error messages Please verify that log messages in /var/log/messages, you should see the following if it mounted your directories properly Messages at boot time ( tail -100 /var/log/messages | grep automount ) Aug 14 01:05:36 xxx automount[370]: starting automounter version 0.3.14, path = /.autofs, maptype = file, mapname = /etc/auto.misc Aug 14 01:05:36 xxx automount[370]: using kernel protocol version 3 Aug 14 01:05:38 xxx automount[370]: attempting to mount entry /.autofs/local Aug 14 01:05:53 xxx automount[370]: attempting to mount entry /.autofs/mail 7.3 To See the Status of your automounter 7.3.1 root# ps auxwl | grep auto ... /usr/sbin/automount --timeout 60 /.autofs file /etc/auto.misc root# /etc/rc.d/init.d/autofs status Sourcing /root/.bashrc Sourcing /root/.alias Configured Mount Points: /usr/sbin/automount --timeout 60 /.autofs file /etc/auto.misc Active Mount Points: /usr/sbin/automount --timeout 60 /.autofs file /etc/auto.mis 7.3.2 amq -ms 7.3.3 /etc/rc.d/init.d/autofs status 7.4 To view what is currently mounted filesystem on this machine as with any un*x variants, there are many ways to see mounted machines: root# /etc/rc.d/init.d/autofs status root# showmount -a root# df root# cat /etc/mtab root# ls -la /.autofs/ Each of the following command will result in a attempt by the automounter to mount the requested directory and alogged in /var/log/messages Aug 14 01:42:39 xxx automount[370]: attempting to mount entry /.autofs/home 7.5 Tracking the activity of the automounter NOTE: When you run a command like "ls -la /Net/*" you will have to wait for ALL the servers to respond either by timeout period or for that server to come back online root# ls -la /Net or /Net/* lrwxrwxrwx 1 root root 1 Jul 30 03:39 xxx -> // lrwxrwxrwx 1 root root 19 Jul 30 03:40 home -> ../.autofs/home/ lrwxrwxrwx 1 root root 18 Jul 15 02:52 mail -> ../.autofs/mail/ lrwxrwxrwx 1 root root 19 Jul 15 02:52 backup -> ../.autofs/backup/ Log entries in /var/log/messages: Aug 14 01:48:08 xxx automount[370]: attempting to mount entry /.autofs/home Aug 14 01:48:08 xxx automount[370]: attempting to mount entry /.autofs/mail Aug 14 01:48:08 xxx automount[370]: attempting to mount entry /.autofs/backup and if you do NOT access the servers before the timeout period expires Aug 14 01:49:08 ahi automount[730]: expired /.autofs/home Aug 14 01:49:08 ahi automount[730]: expired /.autofs/mail Aug 14 01:49:08 ahi automount[730]: expired /.autofs/backup To view should show you the contents of all the server's exported directories root# ls -la /Net/*/ will show you the contents of the xported directory on each of the remote servers To view the mail mount point root# ls -la /var/spool/mail To view the contents of the mail server root# ls -la /var/spool/mail/ To view the Servers on the net root# ls -la /Net/* To compare timestamps, sizes on the passwd files root# ls -la /Net/*/etc/passwd When the filesystem is not being used, the automounter will timeout and unmounted the unsused filesystem. See /var/log/messages When access to the filesystem is needed again, the automounter will remount the requested filesystem. See /var/log/messages 7.6 Network Monitor tools snmp agent snmp source by Erik Schoenfelder, . It is available from: ftp.ibr.cs.tu-bs.de://pub/local/cmu-snmp2.1.2l3-src.tar.gz netwatch showtraf or trafshow --------------------------------------------------- 8. FAQs if your system, LAN hangs waiting for a server, use -intr,soft,timeout=60 Q: When running some commands, it hangs and does not return to command prompt: ( df, sync, ls /, etc... A: you probably have a mounted server that went down - either use soft mounts and timeout - or - - restart your NFS and automount daemon Q. Stale mount points A. donno... try shutting down nfs, automounters, syslogs, and finally reboot kill the users mounting the directory ( tell them first before killing their jobs ) Q. Slow replies A. A server is timeing out and than continuing thru the list of mounted and active servers Q. Umounted a "busy" filesystem... A. ?? Autofs does not remount/reload active partitons even after stopping autofs ?? ( says automount failed ) autofs start -- or -- autofs reload Q. /etc/rc.d/init.d/autofs for redhat 4.2 - autofs has some temp directory creation problems ?? -- forgot which version 9. Credits I wish to thank the author of autofs ( Peter Anvin hpa@transmeta.com ) for distributing a very useful program to the linux community. # # (c) 1998 Linux Consulting All rights Reserved # # end of document