Sophie

Sophie

distrib > Mandriva > 2010.1 > x86_64 > media > contrib-release > by-pkgid > 5ae6a2e3416d2e2f9756d0910c807f6f > files > 19

howto-sgml-en-2006-5mdv2010.0.noarch.rpm

<!doctype linuxdoc system>

<!-- Automount mini-howto -->

<article>

<!-- Title information -->

<title>Automount mini-Howto
<author> Rahul Sundaram, <url url="mailto:Rahulsundaram AT yahoo DOT co DOT in" name="rahulsundaram@yahoo.co.in">
<date>v1.6, 2002-12-27
<abstract>
This file describes the autofs automounter, how to configure it, and
points out some problems to avoid.
</abstract>

<!-- Table of contents -->
<toc>

<!-- Begin the document -->

<sect>Introduction
<sect1> Revision History
<p>
<itemize>
<item> Versions below 1.5 - Authored by Don.
<item> Version 1.5   - Added the copyright and other minor details.Rahul Sundaram took over maintainance.
<item> Version 1.5.1 - Added details to the question about VFAT.
<item> Version 1.5.2 - Revision history and other minor corrections.
<item> Version 1.6 - Added a few questions and answers.
</itemize>
</p>

<sect1> Automount - what and why?
<p>
Automounting is the process where mounting and unmounting of certain
filesystems is done automatically by a daemon. If the filesystem is unmounted,
and a user attempts to access it, it will be automatically (re)mounted. This
is especially useful in large networked environments and for crossmounting
filesystems between a few machines (especially ones which are not always
online). It may also be very useful for removable devices, or a few other
uses, such as easy switching between a forced-on ascii conversion mount of
a dos filesystem and a forced-off ascii conversion mount of the same dos fs.
If you are new to Linux and dont understand what mounting and deamons are,then refer to
some documentation regarding this.

<sect1>Types of automounting
<p>There are two types of automounters in linux; <em>AMD</em> and <em>autofs</em>. AMD is the
automount daemon, and supposedly works like the SunOS AMD. It is implemented in user space, meaning it's not part of the kernel. It's not necessary for the kernel to understand automounting if you NFS mount to the local host, through the AMD daemon, which routes all automount filesystem traffic through the NFS system. Autofs is a newer system assisted by the kernel, meaning that the kernel's filesystem code knows where the automount mount points are on an otherwise normal underlying fs, and the automount program takes it from there. Only autofs will be described in this mini-howto.

<sect>Administrative
<sect1>Copyright information
<p>
This mini-HOWTO is Copyright  Rahul Sundaram Sundaram.All rights reserved.This document is licensed under
the <url url="http://tldp.org/copyright.html" name="Linux Documentation Project license">.I welcome any kind of commercial distrubution but I would like to receive information regarding this.I would 
also help anyone willing to translate this document.If you require any exceptions to the licensing terms
please contact me <url url="mailto:Rahulsundaram AT yahoo DOT co DOT in" name="Rahul Sundaram">. The latest version  of this document is always available at the Linux Documentation
website at <url url="http://tldp.org/HOWTO/mini/Automount.html">.

<sect1>Disclaimer
<p>
Although I have tried to do my best to bring out this howto in a good form,I am 
not responsible for any damage due to the actions taken based upon the
information contained in this document. It is impossible to test the
things under all the configurations, so probably some of the hints given
in this document may be incorrect and may not work on your system. In case you
find anything wrong, let me know it first.I will rewrite it as soon as possible.

This document is provided ``as is''. I put great effort into writing
it as accurately as I could, but you use the information contained in
it at your own risk. In no event shall I be liable for any damages
resulting from the use of this work.

<sect>Installation
<p>
Autofs is implemented in kernel-space, so your kernel must have support compiled in. All versions of the kernel starting from 2.2.xx supports autofs.
<p>The automount program and its configuration files are also necessary; using the rpms. The RedHat distribution has this package available as part of the installation.

<sect>Configuration
<p>Installing the RPM packages will get you to this point easily enough, but here's the part you might not be sure about if you haven't done this before.

