Re: Auto mounting usb device on linux server

2006-05-09 Thread Jim Kuzdrall
On Tuesday 09 May 2006 09:52 pm, Cole Tuininga wrote:
> device.  Extra points if I can also kick off a script once the drive
> is mounted.

This is what I do to find the auto-mounted usb drive.  From your 
log, it appears that all the same information is there.  You can have 
the whole backup script if you are interested.

Jim Kuzdrall

#  8. Find flash, sd?1, using /proc information- 
set -- $( ls /proc/scsi/usb-storage)
cnt=0
while [ "$1" != "" ] ; do
  cat /proc/scsi/usb-storage/$1 | grep $SER_NR &> /dev/null
  # zero means 'found'
  if [ $? -eq 0 ] ; then
FLASH_LET=${T[cnt]}
FLASH_DEV=/dev/sd${FLASH_LET}1
echo "Flash found at ${FLASH_DEV}" >> $LOG_FN
break
  fi
  let "cnt = cnt + 1"
  shift
done

if [ "$1" = "" ] ; then
  echo "Finished with error; Flash disk not found" | tee -a $LOG_FN
  exit 5
fi

#  9. Make flash storage mount directory, if needed - 
# USB usually has the device mounted somewhere; if so, find out where
TMP=$(mount | grep $FLASH_DEV )
if [ "$TMP" = "" ] ; then
  if [ ! -d $FLASH_MNT ] ; then
  mkdir --parents $FLASH_MNT
  fi
  mount $FLASH_DEV $FLASH_MNT
