Hi again. Just a wrap up to this thread.
>From what I can see, the only way to do this is to grep through dmesg. The following script returns the disk attached to a physical usb port. Ports seem to be named like so: /dev/usb4 "addr 4". On my box, this is the 3rd physical port on a 4-port external USB hub. ------------- #!/bin/sh if [ $# -lt 2 ]; then echo "Usage: $0 usbdev \"usb addr\" (eg: $0 /dev/usb4 \"addr 4\")" echo " Use dmesg when plugging the device to work out which device" echo " and addr a physical USB port belongs to." exit 1 fi DEV=$1 ADDR=$2 UMASS=`usbdevs -f $DEV -d | grep -A 1 "$ADDR" | tail -1 | grep umass` if [ -z $UMASS ]; then echo Unable to find a mass storage device on $DEV \"$ADDR\" exit 1 fi SCSIBUS=`/sbin/dmesg | grep scsibus | grep $UMASS | tail -1 | awk '{print $1}'` if [ -z $SCSIBUS ]; then echo Unable to find a scsibus id for $UMASS exit 2 fi USBDISK=`/sbin/dmesg | grep $SCSIBUS | tail -1 | awk '{print $1}'` if [ -z $USBDISK ]; then echo Unable to find a disk attached to $UMASS $SCSIBUS exit 3 fi if [ `/sbin/dmesg | grep $SCSIBUS | tail -1 | grep detached | wc -l` -gt 0 ]; then echo Disk $USBDISK has been detached exit 4 fi echo $USBDISK is attached to $SCSIBUS on $UMASS ----------------- Disk naming seems to be consistent after you first plug the device in. So: The first disk plugged into a port (say "addr 2") gets sd1 (if your SATA disk is sd0) The second disk plugged into another port (say "addr 3") gets sd2, etc If you unplug the first and the second and then plug the second in again first (to the same port of course "addr 3" :-) it still seems to get sd2. But I doubt you can rely on this. Also at boot time, it's unclear which disk device will be allocated to which physical port. I'm not happy with the fact that the script uses dmesg output. dmesg uses a ring buffer and that can fill very quickly (say if you unplug a usb disk while something is writing to it) which will break the above script totally. However, currently I don't have the time (or probably the expertise) to go through the source to work out a better way to do it. As usual, YMMV.. ciao dave --- Dave Edwards