<p>There are two files in /etc, one called <tt>auto.master</tt> and one called <tt>auto.misc</tt>.
A sample auto.master looks like this:
<verb>
/auto   /etc/auto.misc  --timeout=60
</verb>
<p>The first entry is not the mount point. It's where the set of mount points
(found in the second entry) are going to be. The third option says that the
mounted filesystems can try to unmount themselves 60 seconds after use. You will have to
stop using the disk before unmounting it.
<p>
Auto.misc is a "map file". The map file can have any name; this one is named auto.misc because it originally controlled /misc. Multiple map files can be defined in auto.master.
My auto.misc looks like this:
<verb>
kernel          -ro,soft,intr           ftp.kernel.org:/pub/linux
cd              -fstype=iso9660,ro      :/dev/cdrom
zip             -fstype=auto            :/dev/hdd4
floppy          -fstype=vfat            :/dev/fd0
</verb>
<p>
The first column (the "key") is the mount point. In this case it would be
/auto/floppy or whatever. The middle set are the options; read the mount
manpage for details on this. And the last column specifies where the fs
comes from. The "kernel" entry is supposed to be an NFS mount. The : on all
the other lines means its a local device.


<sect>The long wait for unmounting
<p>
Some of you may be eyeing that 60 second timeout and thinking, <em>that's a long
time to wait to eject a floppy.. Maybe I'll just sync the disks and pop
it out mounted and nobody will notice.</em> Let me suggest <tt>saner alternatives</tt>.
First of all, you can change the timeout. But that could be a little
inefficient; telling the system to unmount stuff after only 15 seconds or
whatever. Depending on your setup, you may be able to simply run the umount
command as a normal user.  But there is actually a way to ask the automount program to umount. 
If you send (with the program kill) the signal <tt>SIGUSR1</tt> to the automount process,
it will unmount everything it can. But before people start making unmount
buttons on their window managers, there's a little problem.
<p>
The automount process is run by root, and it will only accept signals from
root. Half of the reason you're probably doing automounting is so you can 
mount and unmount without being root. It would be easy to make a suid-root
C program which does the dirty deed. However, by using sudo it is possible
to allow users to send the proper kill signal. The only problem is that
sudo will not let you use to process subcommands, which you would have to
do to find the current PID. You should have a program called killall, which
will let you do this: 

<verb>
ALL     ALL=NOPASSWD:/usr/bin/killall -USR1 automount
</verb>
Otherwise, you would have to allow your users to send -SIGUSR1 to all processes.
That has various effects on programs; it will recycle some window managers,
but kills xemacs. So here's hoping there's no buffer overruns in killall...

<sect>Questions
<p>

<sect1>I don't see /auto/floppy, or whatever mountpoint I'm looking for.

<p>
If automount is setup properly, whatever mount point you're looking for will be there if you try and use it, even though you don't see it when not in use. If you're browsing the directory with a
graphical tool, you may need to type in the name manually; most programs will try what you give it, and the drive will be mounted before it notices. Unfortunately not
being able to choose from the available invisible mount points is probably the
major drawback of autofs. If it really bugs you, edit the configuration files.
(Hint, the ones that end in .c for "configuration")

One workaround several people have tried is to create symbolic links to where automount will create something once it's mounted. This will likely prevent the program from complaining a directory doesn't exist (if the mount works, that is) but careless directory listings will cause filesystems to be mounted. 

<sect1>How do I see what's mounted?
<p>
The <tt>df</tt> command. <tt>mount</tt> with no options will do the same, plus show the options its mounted with.



<sect1>I put in a win95 disk ("vfat") and it was autodetected as only a regular FAT disk.
<p>
This is not a problem with automount.The "auto" fs type does not attempt a vfat mount before it successfully mounts an MS-DOS filesystem. VFAT is an extension of the basic FAT filesystem inorder to provide Windows 95 and Windows NT with long filenames. 
<p>
According to one of the authors of mount, since mount is only a wrapper around a system call which must specify the filesystem type, it's still the responsibility of the user to come up with the fs type. Having mount take a list of filesystems to try in order, rather than the current "heuristic" is under consideration. Some users have simply not compiled msdos into the kernel; this prevents it from being tested prior to vfat. This will work for most people; a few actually need msdos fs and there is actually a work around.
You have to copy the /proc/filesystems as /etc/filesystems and edit it to change the order such that vfat appears before msdos.(Thanks Mark)

Ariel(aslinux At dsgml.com) writes 

"
o make mount try vfat before fat, just create or edit the file
/etc/filesystems

List, in order of priority, what filesystems you want the 'auto' fs
type
to try.

Create the file with cp /proc/filesystems /etc/filesystems.

