[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: newbie .. how to start with autofs



On Thursday 08 November 2001 04:25, Mirek Dobsicek wrote:
> Hi,
>  I'd like to have my cdrom and floppy, automatically mounted and umounted.
> A friend told me "use autofs" . But this advice is not any help to me :-(
>
>         Mirek Dobsicek

I've been using autofs under MDK 7.2 and 8.1 for some time now (yeah, I know 
- but I haven't had time to face a new install and upgrade process to change 
to Debian, although I've been planning it for a while).

Anyway, autofs works extrememly well (for me). I use it to automatically 
mount my DVD, CDRW, floppy, a windows share over the network, etc.

Basically, there are two components: the autofs code in the kernel, and the 
automount daemon which is used to do the actual mounting on demand. You need 
to ensure that your kernel is compliled with autofs support in it. There are 
two versions, autofs (which is the version 3 form) and autofs4 (version 4). I 
use the latter, although I am unsure what the differences are. If you choose 
to build autofs4 as a module, you need the line 

	alias autofs autofs4 

in /etc/modules.conf so that modutils will know to look for autofs4.o (the 
autofs4 module) when the kernel needs autofs. If you are using autofs you 
obviously don't need that line.

You also will need a startup script to launch the automount daemon on 
startup;  presumably the .deb package that automount comes in for debian will 
include such a script.

The system is configured with several files. /etc/auto.master is used when 
the daemon is started / restarted and contains the "mount points" which 
autofs controls. Each mount point is the root of a directory tree, under 
which automounting can occur. For instance, here's my /etc/auto.master:

# $Id: auto.master,v 1.2 1997/10/06 21:52:03 hpa Exp $
# Sample auto.master file
# Format of this file:
# mountpoint map options
# For details of the format look at autofs(8).
#/misc	/etc/auto.misc	--timeout=60
#/net	/etc/auto.net	--timeout=60
/mount	/etc/auto.mount	--timeout=15

You can see that I have commented out the ones that came with the MDK 
install, and I have a mount point called /mount, under which all my 
automounting takes place. You can have as many such mount points are you 
want. This file specifies that the details of how to handle /mount is 
containined in the configuration file /etc/auto.mount, which looks like this:

# $Id: auto.master,v 1.2 1997/10/06 21:52:04 hpa Exp $
# Created 10-21-2001 NL
# This is an automounter map and it has the following format
# key [ -mount-options-separated-by-comma ] location
# Details may be found in the autofs(5) manpage
dvd	-fstype=iso9660,ro,nosuid,nodev,exec,user	:/dev/dvd
cdrw	-fstype=iso9660,ro,nosuid,nodev,noexec,user	:/dev/cdrw
floppy	-fstype=auto,nosuid,noauto,user,nodev,unhide	:/dev/fd0
windows	-fstype=vfat,user,exec,umask=0			:/dev/hda2
kirk	-fstype=smbfs,user,nosuid,noauto,noexec,rw,password=frobozz 
://kirk/ddrive

So, if I cd to /mount/dvd, autofs mounts /dev/dvd onto the mount point 
/mount/dvd, as an iso9660 filesystem. Similarly for cd to /mount/cdrw; cd'ing 
to /mount/floppy mounts /dev/fd0 and autodetects the file system on the 
floppy in the drive. /mount/windows is a windows partition on my computer in 
/dev/hda2, which /mount/kirk automounts the windows share //kirk/ddrive onto 
/mount/kirk as an smb filesystem. All of this works magically and 
transparently once configured.

Once you have autofs / automount installed, man autofs, man automount, man 
auto.master will tell you all about how to handle this stuff. You can 
automount NFS file shares, or even have scripts executed (so that if you set 
things up correctly, for instance, you can have autofs handle things so that 
if you cd to /mount/xxx where xxx is the name of any system on your LAN, the 
/home directory on that system is automatically mounted for you - and you can 
set this up to work as new systems are added/removed from the network without 
having to change your configuration files once the initial scripts are set 
up. It's very powerful and I have not had a single glitch (or at least, the 
only glitch I have is because of the way windows does (or does not) wake up 
properly from a suspend on my laptop).

Good luck.

Neal




Reply to: