[wellylug] Mounting USB flash memory
jumbophut
jumbophut at gmail.com
Wed Oct 27 23:39:33 NZDT 2004
On Wed, 27 Oct 2004 21:50:28 +1300, Colin Klenner wrote:
[...snip...]
> please can someone remind me what command I need to use
> to:
> a) identify where the USB memory stick is located
> b) what commands to use to automount it whenever I plug it in
>
DISCLAIMER: You don't say what your system is. This all applies to my
machine (Debian Woody):
It defaults to /dev/sda1 (it's the only USB device). You can check
that by doing a 'mount /dev/sda1 /mnt' and cd'ing to the /mnt
directory, which hopefully has the content of the memory stick in it.
Alternatively, try looking in /proc/scsi for a usb-storage directory.
I have a /proc/scsi/usb-storage-0/1 file with the USB info in it, and
I presume (without really knowing) that the 0 refers to sda (rather
than sdb, sdc etc) and the 1 means sda1 (rather than sda2, sda3 etc).
It automounts using hotplug. I added the following script (named
usb-storage to correspond with the driver name) to /etc/hotplug/usb/:
# /etc/hotplug/usb/usb-storage
# Does additional configuration of
# usb-storage device, which is assumed
# to be a digital camera on /dev/sda1
# usb.agent (in parent directory) runs
# first.
# Create a remover file, which will unmount
# the camera directory (requires entry in fstab)
cat <<EOF > $REMOVER
umount /camera
EOF
# Have to make it executable
chmod a-wx $REMOVER
chmod u+x $REMOVER
# Actually mount the camera (requires fstab entry)
mount /camera
# ENDS
In /etc/fstab, I have:
/dev/sda1 /camera auto ro,user,noauto,gid=camera,umask=002 0
If you have many usb devices which use a scsi device, and they aren't
always plugged in in the same order, your hotplug script will
obviously need to be more complicated, and take into account device
IDs etc (using $PRODUCT etc might make this work -- see the usb.agent
file).
--
Tony (echo 'spend!,pocket awide' | sed 'y/acdeikospntw!, /l at omcgtjuba.phi/')
More information about the wellylug
mailing list