Publicado: Lun Feb 19, 2007 11:46 amAsunto: [Espacio Linux] Udev en Slackware
Hola:
Se abre este post para comentar, exponer dudas o hacer observaciones sobre el documento publicado en el Taller Linux : "Udev en Slackware" bajo la autoria de Meleagro.
Publicado: Mar Mar 13, 2007 3:51 amAsunto: Re: [Espacio Linux] Udev en Slackware
ya que se habla de Udev, voy a poner algo que vi en http://esslackware.blogspot.com/
ese blog es uno de los que traen los mejores consejos practicos para slack aunque sea nuevo
Cita:
Modificamos /etc/udev/udev.conf
# udev.conf
# The main config file for udev
#
# This file can be used to override some of udev's default values
# for where it looks for files, and where it places device nodes.
# udev_root - where in the filesystem to place the device nodes
udev_root="/dev/"
# udev_db - The name and location of the udev database.
udev_db="/dev/.udev.tdb"
# udev_rules - The name and location of the udev rules dir
udev_rules="/etc/udev/rules.d"
# default_mode - set the default mode for all nodes that have no
# explicit match in the permissions file
default_mode="666"
# default_owner - set the default owner for all nodes that have no
# explicit match in the permissions file
default_owner="root"
# default_group - set the default group for all nodes that have no
# explicit match in the permissions file
default_group="root"
# udev_log - set to "yes" if you want logging, else "no"
udev_log="no"
Creamos /lib/udev/usbmount.sh
#!/bin/sh
# This script mounts USB and other mass storage devices when they are plugged in
# and unmounts them when they are removed.
# It also creates mountpoints as needed, and removes them afterward
# Copyright (C) 2006 Jean-Philippe Guillemin and Mark Colclough
#
# This file is free software; the copyright holder gives unlimited
# permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
# This file is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
#
# Usage : [hotmount.sh|usbmount.sh|firemount.sh|pcmciamount.sh] (add|remove) DEVICE [MOUNTPOINT]
# if the variable $NICEMOUNTPOINT is defined it will be used as the first tried mountpoint
# version 1.0 11/06/2006
VERBOSE="no"
# Log a string via the syslog facility.
log()
{
[ "$VERBOSE" = "yes" ] && logger -p user.$1 -t "usbmount[$$]" -- "$2"
}
# Test if the first parameter is in the list given by the second
# parameter.
in_list()
{
for v in $2; do
test "$1" != "$v" || return 0
done
return 1
}
# Test if /lib/udev/vol_id is executable.
test -x /lib/udev/vol_id || { log err "cannnot execute /lib/udev/vol_id"; exit 1; }
# The mount point COULD be given as 3rd argument
[ "$3" ] && MOUNTPOINTS="$3 $MOUNTPOINTS"
# if the variable $NICEMOUNTPOINT is defined it will be used as the first tried mountpoint
[ "$NICEMOUNTPOINT" ] && MOUNTPOINTS="$NICEMOUNTPOINT $MOUNTPOINTS"
umask 000
if [ "$1" = add ] ; then
log info "devname == $DEVNAME !!"
# Try to read from the device. Some devices need a few seconds
# initialization time before they can be accessed. Give up after
# 20 seconds (a Markish infinite... .
log info "testing whether $DEVNAME is readable"
read_success=no
for t in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19; do
dd if="$DEVNAME" of=/dev/null bs=512 count=1
if [ "$?" = "0" ] ; then
read_success=yes
break
fi
log info "attempt $t to read from $DEVNAME failed"
sleep 1
done
if [ "$read_success" != "yes" ]; then
log err "cannot read from $DEVNAME"
exit 1
fi
# Test if the device contains a filesystem.
/lib/udev/vol_id "$DEVNAME" | egrep -q '^ID_FS_USAGE=(filesystem|disklabel)$'
if [ "$?" = "0" ] ; then
log info "$DEVNAME contains a filesystem or disklabel"
fstype="$(/lib/udev/vol_id -t $DEVNAME )"
log info "$DEVNAME contains filesystem type $fstype"
# We search for available mountpoint in the list
for mountpoint in $MOUNTPOINTS; do
# Get a lock for the mountpoint under consideration
for t in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19; do
(set -C; echo "$$" > /var/lock/${mountpoint##*/}) && break
log info "waiting for $mountpoint lockfile to be released"
sleep 1
done
if [ -d "$mountpoint" ]; then
log info "mountpoint $mountpoint exists"
if [ ! "$( mount | awk '{print $3}' | grep "$mountpoint" )" ]; then
log info "mountpoint $mountpoint is available for $DEVNAME"
break
else
log info "mountpoint $mountpoint is busy"
rm -f /var/lock/${mountpoint##*/}
continue
fi
else
log info "creating mountpoint $mountpoint for $DEVNAME"
mkdir -p -m0 $mountpoint
umount -l "$mountpoint"
log info "mountpoint $mountpoint is available for $DEVNAME"
break
fi
rm -f /var/lock/${mountpoint##*/}
done
if [ "$mountpoint" ] ; then
# Determine mount options.
options=""
if [ "$FSTABMOUNTOPTIONS" ]; then
options="$FSTABMOUNTOPTIONS"
else
[ "$MOUNTOPTIONS" ] && options="$MOUNTOPTIONS"
[ ! "$fstype" = "vfat" ] && options="${options},sync,dirsync"
[ "$fstype" = "vfat" ] && options="${options},uid=0,gid=100,umask=0"
fi
# Mount the filesystem.
for t in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19; do
[ "$( mount | awk '{print $1}' | grep "$DEVNAME" )" ] && break
log info "executing command: mount -t $fstype -o $options $DEVNAME $mountpoint"
eval "mount -t $fstype -o $options $DEVNAME $mountpoint"
/lib/udev/montaje.sh $DEVNAME $mountpoint
done
rm -f /var/lock/${mountpoint##*/}
else
# No suitable mount point found.
log warning "no mountpoint found for $DEVNAME"
exit 1
fi
else
log info "$DEVNAME does not contain a filesystem or disklabel"
fi
elif [ "$1" = remove ] ; then
/lib/udev/montaje.sh $DEVNAME $DEVNAME $1
# A block or partition device has been removed.
# Test if it is mounted.
while read device mountpoint fstype remainder; do
if [ "$DEVNAME" = "$device" ] ; then
# If the mountpoint and filesystem type are maintained by
# this script, unmount the filesystem.
if in_list "$mountpoint" "$MOUNTPOINTS" ; then
log info "unmounting $mountpoint"
umount -l "$mountpoint"
rmdir $mountpoint && break
log info "cannot remove $mountpoint, maybe not empty"
fi
break
fi
done < /proc/mounts fi exit 0
Por último creamos /lib/udev/montaje.sh
#!/bin/bash
# 06/02/07 SiTuH~
Home_Des="introduce la ruta de tu escritorio"
nombre=`echo $2 | cut -c 6,7,8,9`
y con esto lo que conseguimos es que al pinchar nuestra memoria usb aparezca en nuestro escritorio un link a ella, con opcion de desmontarla con un par de clicks, al quitar nuestro usb el link desaparece.
No olvidar dar permiso de ejecucion a los scripts
chmod +x script
No puedes publicar nuevos temas en este foro No puedes responder a temas en este foro No puedes editar tus mensajes en este foro No puedes borrar tus mensajes en este foro No puedes votar en encuestas en este foro