else
  TMP=${TMP#*on\ }
  FLASH_MNT=${TMP%\ type*}
  FLASH_DIR=$FLASH_MNT/"aaa_bkup"
fi

if [ ! -d $FLASH_DIR ] ; then
mkdir --parents $FLASH_DIR
fi
___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


Re: Auto mounting usb device on linux server

2006-05-09 Thread Bruce Dawson
I believe you want to look at hald/udev. There are scripts in there that
the kernel calls when it detects a new USB device.

Also, all USB devices have a UUID, that I *think* appears in lsusb
output as 'iSerial'. Not sure here, maybe someone with more knowledge
can comment here.

--Bruce

Cole Tuininga wrote:
> Hey all - I'm hoping somebody might be able to point out a suggestion or
> solution for the following.
> 
> What I have is a Debian (sarge) server, and a couple of usb storage
> devices.  What I want to do is to find a way that when I plug in one of
> the storage devices, that the server will automagically mount the
> device.  Extra points if I can also kick off a script once the drive is
> mounted.
> 
> I tried the usbmount package, but it doesn't seem to work at all.  All
> of the /media/usb* directories have been created, but nothing gets
> mounted when I plug in the device.
> 
> I should also mention that I don't know for sure which usb slot the
> storage device will be plugged into, nor can I guarantee that it will be
> the only usb device plugged in.
> 
> Currently, when I plug in my 256MB pen drive, I see the following in the
> logs:
> 
> ==> daemon.log <==
> May  9 21:50:42 localhost udev[3507]: creating device node '/dev/sdb'
> 
> ==> messages <==
> May  9 21:50:42 localhost kernel: usb 1-1: new full speed USB device
> using address 4
> May  9 21:50:42 localhost kernel: scsi2 : SCSI emulation for USB Mass
> Storage devices
> May  9 21:50:42 localhost kernel:   Vendor:   Model: USB DISK
> 12X  Rev: PMAP
> May  9 21:50:42 localhost kernel:   Type:   Direct-Access
> ANSI SCSI revision: 02
> May  9 21:50:42 localhost kernel: SCSI device sdb: 487424 512-byte hdwr
> sectors (250 MB)
> May  9 21:50:42 localhost kernel: sdb: assuming Write Enabled
> May  9 21:50:42 localhost kernel:  /dev/scsi/host2/bus0/target0/lun0: p1
> May  9 21:50:42 localhost kernel: Attached scsi removable disk sdb at
> scsi2, channel 0, id 0, lun 0
> 
> ==> syslog <==
> May  9 21:50:42 localhost kernel: usb 1-1: new full speed USB device
> using address 4
> May  9 21:50:42 localhost kernel: scsi2 : SCSI emulation for USB Mass
> Storage devices
> May  9 21:50:42 localhost kernel:   Vendor:   Model: USB DISK
> 12X  Rev: PMAP
> May  9 21:50:42 localhost kernel:   Type:   Direct-Access
> ANSI SCSI revision: 02
> May  9 21:50:42 localhost kernel: SCSI device sdb: 487424 512-byte hdwr
> sectors (250 MB)
> May  9 21:50:42 localhost kernel: sdb: assuming Write Enabled
> May  9 21:50:42 localhost kernel: sdb: assuming drive cache: write
> through
> May  9 21:50:42 localhost kernel:  /dev/scsi/host2/bus0/target0/lun0: p1
> May  9 21:50:42 localhost kernel: Attached scsi removable disk sdb at
> scsi2, channel 0, id 0, lun 0
> May  9 21:50:42 localhost kernel: USB Mass Storage device found at 4
> May  9 21:50:42 localhost udev[3507]: creating device node '/dev/sdb'
> 
> ==> messages <==
> May  9 21:50:43 localhost scsi.agent[3491]:  sd_mod: loaded
> sucessfully (for disk)
> May  9 21:50:43 localhost usb.agent[3466]:  usb-storage: already
> loaded
> 
> ==> syslog <==
> May  9 21:50:43 localhost scsi.agent[3491]:  sd_mod: loaded
> sucessfully (for disk)
> May  9 21:50:43 localhost usb.agent[3466]:  usb-storage: already
> loaded
> 
> ==> daemon.log <==
> May  9 21:50:44 localhost udev[3554]: creating device node '/dev/sdb1'
> 
> ==> syslog <==
> May  9 21:50:44 localhost udev[3554]: creating device node '/dev/sdb1'
> 
> 
> Anybody have any suggestions?
> 

___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


Auto mounting usb device on linux server

2006-05-09 Thread Cole Tuininga

Hey all - I'm hoping somebody might be able to point out a suggestion or
solution for the following.

What I have is a Debian (sarge) server, and a couple of usb storage
devices.  What I want to do is to find a way that when I plug in one of
the storage devices, that the server will automagically mount the
device.  Extra points if I can also kick off a script once the drive is
mounted.

I tried the usbmount package, but it doesn't seem to work at all.  All
of the /media/usb* directories have been created, but nothing gets
mounted when I plug in the device.

I should also mention that I don't know for sure which usb slot the
storage device will be plugged into, nor can I guarantee that it will be
the only usb device plugged in.

Currently, when I plug in my 256MB pen drive, I see the following in the
logs:

==> daemon.log <==
May  9 21:50:42 localhost udev[3507]: creating device node '/dev/sdb'

==> messages <==
May  9 21:50:42 localhost kernel: usb 1-1: new full speed USB device
using address 4
May  9 21:50:42 localhost kernel: scsi2 : SCSI emulation for USB Mass
Storage devices
May  9 21:50:42 localhost kernel:   Vendor:   Model: USB DISK
12X  Rev: PMAP
May  9 21:50:42 localhost kernel:   Type:   Direct-Access
ANSI SCSI revision: 02
May  9 21:50:42 localhost kernel: SCSI device sdb: 487424 512-byte hdwr
sectors (250 MB)
May  9 21:50:42 localhost kernel: sdb: assuming Write Enabled
May  9 21:50:42 localhost kernel:  /dev/scsi/host2/bus0/target0/lun0: p1
May  9 21:50:42 localhost kernel: Attached scsi removable disk sdb at
scsi2, channel 0, id 0, lun 0

==> syslog <==
May  9 21:50:42 localhost kernel: usb 1-1: new full speed USB device
using address 4
May  9 21:50:42 localhost kernel: scsi2 : SCSI emulation for USB Mass
Storage devices
May  9 21:50:42 localhost kernel:   Vendor:   Model: USB DISK
12X  Rev: PMAP
May  9 21:50:42 localhost kernel:   Type:   Direct-Access
ANSI SCSI revision: 02
May  9 21:50:42 localhost kernel: SCSI device sdb: 487424 512-byte hdwr
sectors (250 MB)
May  9 21:50:42 localhost kernel: sdb: assuming Write Enabled
May  9 21:50:42 localhost kernel: sdb: assuming drive cache: write
through
May  9 21:50:42 localhost kernel:  /dev/scsi/host2/bus0/target0/lun0: p1
May  9 21:50:42 localhost kernel: Attached scsi removable disk sdb at
scsi2, channel 0, id 0, lun 0
May  9 21:50:42 localhost kernel: USB Mass Storage device found at 4
May  9 21:50:42 localhost udev[3507]: creating device node '/dev/sdb'

==> messages <==
May  9 21:50:43 localhost scsi.agent[3491]:  sd_mod: loaded
sucessfully (for disk)
May  9 21:50:43 localhost usb.agent[3466]:  usb-storage: already
loaded

==> syslog <==
May  9 21:50:43 localhost scsi.agent[3491]:  sd_mod: loaded
sucessfully (for disk)
May  9 21:50:43 localhost usb.agent[3466]:  usb-storage: already
loaded

==> daemon.log <==
May  9 21:50:44 localhost udev[3554]: creating device node '/dev/sdb1'

==> syslog <==
May  9 21:50:44 localhost udev[3554]: creating device node '/dev/sdb1'


Anybody have any suggestions?

-- 
Cole Tuininga <[EMAIL PROTECTED]>
Code Energy (http://www.code-energy.com/)

___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss