help: udev rule for usb stick
Hi everybody,
is anyone willing to suggest an udev rule to SYMLINK my usb stick to
something like "/dev/usbpen"? I know that the web is full of suggestions on
how to do it, but I can't get it to work for me!
When I plug it in, it gets recognized by the scsi emulation and assigned
to /dev/sda, but I've been trying in vane to write an udev rule to catch this
device and symlink it to something else.
(Running Debian sarge, with kernel 2.6.13.3 compiled from the sources
on kernel.org with hotplug, udev support and all the like)
Here below I include a portion of syslog and some contents of the sys
filesystem. The problem seems to be that /dev/sda corresponds to
usb/2-2/2-2:1-0, but all the info on the vendor/product, etc of my stick are
in the usb/2-2 directory...
Any suggestion is welcome!
Thanks,
Matteo
Portion of syslog relative to the event of plugging in the usb stick.
---- start syslog ----
Oct 20 01:27:05 roccia kernel: usb 2-2: USB disconnect, address 14
Oct 20 01:27:05 roccia udev[10320]: removing device node '/dev/sg1'
Oct 20 01:27:05 roccia udev[10323]: removing device node '/dev/sda'
Oct 20 01:27:12 roccia kernel: usb 2-2: new full speed USB device using
uhci_hcd and address 15
Oct 20 01:27:12 roccia kernel: scsi14 : SCSI emulation for USB Mass Storage
devices
Oct 20 01:27:12 roccia kernel: usb-storage: device found at 15
Oct 20 01:27:12 roccia kernel: usb-storage: waiting for device to settle
before scanning
Oct 20 01:27:12 roccia usb.agent[10443]: usb-storage: already loaded
Oct 20 01:27:17 roccia kernel: Vendor: Model:
Rev:
Oct 20 01:27:17 roccia kernel: Type: Direct-Access
ANSI SCSI revision: 00
Oct 20 01:27:17 roccia kernel: SCSI device sda: 1019617 512-byte hdwr sectors
(522 MB)
Oct 20 01:27:17 roccia kernel: sda: Write Protect is off
Oct 20 01:27:17 roccia kernel: sda: Mode Sense: 00 c0 00 00
Oct 20 01:27:17 roccia kernel: sda: assuming drive cache: write through
Oct 20 01:27:17 roccia kernel: SCSI device sda: 1019617 512-byte hdwr sectors
(522 MB)
Oct 20 01:27:17 roccia kernel: sda: Write Protect is off
Oct 20 01:27:17 roccia kernel: sda: Mode Sense: 00 c0 00 00
Oct 20 01:27:17 roccia kernel: sda: assuming drive cache: write through
Oct 20 01:27:17 roccia kernel: sda: unknown partition table
Oct 20 01:27:17 roccia kernel: Attached scsi removable disk sda at scsi14,
channel 0, id 0, lun 0
Oct 20 01:27:17 roccia kernel: Attached scsi generic sg1 at scsi14, channel 0,
id 0, lun 0, type 0
Oct 20 01:27:17 roccia kernel: usb-storage: device scan complete
Oct 20 01:27:17 roccia scsi.agent[10504]: sd_mod: loaded sucessfully (for
disk)
Oct 20 01:27:17 roccia udev[10518]: configured rule in
'/etc/udev/rules.d/z_hal-plugdev.rules[2]' applied, 'sda' becomes '%k'
Oct 20 01:27:17 roccia udev[10518]: creating device node '/dev/sda'
Oct 20 01:27:17 roccia udev[10519]: creating device node '/dev/sg1'
---- end syslog ----
Also, this is the result of an investigation of the sys filesystem:
matteo@roccia:~$ cd /sys/block/sda/
matteo@roccia:/sys/block/sda$ ls -l
totale 0
-r--r--r-- 1 root root 4096 2005-10-20 01:27 dev
lrwxrwxrwx 1 root root 0 2005-10-20 01:27 device
-> ../../devices/pci0000:00/0000:00:10.1/usb2/2-2/2-2:1.0/host14/target14:0:0/14:0:0:0
drwxr-xr-x 3 root root 0 2005-10-20 01:27 queue
-r--r--r-- 1 root root 4096 2005-10-20 01:27 range
-r--r--r-- 1 root root 4096 2005-10-20 01:27 removable
-r--r--r-- 1 root root 4096 2005-10-20 01:27 size
-r--r--r-- 1 root root 4096 2005-10-20 01:27 stat
matteo@roccia:/sys/block/sda$ ls -l device/
totale 0
lrwxrwxrwx 1 root root 0 2005-10-20 01:28 block
-> ../../../../../../../../../block/sda
lrwxrwxrwx 1 root root 0 2005-10-20 01:27 bus
-> ../../../../../../../../../bus/scsi
--w------- 1 root root 4096 2005-10-20 01:28 delete
-r--r--r-- 1 root root 4096 2005-10-20 01:28 device_blocked
lrwxrwxrwx 1 root root 0 2005-10-20 01:27 driver
-> ../../../../../../../../../bus/scsi/drivers/sd
lrwxrwxrwx 1 root root 0 2005-10-20 01:28 generic
-> ../../../../../../../../../class/scsi_generic/sg1
-r--r--r-- 1 root root 4096 2005-10-20 01:28 iocounterbits
-r--r--r-- 1 root root 4096 2005-10-20 01:28 iodone_cnt
-r--r--r-- 1 root root 4096 2005-10-20 01:28 ioerr_cnt
-r--r--r-- 1 root root 4096 2005-10-20 01:28 iorequest_cnt
-rw-r--r-- 1 root root 4096 2005-10-20 01:28 max_sectors
-r--r--r-- 1 root root 4096 2005-10-20 01:27 model
-r--r--r-- 1 root root 4096 2005-10-20 01:28 queue_depth
-r--r--r-- 1 root root 4096 2005-10-20 01:28 queue_type
--w------- 1 root root 4096 2005-10-20 01:28 rescan
-r--r--r-- 1 root root 4096 2005-10-20 01:28 rev
-r--r--r-- 1 root root 4096 2005-10-20 01:28 scsi_level
-rw-r--r-- 1 root root 4096 2005-10-20 01:28 state
-rw-r--r-- 1 root root 4096 2005-10-20 01:28 timeout
-r--r--r-- 1 root root 4096 2005-10-20 01:27 type
-r--r--r-- 1 root root 4096 2005-10-20 01:27 vendor
But the files "vendor" and "model" are empty.
On the other hand,
matteo@roccia:/sys$ cd /sys/bus/usb/devices/2-2/
2-2:1.0 bDeviceProtocol bMaxPower configuration
idVendor speed
bcdDevice bDeviceSubClass bNumConfigurations devnum
maxchild version
bConfigurationValue bmAttributes bNumInterfaces driver
product
bDeviceClass bMaxPacketSize0 bus idProduct
serial
matteo@roccia:/sys$ cd /sys/bus/usb/devices/2-2/
2-2:1.0 bDeviceProtocol bMaxPower configuration
idVendor speed
bcdDevice bDeviceSubClass bNumConfigurations devnum
maxchild version
bConfigurationValue bmAttributes bNumInterfaces driver
product
bDeviceClass bMaxPacketSize0 bus idProduct
serial
matteo@roccia:/sys$ cd /sys/bus/usb/devices/2-2/
matteo@roccia:/sys/bus/usb/devices/2-2$ cat idProduct
1100
matteo@roccia:/sys/bus/usb/devices/2-2$ cat idVendor
10d6
matteo@roccia:/sys/bus/usb/devices/2-2$ cat serial
USB 2.0(FS) FLASH DISK
matteo@roccia:/sys/bus/usb/devices/2-2$ cat product
USB 2.0(FS) FLASH DISK
matteo@roccia:/sys/bus/usb/devices/2-2$ cat version
1.10
Reply to: