LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 12-22-2006, 07:10 PM   #1
somae
Member
 
Registered: Nov 2006
Posts: 56

Rep: Reputation: 15
how to install and setup autofs


I want to be able to use cd's and floppies without having to mount and unmount and read that autofs is able to do that. (but not with floppies?) I have slackware 10.2.0. Not sure if autofs is installed.

Would appreciate help in installing and setup. I read the info on it at http://freespace.sourceforge.net/gui...to/autofs.html

Thanks.
 
Old 12-23-2006, 03:34 AM   #2
dive
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Slackware
Posts: 3,467

Rep: Reputation: Disabled
There is an autofs slackware packages in the official package browser at slackware.com. You also need kernel support for it but I think it should be supported by 10.2.

Download the package and install with installpkg then you should have an /etc/auto.master to play with. man autofs will be a good read.
 
Old 12-23-2006, 05:43 AM   #3
r1w1s1
Member
 
Registered: Mar 2004
Location: São Paulo - Brazil
Distribution: Slackware
Posts: 61
Blog Entries: 1

Rep: Reputation: 37
Please see http://www.wasare.net/home/node/9
 
Old 12-24-2006, 04:10 AM   #4
somae
Member
 
Registered: Nov 2006
Posts: 56

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by ricardson
When I went to install the new autofs package using Kpackage, I noticed that I already had it installed. I then, unfortunately, thought that maybe it hadn't installed correctly, so I uninstalled it and then tried to install the newly downloaded package. For some reason, it wouldn't install properly. I tried rebooting and then found that Xwindows and KDE wouldn't start. I tried reinstalling the kernel using the setup utility on the slackware cd. Then, I reinstalled KDE and Xwindows. I had to reset the permissions and finally got everything functioning again.

I assume I needed the autofs-config package, and that was why there was no auto.master file originally?

Is autofs-config different than autoconfig? (autoconf-2.59-noarch-1)

Thanks.

Last edited by somae; 12-24-2006 at 05:08 AM.
 
Old 12-24-2006, 11:15 AM   #5
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
autofs-config is not autoconfig. You'll find auto.master in the documents for the autofs package. Since it must be configured the conf files are not installed by default -auto.master gets run even if set to non-executable.

Here's what I found that works:

Name this rc.autofs and place in etc/rc.d

#! /bin/bash
#
# $Id: rc.autofs.in,v 1.4 2000/01/22 22:17:34 hpa Exp $
#
# rc file for automount using a Sun-style "master map".
# We first look for a local /etc/auto.master, then a YP
# map with that name
#
# On most distributions, this file should be called:
# /etc/rc.d/init.d/autofs or /etc/init.d/autofs
#

# For Redhat-ish systems
#
# chkconfig: 345 15 85
# description: Automounts filesystems on demand

# This is used in the Debian distribution to determine the proper
# location for the S- and K-links to this init file.
# The following value is extracted by debstd to figure out how to
# generate the postinst script. Edit the field to change the way the
# script is registered through update-rc.d (see the manpage for
# update-rc.d!)
#
FLAGS="defaults 21"

#
# Location of the automount daemon and the init directory
#
DAEMON=/usr/sbin/automount
initdir=/etc/rc.d/init.d

#
# Determine which kind of configuration we're using
#
system=unknown
if [ -f /etc/debian_version ]; then
system=debian
elif [ -f /etc/redhat-release ]; then
system=redhat
elif [ -f /etc/slackware-version ]; then
system=slackware
initdir=/etc/rc.d
else
echo "$0: Unknown system, please port and contact autofs@linux.kernel.org" 1>&2
exit 1
fi

if [ $system = redhat ]; then
. $initdir/functions
fi

test -e $DAEMON || exit 0
thisscript="$0"
if [ ! -f "$thisscript" ]; then
echo "$0: Cannot find myself" 1>&2
exit 1
fi

PATH=/sbin:/usr/sbin:/bin:/usr/bin
export PATH

#
# We can add local options here
# e.g. localoptions='rsize=8192,wsize=8192'
#
localoptions=''

