Autofs Automounter HOWTO Written by Alvin Oga alvin@Linux-Consulting.com Ver 1.34, 07 December 1998 (c) 1998 Linux Consulting All rights Reserved This Autofs HOWTO document was written to provide the basics of autofs to mount and unmount partitions for access by the system and users. ______________________________________________________________________ Table of Contents 1. General Info 1.1 Introduction 1.2 Feedback & Corrections 1.3 Disclaimer 1.4 Copyright 1.5 Trademarks 2. General Info About Linux 2.1 Brief History of Linux 2.2 Where to get Linux ( Free distributions and commercial ones ) 2.3 Linux HOWTO Documents and FAQs 2.4 Linux HOWTOs 2.5 Grep'ping the HOWTOs 2.6 AutoFS Related Mailing List 2.7 Linux NewsGroups 2.8 Linux Networking related documents 2.9 Linux Document Search Engines 2.10 Other Websites 2.11 Linux Networking Related Books 2.12 Automounter Man Pages and source code 2.12.1 Man pages for amd 2.12.2 Man pages for autofs 2.12.3 Autofs source code is part of the newer linux kernels at 2.12.4 amd source code is 3. Automounter 3.1 What Automounter Allows You To Do 3.2 Some automounting tips excerpted from NET-2-HOWTO 4. Setting up the Automounters 4.1 Automounter Hardware Requirements 4.2 Automounter Software requirements 4.3 Check that your existing kernel supports autofs 4.4 Recompiling your kernel to support autofs 4.5 Generic System Files for the Network 4.5.1 /etc/fstab 4.5.2 /etc/mtab 4.5.3 /etc/exports 5. Automounter Examples 5.1 Solaris Automounter 5.1.1 Master Map file 5.1.2 Indirect Map file 5.1.3 Direct Map files 5.2 Amd Automounter Files 5.2.1 /etc/amd.conf 5.2.2 /.automount Amd Automounter Directory tree 5.2.3 /net 5.2.4 Amd arguments 5.2.5 To have amd automount two directories that was manually mounted. 5.2.6 Starting the amd Automounter 5.3 Autofs Files 5.3.1 Autofs Automounter Binaries and Config Files 5.3.2 Autofs Automounter Directory tree 5.3.3 /etc/auto.master Autofs files 5.3.4 /etc/auto.misc Autofs Mount Map File 5.3.5 Additional AutoFS Examples 5.3.6 Additional Submount Examples 5.3.7 Converting direct -> indirect map translation script 5.3.8 AutoFS w/ NIS+ style automaster file 5.3.9 Additional Samba Example 5.3.10 /Net Network Directory 5.3.11 Starting and stopping the automounter 6. Mount Options 6.1 General format for mount command 6.2 Mount Options 7. Testing Your Automounter 7.1 To Kill, Start, Reload Your Automounter 7.1.1 To Kill your automounter 7.1.2 To Start your automounter 7.1.3 To Reload your automounter 7.2 Verify the log files for any error messages 7.3 To See the Status of your automounter 7.3.1 Current Mounted Filesystem 7.3.2 Tracking the activity of the automounter 7.4 Sample Network Monitor Tools 8. Automounter FAQs 9. Credits and Acknowledgements ______________________________________________________________________ 11.. GGeenneerraall IInnffoo 11..11.. IInnttrroodduuccttiioonn The version of AutoFS-Automounter HOWTO was 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. 11..22.. FFeeeeddbbaacckk && CCoorrrreeccttiioonnss PPLLEEAASSEE RREEPPOORRTT AANNYY IINNAACCCCUURRAACCIIEESS IINN TTHHIISS DDOOCCUUMMEENNTT ttoo mmee ((aallvviinn@@LLiinnuuxx-- CCoonnssuullttiinngg..ccoomm)) 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. 11..33.. DDiissccllaaiimmeerr WWEE AARREE NNOOTT RREESSPPOONNSSIIBBLLEE FFOORR AANNYY DDAAMMAAGGEESS IINNCCUURRRREEDD DDUUEE TTOO AACCTTIIOONNSS OORR IINNAACCTTIIOONNSS TTAAKKEENN BBAASSEEDD OONN TTHHIISS DDOOCCUUMMEENNTT WWHHEETTHHEERR EEXXPPLLIICCIITTLLYY SSTTAATTEEDD OORR IIMMPPLLIIEEDD.. 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 back to the Linux community. Given that directory and file structure varies from the various vendors, and for simplicity, my examples assumes the "redhat" directory scheme. 11..44.. CCooppyyrriigghhtt 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 alvin@Linux- Consulting.com ( whois ao196 ). The HTML version of this document is available at http://www.Linux- Consulting.com/Amd_AutoFS 11..55.. TTrraaddeemmaarrkkss Trademarks are owned by their repective owners. There are no warranty with respect to the information in this document. Please feel free to use and distribute at your own risk under the terms of the GNU License. The content of this document is in the public domain, but please be polite and attribute any quotes. 22.. GGeenneerraall IInnffoo AAbboouutt LLiinnuuxx 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. 22..11.. BBrriieeff HHiissttoorryy ooff LLiinnuuxx I gathered some notable linux kernel release info from: +o http://www.linux.org +o http://www.kernel.org +o 1991 Linux-0.1 released... ( about 93K for linux-0.01.tar.gz ) RELNOTES-0.01 Linux-0.01 was compiled with gcc-1.40 and released by Linus Torvalds Linux boots from floppy drive. - It was binary compatible with single threaded file system of mimix, - no message passing and linux used multithreaded filesystem instead, - true multi-tasking was available with a 'better" scheduler than that on mimix. - Device drivers used interrupts which was not hidden. - There was no distinction in the kernel/fs/mm, and was all linked to the same heap and in its own subdirectory source tree and running in the same data/code space. - Simple memory management algorithm took advantage of page and segment faults features of the intel386 CPU. - linux partitions could be mounted from mimix but linux cound not mount mimix ( no mount command ) - Linux' kernel goes into supervisor mode to solve the multirace conditions and deadlocks to access the multithreaded file system. - GNU provided the shell (bash), compilers and libraries. +o MMM-199x Linux-0.12 released... RELNOTES-0.12 - SVGA Mode support for ET400 at 100x40 instead of 80x25 - job control: bg,fg, jobs & kill - support for virtual console, EGA, VGA - 387 emulation works with gcc-2.0 - support for symbolic links ( one level ) - mkswap was born for virtual memory +o 07-Mar-92 Linux-0.95 released ( about 138K for linux-0.95.tar.gz ) RELNOTES-0.95 - init & login prompt on 4 virtual consoles - extended partions support and device name change to the familiar /dev/hdxx - bash+tar+compress does NOT fit on floppy anymore - 5 depth levels of symlinks - improved virtual memory: swap, mkswap, swapon, dd - less mimix dependence - Linux-0.95a released on 17-Mar-92 ( about 100K for linux-0.95.gz ) - sh, ash replaced overgrown bash - binaries moved around: cat, more, mkdev, install, init, update - lots of activity around linux-0.95 by various contributers +o 12-Mar-94 Linux-1.0 Released ( about 1.2Mb for linux-1.0.tar.gz ) - the "proud day" +o 01-Aug-95 Linux-1.2.13 ( about 2.3Mb for linux-1.2.13.tar.gz ) - Disk access speedups, TTY improvements, - virtual memory enhancements, multiple platform - support, quotas +o 08-Jun-98 Linux-2.0 ( about 5.6Mb for linux-2.0.tar.gz ) - Many performance improvements, new networking protocols, - one of the fastest TCP/IP implementations in the world +o 08-Jun-96 Linux-2.0.tar.gz +o 02-Jul-96 Linux-2.0.1.tar.gz +o 04-Jul-96 Linux-2.0.2.tar.gz +o 05-Jul-96 Linux-2.0.3.tar.gz +o 07-Jul-96 Linux-2.0.4.tar.gz +o 09-Jul-96 Linux-2.0.5.tar.gz +o 11-Jul-96 Linux-2.0.6.tar.gz +o 14-Jul-96 Linux-2.0.7.tar.gz +o 24-Jul-96 Linux-2.0.8.tar.gz +o 25-Jul-96 Linux-2.0.9.tar.gz +o 26-Jul-96 Linux-2.0.10.tar.gz +o 04-Aug-96 Linux-2.0.11.tar.gz +o 08-Aug-96 Linux-2.0.12.tar.gz +o 16-Aug-96 Linux-2.0.13.tar.gz +o 20-Aug-96 Linux-2.0.14.tar.gz +o 25-Aug-96 Linux-2.0.15.tar.gz +o 31-Sep-96 Linux-2.0.16.tar.gz +o 02-Sep-96 Linux-2.0.17.tar.gz +o 05-Sep-96 Linux-2.0.18.tar.gz +o 11-Sep-96 Linux-2.0.19.tar.gz +o 13-Sep-96 Linux-2.0.20.tar.gz +o 20-Sep-96 Linux-2.0.21.tar.gz +o 08-Oct-96 Linux-2.0.22.tar.gz +o 18-Oct-96 Linux-2.0.23.tar.gz +o 29-Oct-96 Linux-2.0.24.tar.gz +o 08-Nov-96 Linux-2.0.25.tar.gz +o 22-Nov-96 Linux-2.0.26.tar.gz +o 01-Dec-96 Linux-2.0.27.tar.gz +o 14-Jan-97 Linux-2.0.28.tar.gz Jan-97 +o 07-Feb-97 Linux-2.0.29.tar.gz +o 08-Apr-97 Linux-2.0.30.tar.gz Note that next release - 6 months later !!! +o 17-Oct-97 Linux-2.0.31.tar.gz +o 17-Nov-97 Linux-2.0.32.tar.gz +o 16-Dec-97 Linux-2.0.33.tar.gz Dec-97 +o 03-Jun-98 Linux-2.0.34.tar.gz +o 13-Jul-98 Linux-2.0.35.tar.gz +o +o LLiinnuuxx iiss nnooww rreeaallllyy aa vveerryy ssttaabbllee pprroodduucctt +o 22..22.. WWhheerree ttoo ggeett LLiinnuuxx (( FFrreeee ddiissttrriibbuuttiioonnss aanndd ccoommmmeerrcciiaall oonneess )) There are tons of reading material on how to get started, some of which might interest you are: +o For more general info about linux, please read all the Linux documents including Linux-FAQ +o Installation-HOWTO by Eric S. Raymon, esr@thyrsus.com +o Linux INFO SHEET by Michael K. Johnson. johnsonm@redhat.com +o Linux META_FAQ by Michael K. Johnson johnsonm@redhat.com +o Linux can be downloaded for FREE from several sites, eg: Free Linux Distributions , Distribition HOWTO by Michael K. Johnson johnsonm@redhat.com +o Linux is also distrributed on CDROM media by many Commercial Linux Resources +o ..the list goes on and on... 22..33.. LLiinnuuxx HHOOWWTTOO DDooccuummeennttss aanndd FFAAQQss 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. To contribute linux related documents join the mailing list lliinnuuxx-- ddoocc@@vvggeerr..rruuttggeerrss..eedduu mailing list. To: majordomo@vger.rutgers.edu Subject: subject line is ignored help end 22..44.. LLiinnuuxx HHOOWWTTOOss The 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 Tim Bynum, linux-howto@sunsite.unc.edu +o You might have a local copy of the entire LDP HOWTO on your linux disk at /usr/doc/HOWTO +o HOWTOs are posted to comp.os.linux.answers +o HOWTOs are available in text, HTML, DVI and postscript formats from +o SunSite.unc.edu +o TSX-11.mit.edu +o SunSite.unc.edu HowTo Index +o Additional Linux HOWTO Mirror sites +o Linux FAQs are at SunSite.unc.edu 22..55.. GGrreepp''ppiinngg tthhee HHOOWWTTOOss 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 at: +o ftp://ftp.Linux-Consulting.com/pub/HOWTO +o http://www.Linux-Consulting.com:/HOWTO A simple grep based search engine is at: Searching the HOWTO 22..66.. AAuuttooFFSS RReellaatteedd MMaaiilliinngg LLiisstt There is an autofs mailing list at aauuttooffss@@lliinnuuxx..kkeerrnneell..oorrgg Send email to majordomo@linux.kernel.org with "subscribe autofs" in the body of the email. Add "end" as the second line if you have a signature file appended to your outgoing emails +o TToo SSuubbssccrriibbee ttoo tthhee AAuuttooffss mmaaiilliinngg lliisstt 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 echo "subscribe autofs" | elm -s "Subscribing to autofs" majordomo@linux.kernel.org +o TToo uunnssuubbssccrriibbee,, uussee tthhee kkeeyywwoorrdd ""uunnssuubbssrriibbee"" iinnsstteeaadd.. 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 echo "unsubscribe autofs" | elm -s "Unsubscribing to autofs" majordomo@linux.kernel.org +o TToo jjooiinn tthhee LLiinnuuxx lliinnuuxx--nneett cchhaannnneell oonn tthhee mmaaiill lliisstt sseerrvveerr,, sseenndd mmaaiill ttoo:: From your email client: To: Majordomo@vger.rutgers.edu Subject: Subject line is ignored subscribe linux-net end or if you are a command line type of user echo "subscribe linux-net" | elm -s "Subscribing to linux- net" majordomo@vger.rutgers.edu 22..77.. LLiinnuuxx NNeewwssGGrroouuppss For more info, visit LDP at Linux NewsGroups +o ccoommpp..ooss..lliinnuuxx..aaddmmiinn is an unmoderated newsgroup for discussion of administration of Linux systems. +o ccoommpp..ooss..lliinnuuxx..ddeevveellooppmmeenntt..ssyysstteemm is an unmoderated newsgroup specifically for discussion of Linux kernel development. +o ccoommpp..ooss..lliinnuuxx..ddeevveellooppmmeenntt..aappppss is an unmoderated newsgroup specifically for discussion of Linux-related applications development. +o ccoommpp..ooss..lliinnuuxx..hhaarrddwwaarree is for Linux-specific hardware questions. +o ccoommpp..ooss..lliinnuuxx..nneettwwoorrkkiinngg is for Linux-specific networking development and setup questions. +o ccoommpp..ooss..lliinnuuxx..xx is for Linux-specific X Windows questions. +o ccoommpp..ooss..lliinnuuxx..mmiisscc is the replacement for comp.os.linux, and is meant for any discussion that doesn't belong elsewhere. +o LLiinnuuxx..** newsgroups... 22..88.. LLiinnuuxx NNeettwwoorrkkiinngg rreellaatteedd ddooccuummeennttss A well written networking HOWTO is NET-3-HOWTO written by Terry Dawson, terry@perf.no.itg.telecom.com.au http://sunsite.unc.edu/LDP/HOWTO/NET-3-HOWTO.html The Linux Network Administration Guide is Copyright (c) by Olaf Kirch has written a substantial document as part of the Linux Documentation Project and is freely available from the site. You should also read the other HOWTO documents relevant to networking with Linux. They are: +o 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. +o PPP-HOWTO if you intend using PPP. +o IPX-HOWTO if you would like information relating to IPX support for Linux. +o Serial-HOWTO if you intend using SLIP or PPP in server mode. +o Automount mini-Howto This file describes the autofs automounter, how to configure it, and points out some problems to avoid. +o NIS-HOWTO if you are interested in running a version of Sun's Network Information Service. +o NIS-3 HOWTO Linux Networking HOWTO +o NFS HOWTO Linux NFS Clients and Servers +o SMB-HOWTO How to connect Linus to Microsoft Win95/WinNT machines using the Session Message Block (SMB) protocol, also called the NetBIOS or LanManager protocol. +o HAM-HOWTO if you are interested in configuring and running amateur radio software. +o Mail-HOWTO and the News-HOWTO for some specific information on setting up Mail and News on your system. +o UUCP-HOWTO if you will be connecting to the net via UUCP. +o 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: +o tcp/ip introduction text version tcp-ip-intro.doc postscript version tcp-ip-intro.ps . +o tcp/ip administration text version tcp-ip-damin.doc , postscript version tcp-ip-admin.ps . 22..99.. LLiinnuuxx DDooccuummeenntt SSeeaarrcchh EEnnggiinneess Search Engines in the Linux Documents and Man Pages +o http://amelia.db.erau.edu/Excite/AT-LDPquery.html Excite Search Engine +o http://sunsite.unc.edu/LDP/search.html LDP Search Engine +o http://www.ctyme.com/linuxdoc.htm Linux MAN Page Search Engine +o http://www.Linux-Consulting.com/HOWTO.Search Grep Based HOWTO.Search 22..1100.. OOtthheerr WWeebbssiitteess The AutoFS HOWTO is maintained at http://www.Linux- Consulting.com/Amd_AutoFS The NET-2/3-HOWTO is available at: +o Linux Documentation Project +o web.mit.edu +o www.pa.msu.edu +o cesdis.gsfc.nasa.gov and the automounter section is NET-2-HOWTO-11.html +o Chinese Net-2/3 22..1111.. LLiinnuuxx NNeettwwoorrkkiinngg RReellaatteedd BBooookkss The Linux Network Administration Guide is copyright (c) by Olaf Kirch is freely available from various sites. The book is published by SSC - Specialized System Consultants Additional network related books are available from our friends at OReilly & Associates +o Linux Network Administrators Guide by Olaf Kirch +o TCP/IP Network Administration by Craig Hunt +o Networking Personal Computers with TCP/IP by Craig Hunt An online Quick AutoFS Tutorial by Marc Neilsen 22..1122.. AAuuttoommoouunntteerr MMaann PPaaggeess aanndd ssoouurrccee ccooddee 22..1122..11.. MMaann ppaaggeess ffoorr aammdd +o man amd +o man amdxref +o man amd.con 22..1122..22.. MMaann ppaaggeess ffoorr aauuttooffss +o man autofs +o man auto.master 22..1122..33.. AAuuttooffss ssoouurrccee ccooddee iiss ppaarrtt ooff tthhee nneewweerr lliinnuuxx kkeerrnneellss aatt +o /usr/src/linux/fs/autofs +o /usr/doc/autofs-3.1.1 22..1122..44.. aammdd ssoouurrccee ccooddee iiss +o am-utils by Erez Zadok ( ezk@cs.columbia.edu ) http://www.cs.columbia.edu/ ezk/am-utils +o /usr/doc/am-utils-6.0a16//README +o /usr/doc/am-utils-6.0a16//README.autofs 33.. AAuuttoommoouunntteerr 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 the load on both the server and the client and provides a great deal of flexibility even for local server and it's filesystems. AAnn aauuttoommoouunntteerr pprroovviiddeess 44 kkeeyy ffeeaattuurreess:: +o An automounter makes exported filesystems on all servers listed in /etc/hosts available to your local host machine +o Wildcarding in the automounter makes it easy to mount remote directories to like-named mount points on the local host machine +o The automounting features of the programs mounts only the exported filesystems that is used from the possibly huge list of servers +o Having multiple servers improves the reliability of the servers and the network by removing the dependency on teh network 33..11.. WWhhaatt AAuuttoommoouunntteerr AAlllloowwss YYoouu TToo DDoo +o transparently mount your home dir if you need it +o transparently mount your backup directory as you need it +o transparently mount your mail server for reading and deleting +o compare files on the different servers +o 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. +o increase the reliability of your LAN by removing the dependecies on a single server +o 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 auto- mounter the ability to merge the contents of multiple direc- tories into a single directory. 33..22.. SSoommee aauuttoommoouunnttiinngg ttiippss eexxcceerrpptteedd ffrroomm NNEETT--22--HHOOWWTTOO 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 aauuttoommoouunntt22aammdd..ppll which can be found at in the 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. 44.. SSeettttiinngg uupp tthhee AAuuttoommoouunntteerrss 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... 44..11.. AAuuttoommoouunntteerr HHaarrddwwaarree RReeqquuiirreemmeennttss - you will need an ethernet cable ( RJ45 or BNC ) for your network card - make sure your ethernet card is listed in the Ethernet-HOWTO hardware compatible list 44..22.. AAuuttoommoouunntteerr SSooffttwwaarree rreeqquuiirreemmeennttss The amd automounter does NOT require any kernel support. Therefore you should be able to get it running with no problems. The current versions of amd is available from: ftp://sunsite.unc.edu:/pub/Linux/system/mount/ amd920824upl67.tar.gz aauuttoommoouunntt22aammdd..ppll script in NET-2-HOWTO will convert Sun automounter map file format into amd map file format. TThhee aauuttooffss aauuttoommoouunntteerr oonn tthhee ootthheerrhhaanndd ddooeess RREEQQUUIIRREE kkeerrnneell lleevveell ssuuppppoorrtt.. The current versions of autofs is available from: ftp.kernel.org:/pub/linux/daemons/autofs/ autofs-3.1.1.tar.gz ftp://sunsite.unc.edu/pub/Linux/system/mount/ autofs-3.1.0.tar.gz Autofs source code is also included in the the Linux kernel source tree at: /usr/src/linux/fs/autofs ( on your local disk ) 44..33.. CChheecckk tthhaatt yyoouurr eexxiissttiinngg kkeerrnneell ssuuppppoorrttss aauuttooffss root# cat /proc/filesystems ext2 ... nodev autofs <<---- required for autofs # Note: Kernel.Version will vary on your system, eg: 2.0.35 for linux-2.0.35 # # if autofs is not listed...you can try to install the autofs module: # root# /sbin/insmod /lib/modules/Kernel.Version/fs/autofs.o or root# /sbin/modprobe autofs # # # Now Check if the module is loaded # root# /sbin/lsmod should list the loaded modules # Module Pages Used by ... autofs 1 2 (autoclean) # If your linux kernel does NOT support autofs, you will get in your log files: ( /var/log/messages ) Jul 20 11:40:40 xxx automount[29602]: >> mount: fs type autofs not supported by kernel Jul 20 11:40:40 xxx automount[29602]: /kernel: mount failed! 44..44.. RReeccoommppiilliinngg yyoouurr kkeerrnneell ttoo ssuuppppoorrtt aauuttooffss Given that recompiling the kernel is a lot of fun to some and a source of aggrevation to others... and if you are not comfortable with your linux hardware and software configuration, you should consider using amd first and play with the kernel at a later date. For more info, see Linux Kernel HOWTO Be sure to enable modules support, so that features can be incrementally added to your kernel without having to recompile it each time. To verify if your kernel supports autofs +o Use the autofs script to check the status root# /etc/rc.d/init.d/autofs status Configured Mount Points: /usr/sbin/automount --timeout 600 /.autofs file /etc/auto.misc Active Mount Points: /usr/sbin/automount --timeout 60 /.autofs file /etc/auto.mis +o Searching for the autofs strings in the compiled kernel sources root# grep -i autofs /usr/src/linux-2.0.3x/.config CONFIG_EXPERIMENTAL=y <<--- required for autofs ....etc... CONFIG_AUTOFS_FS=y <<--- required for autofs 44..55.. GGeenneerriicc SSyysstteemm FFiilleess ffoorr tthhee NNeettwwoorrkk These are the files that must be configured for your network and varies from the different linux distributions. 44..55..11.. //eettcc//ffssttaabb the /etc/fstab is a file that defines your file system and is read at boot time. General fstab file 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 # # Sample /etc/fstab file # ------ # # These filesystems are mounted by # root# mount -a # # To view the mounted filesystems # root# showmount -e # or # root# df # # # 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 # /dev/sdb1 /people ext2 defaults 0 2 # # Do not mount on reboots /dev/sdc1 /cdrom iso9660 noauto,default,ro 0 2 # # # If you want to be able to manually mount these filesystems # # make sure /mnt/kernel.org 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. 44..55..22.. //eettcc//mmttaabb 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. 44..55..33.. //eettcc//eexxppoorrttss 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 # # Sample /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 commonly used 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 below for more info a loadable module or pre-compiled into the linux kernel. 55.. AAuuttoommoouunntteerr EExxaammpplleess These examples were taken from TCP/IP Network Admin by Craig Hung, published by O'Reilly and Associates 55..11.. SSoollaarriiss AAuuttoommoouunntteerr For comparason, for those of you that understand Solaris' NFS automounter, 55..11..11.. MMaasstteerr MMaapp ffiillee The Master Map configuration file is read by automount. It lists all the map files used by the automounter. # # Sample /etc/auto_master ( equivalent of /etc/auto.master in linux ) # ------ these Solaris options are NOT necessarily compatible with linux' autofs # # Excerpted from TCP/IP Network Administration, Chap 9 # # 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 55..11..22.. IInnddiirreecctt MMaapp ffiillee An Indirect map configuration file lists the pathnames and relative mount points, /home in this case # # Sample /etc/auto_home # ------ these Solaris options are NOT necessarily compatible with linux' autofs # # Excerpted from TCP/IP Network Administration, Chap 9 # # 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 55..11..33.. DDiirreecctt MMaapp ffiilleess # # Sample /etc/auto_direct ( Direct map file ) # ------ these Solaris options are NOT necessarily compatible with linux' autofs # # Excerpted from TCP/IP Network Administration, Chap 9 # # # 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 55..22.. AAmmdd AAuuttoommoouunntteerr FFiilleess amd is another popular automounter and I shall briefly describe it's files for similarity The amd related binaries and files are: /usr/sbin/amd amd binary /etc/amd.conf amd config file /etc/rc.d/init.d/amd amd startup script /.automount temporary directory to manage the mount points /var/log/messages log files ( depends on your syslog.conf ) 55..22..11.. //eettcc//aammdd..ccoonnff # # Sample /etc/amd.conf # ------ these amd configurations are NOT necessarily compatible with linux' autofs # # see man pages for more info, "man 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 55..22..22.. //..aauuttoommoouunntt AAmmdd AAuuttoommoouunntteerr DDiirreeccttoorryy ttrreeee /.automount is your mount point, and is managed by the amd automount daemon. The name of the moint point directory used is defined by the -a option root# /usr/sbin/amd -a /.automount .... And, you must make sure that the directory exists root# mkdir /.automount Please do NOT add or delete links, files, sub-directories from this direcotry amd will create subdirectories for "mount points" for the servers root# ls -l /.automount /.automount/server1 /.automount/server2 /.automount/server3 55..22..33.. //nneett amd will create links to the /.automount directory Please do NOT create these links...amd will do it dynamically for you... root# ls -la /net server1 -> /.automount/server1 server2 -> /.automount/server2 server3 -> /.automount/server3 55..22..44.. AAmmdd aarrgguummeennttss Usually amd is invoked by root# /etc/rc.d/init.d/amd stop root# /etc/rc.d/init.d/amd start The default arguments are: root# /usr/sbin/amd -a /.automount -l syslog -c 1000 /net /etc/amd.conf -a /.automount defines the temporary directory to manage the mount points -l syslog tells amd to log all messages via syslogd -c 1000 tells amd to cache the remote host's filesystem for 1000 seconds /net tells amd to put it's links here /etc/amd.conf tells amd where to find it's config files To Check on the status of amd # amq -ms 55..22..55.. TToo hhaavvee aammdd aauuttoommoouunntt ttwwoo ddiirreeccttoorriieess tthhaatt wwaass mmaannuuaallllyy mmoouunntteedd.. Excerpted from Net-2/3-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 are nfs mounting server-1 and server-2 onto your linux disk on the /nfs directory as /nfs/server-1 and /nfs/server-2. 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: Example /etc/amd.server file # # Sample /etc/amd.server # ------ these amd configurations are NOT necessarily compatible with linux' autofs # /defaults opts:=rw;type:=nfs # server-1 rhost:=server-1;rfs:=/export/disk server-2 rhost:=server-2;rfs:=/export/disk # # AutoMount the remote Home Server home directory home host!=HomeSrvr;type:=nfs;rhost:=HomeSrvr;rfs:=/home # # AutoMount the remote Mail Server mail directory mail host!=MailSrvr;type:=nfs;rhost:=MailSrvr;rfs:=/var/spool/mail # # end of file 55..22..66.. SSttaarrttiinngg tthhee aammdd AAuuttoommoouunntteerr root# /etc/rc.d/init.d/amd stop root# /etc/rc.d/init.d/amd start - or - root# /etc/rc.d/init.d/amd reload Check the log files and the status of the amd automounter root# /etc/rc.d/init.d/amd status root# cat /etc/mtab root# amq -ms root# df root# showmount -e root# tail -100 /var/log/messages Your amd log messages ( /var/log/messages ) could look like: # # I do NOT know what "old syntax" it's complaining about... # Aug 17 08:28:02 HomeSrv amd[865]: key /defaults: Old syntax selector found: type=nfs Aug 17 08:28:02 HomeSrv amd[865]: key /defaults: Old syntax selector found: type=nfs= Aug 17 08:28:02 HomeSrv amd[865]: skipping selector to "" # Aug 17 08:28:02 HomeSrv amd[865]: file server remote.your_domain.com type nfs starts up Aug 17 08:28:02 HomeSrv amd[865]: Flushed /net/remote; dependent on remote.your_domain.com Aug 17 08:28:02 HomeSrv amd[21970]: linux mount: type nfs Aug 17 08:28:02 HomeSrv amd[21970]: linux mount: version 1 Aug 17 08:28:02 HomeSrv amd[21970]: linux mount: fd 8 Aug 17 08:28:02 HomeSrv amd[21970]: linux mount: hostname www.xxx.yyy.zzz Aug 17 08:28:02 HomeSrv amd[21970]: linux mount: port 2049 Aug 17 08:28:02 HomeSrv amd[21970]: linux mount: fsname remote:/ Aug 17 08:28:02 HomeSrv amd[21970]: linux mount: type (mntent) nfs Aug 17 08:28:02 HomeSrv amd[21970]: linux mount: opts rw Aug 17 08:28:02 HomeSrv amd[21970]: linux mount: dir /.automount/remote Aug 17 08:28:02 HomeSrv amd[865]: remote:/ mounted fstype nfs on /.automount/remote Now if you say: root# ls /nfs you should see no files. However the command: root# 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. 55..33.. AAuuttooffss FFiilleess 55..33..11.. AAuuttooffss AAuuttoommoouunntteerr BBiinnaarriieess aanndd CCoonnffiigg FFiilleess The autofs related binaries and files are: /usr/sbin/automount autofs binary /etc/auto.master master file /etc/auto.misc map file /etc/rc.d/init.d/autofs autofs startup script /usr/lib/autofs autofs libraries /lib/modules/Kernel.Version/fs/autofs.o autofs loadable module /.autofs temporary directory to manage the mount points /var/log/messages log files ( depends on your syslog.conf ) Note: Kernel.Version will vary on your system, eg: 2.0.35 for linux-2.0.35 NOTE: Sometimes the autofs startup script is at /etc/rc.d/rc.autofs 55..33..22.. AAuuttooffss AAuuttoommoouunntteerr DDiirreeccttoorryy ttrreeee /.autofs This is your temporary mount directory, 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 directory does not exit, please create it. root# mkdir /.autofs 55..33..33.. //eettcc//aauuttoo..mmaasstteerr AAuuttooffss ffiilleess 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. -- -- autofs does NOT reload nor restart if the mounted directory ( eg: /home ) is busy -- In the example below, /.autofs is the mount point and /etc/auto.misc is the map file defining the options for the mount point. # # Sample /etc/auto.master file # ------ # # see man pages for more info, "man autofs.master" # # 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 55..33..44.. //eettcc//aauuttoo..mmiisscc AAuuttooffss MMoouunntt MMaapp FFiillee 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 read only from the remote host -soft if the remote host is unavailable, return an error and don't retry after the timeout period expired -hard if the remote host is unavailable, retry until it does respond - be careful that hard mounts does NOT causes slow network and hung systems ( use it in conjunction with -intr or be readily available to check ( on the network status -intr allows the keyboard interrupts to kill the process that is hung waiting for the remote host to respond -bg do the retries in background mode -fg do the retries in foreground mode -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 CCAAUUTTIIOONN:: When defining /home directories and partitions, please be aware of /home from your remote server IS 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. When the automounter is properly loaded and running, it will manage some directories in it's temporary mount dirctory /.autofs. # # 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 ??? is it supported ?? # # # To implement "/net -hosts" form from Solaris automounter: # # * -soft,bg,intr &:/ # # # To automount your WinNT box # WinNT_C -fstype=smbfs,login=your_id,passwd=xxxxxx WinNT:/C # # end of file 55..33..55.. AAddddiittiioonnaall AAuuttooFFSS EExxaammpplleess Excerpted from autofs mailing list, submitted by Peter Anvin (hpa@transmeta.com) To have autofs automount your remote hosts # # Sample auto.master # ------ # /auto auto.auto # # end of file # # Sample auto.auto # ------ # host1 -fstype=autofs file:/etc/auto.host1 host2 -fstype=autofs file:/etc/auto.host2 host3 -fstype=autofs file:/etc/auto.host3 # # end of file (If you're using something else than file maps, substitute with yp:auto.host1 or whatever.) If you have options for the various host maps, add them after the -fstype argument (e.g. -fstype=autofs,ro) or add them to the entries in the individual host maps (probably preferred, then you can control them per individual mount point, too.) For expires to work properly you need a recent 2.1.x kernel. 55..33..66.. AAddddiittiioonnaall SSuubbmmoouunntt EExxaammpplleess Two excerpted from autofs mailing list by Richard Henderson (rth@cygnus.com) The following fragment allows /nfs/host/disk to work automatically, assuming it is exported from the host from /host/disk. This is the configuration we have at Cygnus. # # Sample /etc/auto.master # ------ # /nfs /etc/autofs/nfs rw,intr,rsize=8192,wsize=8192 # # end of file # # Sample /etc/autofs/nfs # ------ # ... some exceptions to the rule ... # * -fstype=autofs,-Dhost=&,-Dprefix=/& file:/etc/autofs/nfs.sub # # end of file # # Sample /etc/autofs/nfs.sub # ------ # * ${host}:${prefix}/& # # end of file Another Submount Example and Explanation submitted by Rainer Clasen clasen@unidui.uni-duisburg.de A submount is a subdirectory of the automount point, or more precisely: A submount generates a new automount sublevel beneath the current one. Syntax: ======= syntax for submounts in sun-style maps: -[other options,]fstype=autofs[,other options] : the name of the subdirecctory how you retrieve your maps: file, yp, nisplus, hesiod, program for filemaps a full path eg. /etc/auto.cd, for yp the mapname eg. auto.cd in addition to [,other options] submounts seem to inherit the map options. Submount Example 2a =================== I want my cdroms accessible as /vol/cd/ Top level automount watches /vol. I define "cd" as submount. If somebody does an "ls /vol/cd" autmount mkdirs /vol/cd and starts a new automount watching /vol/cd. Somebody accesses /vol/cd/1 and the new automount could try to mount one of my cdroms. # /etc/auto.master /vol /etc/auto.vol # end of file # /etc/auto.vol # # Hrm, I want all my cdroms in a subdirectory, I don't like calling em cdrom0 # cd -fstype=autofs file:/etc/auto.cd # end of file # /etc/auto.cd 0 -fstype=iso9660,ro :/dev/scd0 1 -fstype=iso9660,ro :/dev/scd1 # end of file Submount Example 2b =================== Basic idea borowed from Richard Henderson (rth@cygnus.com) I want all hosts' filesystem accessible as as /net// . This needs all hosts exporting their fs's as /disk/ . I can think of two ways to acomplish this: either mount them as /disk/, or make /disk/ a symlink to the real mountpoint ( At least you'll need a symlink root -> / ). Top level automount watches /net. It's map has a wildcard key (*) to avoid unneccessary typing. To avoid needing one map for each host I define a variable with the hostname (ie. the looked up key). # /etc/auto.master /net /etc/auto.net # end of file # /etc/auto.net * -fstype=autofs,-Dhost=& file:/etc/auto.netsub # end of file # /etc/auto.netsub * ${host}:/disk/& # end of file Richard's original assumes each host offers its filesystems as // . It uses another variable named prefix to store that / part. My example matches Richard's with a hardwired prefix of /disk. some Notes: =========== - you can always put some exceptions above the wildcard entry - & is replaced with te key used to lookup - variables become more important with submounts - there is no variable substitution within the key I encountered two bugs while playing with submounts. See my other post for a patch. 55..33..77.. CCoonnvveerrttiinngg ddiirreecctt -->> iinnddiirreecctt mmaapp ttrraannssllaattiioonn ssccrriipptt Excerpted from autofs mailing list, submitted by Justin Hahn (jehahn@raven.bu.edu) The systems I administrate are mostly Sun Workstations. Lately we've been adding a few Linux Workstations, and I realized I had an autofs problem. Last I checked autofs didn't handle direct maps. However 99% of our NFS mounts are handled by a direct map distributed by NIS. I've created the following perl script as a QUICK hack around the problem. I'd like suggestions on improving it. It appears to work, although I'm not sure about what automount wants to be given. I know that if I just give it the mount point it works, but I'd like to be able to pass options. I haven't checked the source yet to check out what I could be passing instead, but I will soon. Again any comments you can give me are seriously appreciated. --- BEGIN auto_direct_map.pl #!/usr/bin/perl use strict; # # Globals # my $YPCAT = "/usr/bin/ypcat"; my $MAPNAME = "auto_direct"; # NONE! # # main block - keep it all in one nice neat place # main: { my (%opts, %mounts)=(); my ($i,$j,$k)=(); # if(scalar(@ARGV) != 1) { exit(0); #Just die quietly. Users shouldn't call us. } # open(FILE, "$YPCAT -k $MAPNAME|") or die("Can't fork $YPCAT. Contact Admin."); # while(defined($_=)) { ($i,$j,$k)=split(); $i =~ s[^/][]; $opts{$i}=$j if($i); $mounts{$i}=$k if($i); } # # How do we add the options, etc. in?.... hmmm... # printf("%s\n",$mounts{$ARGV[0]}) if($mounts{$ARGV[0]}); close(FILE); # exit(0); } # end main 55..33..88.. AAuuttooFFSS ww// NNIISS++ ssttyyllee aauuttoommaasstteerr ffiillee These patches were excerpted from the mailing lists or submitted to me and I have NOT tested these. Please let me know if there is any clarification of changes required. Larry Augustine's NIS & autofs rc patch is available at AutoFS.NIS.ScriptPatches Michel Lespinasse's NIS & autofs rc script is available at AutoFS.NIS.sh Note: The filename extension is ._sh so that you can view/click it 55..33..99.. AAddddiittiioonnaall SSaammbbaa EExxaammppllee Samba allows linux servers to read/write files on Microsoft PCs running WFW, Win95, Win98, WinNT. It is available from http://samba.anu.edu.au/samba Excerpted from autofs mailing list, submitted by Peter Kudrat (kundrat@gw.gic.sk) # # Sample automounting for Samba filesystem ( Win95/Win98/WinNT ) # ------ # ( add these to /etc/auto.misc ) # # see http://www.wittsend.com/mhw/smbmount.html for converting # linux-2.0.x/smbfs to linux-2.1.x/samba compatible options # sys -fstype=smbfs,login=your_id,passwd=xxxxxx ://WinNT/System data -fstype=smbfs,login=your_id,passwd=xxxxxx ://WinNT/Data # # end of file and checking the log file ( /var/log/messages ) will show something like: ... Aug 29 12:32:43 brana automount[325]: attempting to mount entry /WinNT/users Aug 29 12:32:43 brana automount[11139]: lookup(file): looking up users Aug 29 12:32:44 brana automount[11139]: lookup(file): users -> -fstype=smbfs,login=yyyy,passwd=xxx://WinNT/Users Aug 29 12:32:44 brana automount[11139]: expanded entry: -fstype=smbfs,login=yyyy,passwd=xxxx^I^I://WinNT/Users Aug 29 12:32:44 brana automount[11139]: parse(sun): gathered options: fstype=smbfs,login=yyyy,passwd=xxxx Aug 29 12:32:44 brana automount[11139]: parse(sun): core of entry: //WinNT/Users Aug 29 12:32:44 brana automount[11139]: do_mount //WinNT/Users /WinNT/users type smbfs options login=yyyy,passwd=xxxx using module smbfs Aug 29 12:32:44 brana automount[11139]: mount(smbfs): calling mkdir /WinNT/users Aug 29 12:32:44 brana automount[11139]: >> Added interface ip=194.1.129.233 bcast=194.1.129.233 nmask=255.255.255.255 Aug 29 12:32:44 brana automount[11139]: >> Server time is Sat Aug 29 12:32:36 1998 Aug 29 12:32:44 brana automount[11139]: >> Timezone is UTC+2.0 Aug 29 12:32:44 brana automount[11139]: >> Domain=[GICNET] OS=[Windows NT 4.0] Server=[NT LAN Manager 4.0] Aug 29 12:32:44 brana automount[11139]: >> security=user Aug 29 12:32:44 brana automount[11139]: mount(smbfs): mounted //WinNT/Users on /WinNT/users 55..33..1100.. //NNeett NNeettwwoorrkk DDiirreeccttoorryy NNOOTTEE:: DDoo NNOOTT ccrreeaattee aannyy ffiilleess oorr ddiirreeccttoorriieess iinn //..aauuttooffss 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# ln -s ../.autofs/Server1 . root# ln -s ../.autofs/Server2 . Create your links for your users home directory ( /home/$USER ): root# cd / root# ln -s .autofs/home . Create your links for incoming emails: root# cd /var/spool 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 -l /var/spool/mail To view the contents of the mail server root# ls -l /var/spool/mail/ To view the Servers on your local LAN root# ls -l /Net/* To compare timestamps, sizes on the passwd files root# ls -l /Net/*/etc/passwd 55..33..1111.. SSttaarrttiinngg aanndd ssttooppppiinngg tthhee aauuttoommoouunntteerr --- --- WARNING: do NOT stop the automount daemon if you have any directories --- automounted at the time such as /home, /var/spool/mail, etc --- --- autofs daemon will not reload nor restart itself...therefore no --- new filesystems, partitions can be mounted... To stop the daemon root# /etc/rc.d/init.d/autofs stop To start the daemon root# /etc/rc.d/init.d/autofs start To stop and start the daeon with one command root# kill -HUP "pid_of_the_autofs_daemon" ( automount ) Check the log files and the status of the autofs automounter root# /etc/rc.d/init.d/autofs status root# cat /etc/mtab root# df root# showmount -e root# tail -100 /var/log/messages 66.. MMoouunntt OOppttiioonnss For more information, see the man pages: man mount 66..11.. GGeenneerraall ffoorrmmaatt ffoorr mmoouunntt ccoommmmaanndd mount remote_host:/remote_directory /local_mount_point The remote_directory must be exported by remote_host as defined in the remote_host's /etc/exports file. root# mount -a Linux mount everything allowed root# mountall Solaris equivalent 66..22.. MMoouunntt OOppttiioonnss Refer to "man mount" for all your options and details -ro Read only -rw Mount the filesystem read and write, but can be restricted by the server, and a warning is flagged -blocksize=1024 block size -rsize=4096 Read buffer size -wsize=4096 Write buffer size -intr allow keyboard interrupts to kill the process that is hung waiting for the server that is down. -nointr No keyboard interrupts allowed. -soft if the server fails to respond, return an error after the timeout period ( -timeo=value ) expires 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. ( use with -intr to allow killing hung processes ) -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 77.. TTeessttiinngg YYoouurr AAuuttoommoouunntteerr CCAAUUTTIIOONN:: Before killing your automount daemons, make sure no one is using the mounted filesystem CCoommmmoonn pprroobblleemmss ssuucchh aass ""hhuunngg ccoommmmaannddss"" aanndd ssllooww ccoommmmaannddss ccaann bbee aavvooiiddeedd bbyy aa wweellll aaddmmiinniisstteerreedd nneettwwoorrkk ppoolliiccyy.. 77..11.. TToo KKiillll,, SSttaarrtt,, RReellooaadd YYoouurr AAuuttoommoouunntteerr 77..11..11.. TToo KKiillll yyoouurr aauuttoommoouunntteerr root# /etc/rc.d/init.d/autofs stop 77..11..22.. TToo SSttaarrtt yyoouurr aauuttoommoouunntteerr root# etc/rc.d/init.d/autofs start 77..11..33.. TToo RReellooaadd yyoouurr aauuttoommoouunntteerr 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 ( /var/log/messages ) # 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 77..22.. VVeerriiffyy tthhee lloogg ffiilleess ffoorr aannyy eerrrroorr mmeessssaaggeess Please verify that log messages in /var/log/messages, you should see the following if it mounted your directories properly Messages at boot time root# 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 77..33.. TToo SSeeee tthhee SSttaattuuss ooff yyoouurr aauuttoommoouunntteerr root# ps auxwl | grep auto or: root# ps auxwl | grep '[a]uto' /usr/sbin/automount --timeout 60 /.autofs file /etc/auto.misc root# /etc/rc.d/init.d/autofs status ( for autofs ) 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 root# amq -ms ( for amd ) root# showmount -e thishost ( for the mountpoints on thishost ) 77..33..11.. CCuurrrreenntt MMoouunntteedd FFiilleessyysstteemm 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 -l /.autofs/ Each of the avove command will result in a attempt by the automounter to mount the requested directory and logged root# tail -100 /var/log/messages ... Aug 14 01:42:39 xxx automount[370]: attempting to mount entry /.autofs/home 77..33..22.. TTrraacckkiinngg tthhee aaccttiivviittyy ooff tthhee aauuttoommoouunntteerr 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 -l /Net or /Net/* lrwxrwxrwx 1 root root 1 Jul 30 03:39 localhost -> // 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 xxx automount[730]: expired /.autofs/home Aug 14 01:49:08 xxx automount[730]: expired /.autofs/mail Aug 14 01:49:08 xxx 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 77..44.. SSaammppllee NNeettwwoorrkk MMoonniittoorr TToooollss +o ftp://ftp.ibr.cs.tu-bs.de/pub/local cmu-snmp2.1.2l3-src.tar.gz ( snmp agent ) by Erik Schoenfelder, (schoenfr@ibr.cs.tu-bs.de) +o http://sunsite.unc.edu/pub/Linux/system/network/management netwatch statnet tcpdump tcpview trafshow +o http://sunsite.unc.edu/pub/Linux/system/network/monitor iptraf netl netwatch udplog wmrxtx 88.. AAuuttoommoouunntteerr FFAAQQss 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 timing 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 99.. CCrreeddiittss aanndd AAcckknnoowwlleeddggeemmeennttss I wish to thank the author of autofs, Peter Anvin (hpa@transmeta.com) for distributing a very useful program to the linux community. This document was created with SGML Tools Additional contributions, corrections and additions to this document was provided by: Larry Augustine lma@VaResearch.com Tim Bynum linux-howto@SunSite.UNC.edu Rainer Clasen clasen@unidui.uni-duisburg.de Peter Funk pf@artcom0.north.de Justin Hahn jehahn@raven.bu.edu Richard Henderson rth@cygnus.com Ian Kluft ikluft@thunder.sbay.org Peter Kudrat kundrat@gw.gic.sk Michel Lespinasse walken@wrs.com Hannes Reinecke Hannes.Reineke@mathi.uni-heidelburg.de Brion Vibber brion@rdaneel.dyn.ml.org