The method below is deprecated. Modern distros use udev.

By default udev will write unique symlinks for each USB Mass Storage device to

 /dev/disk/by-id/


I'm sure there are less messy solutions but this is how I did it. Assuming you have the same problem I did some time ago....

Problem:

(and thus show up at the same point on the SCSI chain).

Solution:

For each USB hotplug device you own:

POINT>

is plugged in.

 --- SAMPLE DEVICE HOTPLUG SCRIPT --

{{{

#!/bin/bash
 1. Take a bit out of the second relevant line in /proc/scsi/scsi which will
 1. uniquely identify the device.  Example: in
  1. Host: scsi2 Channel: 00 Id: 00 Lun: 01
  2. Vendor: USB2.0 Model: CompactFlashCard Rev:

  3. Type: Direct-Access ANSI SCSI revision: 02
  4. you might use "CompactFlashCard".

DRIVETYPE="ST316002" DEVICENAME="usbdisk" MOUNTPOINT="/mnt/usbdisk"

  1. it takes a second or so for the drive to appear in /proc/scsi/scsi

sleep 1

  1. we want to find out where the drive is on the scsi bus

LOCATION=/bin/grep -B 1 $DRIVETYPE /proc/scsi/scsi | /bin/head -n 1 HOST=echo $LOCATION | cut -d " " -f 2 | sed -e 's/scsi/host/' BUS=echo $LOCATION | cut -d " " -f 4 | sed -e 's/0/bus/' TARGET=echo $LOCATION | cut -d " " -f 6 | sed -e 's/0/target/' LUN=echo $LOCATION | cut -d " " -f 8 | sed -e 's/0/lun/' echo -n "#!/bin/bash umount -f $MOUNTPOINT rm -f $DEVICENAME " > $REMOVER chmod 755 $REMOVER rm -f $DEVICENAME ln -s /dev/scsi/$HOST/$BUS/$TARGET/$LUN/part1 $DEVICENAME

}}}

-- END SAMPLE DEVICE HOTPLUG SCRIPT --

LinuxHints/MountingUSBDevices (last edited 2008-02-06 10:17:18 by 81)