#
# This function will build a list of automount commands to execute in
# order to activate all the mount points. It is used to figure out
# the difference of automount points in case of a reload
#
function getmounts()
{
#
# Check for local maps to be loaded
#
if [ -f /etc/auto.master ]
then
cat /etc/auto.master | sed -e '/^#/d' -e '/^$/d'| (
while read dir map options
do
if [ ! -z "$dir" -a ! -z "$map" \
-a x`echo "$map" | cut -c1` != 'x-' ]
then
map=`echo "/etc/$map" | sed -e 's:^/etc//:/:'`
options=`echo "$options" | sed -e 's/\(^\|[ \t]\)-/\1/g'`
if [ -x $map ]; then
echo "$DAEMON $dir program $map $options $localoptions"
elif [ -f $map ]; then
echo "$DAEMON $dir file $map $options $localoptions"
else
echo "$DAEMON $dir `basename $map` $options $localoptions"
fi
fi
done
)
fi

#
# Check for YellowPage maps to be loaded
#
if [ -e /usr/bin/ypcat ] && [ `ypcat -k auto.master 2>/dev/null | wc -l` -gt 0 ]
then
ypcat -k auto.master | (
while read dir map options
do
if [ ! -z "$dir" -a ! -z "$map" \
-a x`echo "$map" | cut -c1` != 'x-' ]
then
map=`echo "$map" | sed -e 's/^auto_/auto./'`
if echo $options | grep -- '-t' >/dev/null 2>&1 ; then
mountoptions="--timeout $(echo $options | \
sed 's/^.*-t\(imeout\)*[ \t]*\([0-9][0-9]*\).*$/\2/g')"
fi
options=`echo "$options" | sed -e '
s/--*t\(imeout\)*[ \t]*[0-9][0-9]*//g
s/\(^\|[ \t]\)-/\1/g'`
echo "$DAEMON $dir yp $map $options $localoptions"
fi
done
)
fi
}

#
# Status lister.
#
function status()
{
echo "Configured Mount Points:"
echo "------------------------"
getmounts
echo ""
echo "Active Mount Points:"
echo "--------------------"
ps ax|grep "[0-9]:[0-9][0-9] automount " | (
while read pid tt stat time command; do echo $command; done
)
}


#
# Redhat start/stop function.
#
function redhat()
{

#
# See how we were called.
#
case "$1" in
start)
# Check if the automounter is already running?
if [ ! -f /var/lock/subsys/autofs ]; then
echo 'Starting automounter: '
getmounts | sh
touch /var/lock/subsys/autofs
fi
;;
stop)
kill -TERM $(/sbin/pidof /usr/sbin/automount)
rm -f /var/lock/subsys/autofs
;;
reload|restart)
if [ ! -f /var/lock/subsys/autofs ]; then
echo "Automounter not running"
exit 1
fi
echo "Checking for changes to /etc/auto.master ...."
TMP1=`mktemp /tmp/autofs.XXXXXX` || { echo "could not make temp file" >& 2; exit 1; }
TMP2=`mktemp /tmp/autofs.XXXXXX` || { echo "could not make temp file" >& 2; exit 1; }
getmounts >$TMP1
ps ax|grep "[0-9]:[0-9][0-9] automount " | (
while read pid tt stat time command; do
echo "$command" >>$TMP2
if ! grep -q "^$command" $TMP2; then
kill -USR2 $pid
echo "Stop $command"
fi
done
)
cat $TMP1 | ( while read x; do
if ! grep -q "^$x" $TMP2; then
$x
echo "Start $x"
fi
done )
rm -f $TMP1 $TMP2
;;
status)
status
;;
*)
echo "Usage: $initdir/autofs {start|stop|restart|reload|status}"
exit 1
esac
}