Edit the list to change the order. Put fs types that are detected with
great confidence such as ext2 (which means they are checked very
quickly),
and those that are more common for you first. Just put vfat before 
msdos
and you're all set. Make sure to put both, in case you're mounting
something that has no vfat.

Mine looks like:

ext2
vfat
msdos
iso9660

****

I use a timeout of 1 second for removable devices. Create separate
maps, separated by the timeout you need.

You're thinking 1 second? That wastes a lot of resources - but it
doesn't.
Remember that the system only unmounts when it's no longer in use.

So a 1 second unmount means, as soon as no one is using the device,
it's
unmounted.

Also, be very sure to put 'sync' as an option for the floppy!

i.e.

floppy      -fstype=auto,sync,user,umask=002,gid=floppy     :/dev/fd0"

That should make clear the answer.

<sect1>My filesystem <tt>/auto/grumblesmurf</tt> is mounted and <tt>kill -SIGUSR1</tt> won't unmount it.
<p>
It's being used by something. Root probably can't manually unmount it
either. If you're the one who caused it to be mounted (i.e. it can't be someone
else using it) look around for a shell that might be in that directory. If
there are none, look for something else (particularly something that might
have gone though that directory like a directory browser) that might have left
an invisible foot in the door so to speak. If you've given up looking, try
using the fuser program.

<sect1>What happens if I make / the directory for the automounter
<p>
I dont recommend it.If you want /grumblesmurf, then I suggest a symbolic link. It would be much safer.

<sect1>Can I have two map files on the same directory?
<p>
Not as far as I know. Try using one map file, with specific options for individual entries.

<sect1>I'm using SuSE 6.0 and needed <tt>---timeout</tt> instead of <tt>--timeout</tt>
<p>
Another solution to "timeout not working" problems would be to add a <tt>-t time</tt> option to the autofs script.

<sect1>How do I set the permissions and ownership for the filesystem (ie)FAT.
<p>
Check the man page for mount for some of the options, such as setting the uid=value or umask=value options. One option that appears to be missing for FAT filesystems is mode=value. Sorry. Check in with the people who do mounting.

<sect1>How to browse the content of an autofs directory, when sub-dirs are not currently mounted ?

Philippe Froidevaux <philippe.froidevaux AT unifr.ch> writes 
<p>

		" The author of autofs say "no way"

a possible hack is (from the newsgroup) :

"don't mount to  /home/blauser  but to  /mount/.auto/blauser
then add a link   /home/blauser -> /mount/.auto/blauser

now you can browse into /home and see the users-home, it then gets
mounted when you enter it.

problem with this: it isn't so clean and needs work for each user.

another solution is to use 'amd' in place of 'autofs', but amd is less
performant".



<sect1>Who do I thank for autofs?
<p>
This is only a documentation provided for you to grab everyone's attention to what a great
job had been done with autofs, and howeasy it is to use.Compared to the original perpetrators
of AMD,the autofs is very well documented and the implementors have my sincere thanks.
Everything has been copyrighted by the Transmeta company so it's not possible to provide
a credits list, but Peter Anvin is probably responsible for quite a bit of it. Peter also held
a session on autofs at linuxworldexpo on March 3, 1999.

<sect1>Where can I learn more about automounting?
<p>
There's a autofs tutorial at <url url="http://www.linuxhq.com/lg/issue24/nielsen.html">.
See also am-utils at <url url="http://www.cs.columbia.edu/~ezk/am-utils">

<sect1>where to contact the developpers" ?.Is there a mailing-list for autofs ?
<p>
I could not locate any information regarding this.Please let me know if you come across anything.

<sect>Acknowledgements,feedback and dedication
<p>
I would like to thank <url url="mailto:don@sabotage.org" name="Don"> (email id seems to be invalid now) for his original work on this mini-Howto.I thank Ariel for his
answer regarding the question on "win95 vfat" issue.I would thank all my friends for their support and everyone who were patient enough with me while I completed this work.
Please mail me to <url url="mailto:Rahulsundaram AT yahoo DOT co DOT in" name="Rahul Sundaram"> in case of any suggestions,improvements or if you have any bright ideas.
Please mail me if you have any good tutorials or stuff that I can add to this document.Thanks in advance.
I dedicate this document to my late parents Mr.V.Sundaram and Mrs.S.Soundara Sundaram.
</article>


2