Using autofs with USB Devices
I am working on the the following system.
OS: Stable (Sarge) Debian with 2.6 Kernel. CPU: i386 Devices: 1) several usb-storage class devices.
2) Palm m505 using ttyUSB* devices.
Subsystems: hotplug, scsi, autofs
I am trying to develop a procedure to associate a specific USB device using the manufacture and product-id with a mount point. Currently I have a script that does a switch within the hotplug system that determines which device has been plugged in the system. This part is working.
What is missing is how to determine which usb dev mount point (i.e. /dev/sd?) the device is being associated with within this same context.
The plan is within the context of the hotplug script is to make a soft link to this dev mount point that is associated with the device just being plugged into the computer. Once the hotplug script is complete then autofs can mount to the dev through this link when the user software needs a static mount point (i.e. /mnt/camera-1 or /mnt/memcardreader-2). This will allow a fixed mount point to the user so that the user software can find the correct device on demand once the device has been plugged into the system.
The issues at play here is when there are several usb-storage devices, (i.e. ipod, memory cards, and cameras) mounted in different order and in different usb ports the (/dev/sd?) assignment is somewhat random from a user standpoint. The goal is to resolve this problem and document the solution. Note also other devices such as iPODS may also be plugged into the USB ports during the same time period.
Let me know if anyone has any ideas or knows where this is documented.
Thanks.
Hal
__________________________________
Yahoo! Music Unlimited
Access over 1 million songs. Try it free.
http://music.yahoo.com/unlimited/
Quoted 3 lines · P.E.
What is missing is how to determine which usb dev
mount point (i.e./dev/sd?) the device is being
associated with within this same context.
sysfs will give you this information; look in/sys/bus/usb/drivers/usb-storage/, IIRC.
/* Steinar */
Signature · 1 line
Homepage: http://www.sesse.net/
Ian Kent
maintainerQuoted 9 lines · P.E.
The issues at play here is when there are several usb-storage devices, (i.e. ipod, memory cards, and cameras) mounted in different order and in different usb ports the (
/dev/sd?) assignment is somewhat random from a user standpoint. The goal is to resolve this problem and document the solution. Note also other devices such as iPODS may also be plugged into the USB ports during the same time period.
I thought that device name persistence was one of the issues that udev addressed?
Ian
Quoted 10 lines · Ian Kent
Quoted 5 lines · P.E.
The issues at play here is when there are several usb-storage devices, (i.e. ipod, memory cards, and cameras) mounted in different order and in different usb ports the (
/dev/sd?) assignment is somewhat random from a user standpoint.I thought that device name persistence was one of the issues that udev addressed?
Well, sort of, but... When I use hotplug USB devices (kernel 2.6.11, hotplug-0.50, udev-053), the primary device name is whatever the kernel feels like, e.g. /dev/sdb1. However, the rules in /etc/udev/rules.d have the possibility of making a symlink with a fixed name, and removing it when the device is unplugged. e.g. /dev/ipod -> /dev/sd(whatever). The hotplug machinery also mounts the device for you, and for me this happens reliably. In the SuSE distro the mount point is auto-created in the /media directory, with a name associated with the particular device which seems to change at every version upgrade, but which at one point included the device's product ID in hex. Thus you can make a symlink to the future mount point of the specific device.
Unplugging is another matter -- it's recommended to use "eject" to unmount the device, but I've found that hotplug can usually unmount a truly non-busy device by itself -- but sometimes it messes up.
Autofs doesn't seem like the best way to handle USB devices, mainly because it dismounts on a timeout if the mount point has been unused for a (configurable) time, usually set to 5 minutes.
James F. Carter Voice 310 825 2897 FAX 310 206 6673
UCLA-Mathnet; 6115 MSA; 405 Hilgard Ave.; Los Angeles, CA, USA 90095-1555
Email: [email protected] http://www.math.ucla.edu/~jimc (q.v. for PGP key)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
Quoted 10 lines · P.E.
I am trying to develop a procedure to associate a specific USB device using the manufacture and product-id with a mount point. Currently I have a script that does a switch within the hotplug system that determines which device has been plugged in the system. This part is working.
What is missing is how to determine which usb dev mount point (i.e.
/dev/sd?) the device is being associated with within this same context.
I do have a script that can be used to create such automount map entries. It does currently use the volume label in preference to device type, name or vendor, but that could be hacked easily.
The current "release" version is at
http://ccomb.free.fr/wiki/wakka.php?wiki=UsbMassStorageEnglish
http://ccomb.free.fr/usbstorage/hotplug-mount.pl
http://ccomb.free.fr/usbstorage/hotplug-mount.README
The release is mostly a 1:1 port of Christophe's Shell-Script to Perl. A much more recent, more featureful and highly streamlined version can be obtained from me => send email.
Ciao,
Thomas Jahns
- --"Computers are good at following instructions, but not at reading your mind."
D. E. Knuth, The TeXbook, Addison-Wesley 1984, 1986, 1996, p. 9 -----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
iD8DBQFDVr4DoKHaAfEZMbkRAj6XAJ47SY4ua71gdc58kvU5sKz/5kS1FQCfavIE ExkwOdaVjsNBK5oMd+13yd4=
=/koV
-----END PGP SIGNATURE-----