#
# Debian start/stop functions.
#
function debian()
{
#
# See how we were called.
#
case "$1" in
start)
echo -n 'Starting automounter:'
getmounts | while read cmd mnt rest
do
echo -n " $mnt"
pidfile=/var/run/autofs`echo $mnt | sed 's/\//./'`.pid
start-stop-daemon --start --pidfile $pidfile --quiet \
--exec $DAEMON -- $mnt $rest
#
# Automount needs a '--pidfile' or '-p' option.
# For now we look for the pid ourself.
#
ps ax | grep "[0-9]:[0-9][0-9] $DAEMON $mnt" | (
read pid rest
echo $pid > $pidfile
echo "$mnt $rest" >> $pidfile
)
done
echo "."
;;
stop)
echo 'Stopping automounter.'
start-stop-daemon --stop --quiet --signal USR2 --exec $DAEMON
;;
reload|restart)
echo "Reloading automounter: checking for changes ... "
TMP=/var/run/autofs.tmp
getmounts >$TMP
for i in /var/run/autofs.*.pid
do
pid=`head -n 1 $i 2>/dev/null`
[ "$pid" = "" ] && continue
command=`tail +2 $i`
if ! grep -q "^$command" $TMP
then
echo "Stopping automounter: $command"
kill -USR2 $pid
fi
done
rm -f $TMP
$thisscript start
;;
status)
status
;;
*)
echo "Usage: $initdir/autofs {start|stop|restart|reload|status}" >&2
exit 1
;;
esac
}

function slackware()
{
#
# See how we were called.
#
case "$1" in
start)
echo -n 'Starting automounter:'
getmounts | while read cmd mnt rest
do
echo -n " $mnt"
pidfile=/var/run/autofs`echo $mnt | sed 's/\//./'`.pid
$DAEMON -- $mnt $rest
#
# Automount needs a '--pidfile' or '-p' option.
# For now we look for the pid ourself.
#
ps ax | grep "[0-9]:[0-9][0-9] $DAEMON $mnt" | (
read pid rest
echo $pid > $pidfile
echo "$mnt $rest" >> $pidfile
)
done
echo "."
;;
stop)
echo 'Stopping automounter.'
/bin/killall -USR2 automount
;;
reload|restart)
echo "Reloading automounter: checking for changes ... "
TMP=/var/run/autofs.tmp
getmounts >$TMP
for i in /var/run/autofs.*.pid
do
pid=`head -n 1 $i 2>/dev/null`
[ "$pid" = "" ] && continue
command=`tail +2 $i`
if ! grep -q "^$command" $TMP
then
echo "Stopping automounter: $command"
kill -USR2 $pid
fi
done
rm -f $TMP
$thisscript start
;;
status)
status
;;
*)
echo "Usage: $thisscript {start|stop|restart|reload|status}" >&2
exit 1
;;
esac
}



if [ $system = debian ]; then
debian "$@"
elif [ $system = redhat ]; then
redhat "$@"
elif [ $system = slackware ]; then
slackware "$@"
fi


Example 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).
/media /etc/auto.misc
# /mnt /etc/auto.cdrom


Example /etc/auto.misc:

# $Id: auto.misc,v 1.2 1997/10/06 21:52:04 hpa Exp $
# 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

#kernel -ro ftp.kernel.org:/pub/linux
#boot -fstype=ext2 :/dev/hda1
#removable -fstype=ext2 :/dev/hdd
cdrom -fstype=iso9660,ro :/dev/sr0
#floppy -fstype=auto :/dev/fd0

As I said, auto.master and auto.misc don't have to be executable and are placed in /etc.
rc.autofs goes in /etc/rc.d. You'll need to make it executable and add an entry for it in /etc/rc.d/rc.local something like this:

if [ -x /etc/rc.d/rc.autofs ] ; then
. /etc/rc.d/rc.autofs start
fi

This will mount your cdrom (/dev/sr0) under /media/cdrom

The rc.autofs is a patched version I found -you'll need yptools (from the 'n' series) installed for it to work. I've found a simpler one that doesn't need yptools to work and has no references to debian or redhat, but I've not had a chance to test it yet, so I won't provide it just yet. Pretty soon I'll add the autofs4 package to my site with some working examples.
 
Old 12-24-2006, 01:14 PM   #6
Alien Bob
Slackware Contributor
 
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 8,559

Rep: Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106
I am using this rc.autofs for some time now, it does not need yp:

http://www.slackware.com/~alien/rc_s...ipts/rc.autofs

Eric
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
autofs sl4ckw4re Slackware 1 09-18-2006 12:51 PM
autofs kemkem42 Linux - Software 1 09-22-2005 01:22 PM
Autofs tefal Linux - Software 4 07-20-2004 10:58 AM
Using Autofs guygriffiths Linux - Software 1 09-17-2003 10:31 AM
Autofs...help please yourcompadre Linux - Networking 0 06-03-2003 09:07 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 12:09 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration