Hey Everyone,
I'm currently running SME Server, and need to have a script run upon the attachment of SD Cards to my server. The script itself works fine (it copies the contents of the cards), but the automounting and execution of the script is where I'm having issues.
The I have a USB hub consisting of 10 USB ports; that shows up as:
[root@server ~]# lsusb
Bus 004 Device 002: ID 0000:0000
Bus 004 Device 001: ID 0000:0000
Bus 003 Device 001: ID 0000:0000
Bus 002 Device 001: ID 0000:0000
Bus 001 Device 055: ID 1a40:0101 TERMINUS TECHNOLOGY INC.
Bus 001 Device 051: ID 1a40:0101 TERMINUS TECHNOLOGY INC.
Bus 001 Device 050: ID 1a40:0101 TERMINUS TECHNOLOGY INC.
Bus 001 Device 001: ID 0000:0000
(The hub is the TERMINUS TECHNOLOGY INC entries)
As I cannot plug SD Cards directly into the server; I use a USB to SD card attachement (10 of them) plugged into the hub to read the cards. Upon pluggig the 10 attachments (without cards) into the hub; lsusb yields the following:
[root@server ~]# lsusb
Bus 004 Device 002: ID 0000:0000
Bus 004 Device 001: ID 0000:0000
Bus 003 Device 001: ID 0000:0000
Bus 002 Device 001: ID 0000:0000
Bus 001 Device 073: ID 05e3:0723 Genesys Logic, Inc.
Bus 001 Device 072: ID 05e3:0723 Genesys Logic, Inc.
Bus 001 Device 071: ID 05e3:0723 Genesys Logic, Inc.
Bus 001 Device 070: ID 05e3:0723 Genesys Logic, Inc.
Bus 001 Device 069: ID 05e3:0723 Genesys Logic, Inc.
Bus 001 Device 068: ID 05e3:0723 Genesys Logic, Inc.
Bus 001 Device 067: ID 05e3:0723 Genesys Logic, Inc.
Bus 001 Device 066: ID 05e3:0723 Genesys Logic, Inc.
Bus 001 Device 065: ID 05e3:0723 Genesys Logic, Inc.
Bus 001 Device 064: ID 05e3:0723 Genesys Logic, Inc.
Bus 001 Device 055: ID 1a40:0101 TERMINUS TECHNOLOGY INC.
Bus 001 Device 051: ID 1a40:0101 TERMINUS TECHNOLOGY INC.
Bus 001 Device 050: ID 1a40:0101 TERMINUS TECHNOLOGY INC.
Bus 001 Device 001: ID 0000:0000
As you can see, the readers are the "Gensys Logic, Inc" entries.
Plugging in an SD card to a reader doesn't affect lsusb (it reads exactly as above), however my system recognises the cards fine; as indicated by dmesg:
Attached scsi generic sg11 at scsi54, channel 0, id 0, lun 0, type 0
USB Mass Storage device found at 73
SCSI device sdd: 31388672 512-byte hdwr sectors (16071 MB)
sdd: Write Protect is on
sdd: Mode Sense: 03 00 80 00
sdd: assuming drive cache: write through
SCSI device sdd: 31388672 512-byte hdwr sectors (16071 MB)
sdd: Write Protect is on
sdd: Mode Sense: 03 00 80 00
sdd: assuming drive cache: write through
sdd: sdd1
SCSI device sdd: 31388672 512-byte hdwr sectors (16071 MB)
sdd: Write Protect is on
sdd: Mode Sense: 03 00 80 00
sdd: assuming drive cache: write through
SCSI device sdd: 31388672 512-byte hdwr sectors (16071 MB)
sdd: Write Protect is on
sdd: Mode Sense: 03 00 80 00
sdd: assuming drive cache: write through
sdd: sdd1
SCSI device sdd: 31388672 512-byte hdwr sectors (16071 MB)
sdd: Write Protect is on
sdd: Mode Sense: 03 00 80 00
sdd: assuming drive cache: write through
SCSI device sdd: 31388672 512-byte hdwr sectors (16071 MB)
sdd: Write Protect is on
sdd: Mode Sense: 03 00 80 00
sdd: assuming drive cache: write through
sdd: sdd1
If I manually mount sdd1 (mount /dev/sdd1 /somedirectory/) this works fine.
What I'm really after is a solution that automounts each of the cards as they are inputted into the reader; and executes a script for them (this will involve copying their contents to another directory).
My problem is that I don't know how to do this; I don't think udev will work as the USB devices don't change; if I could somehow get udev working with /dev/disk/by-path/ however I think this is doable (it seems to keep constant entries).
ls /dev/disk returns:
pci-0000:00:1d.7-usb-0:4.1.1.1:1.0-scsi-0:0:0:0
pci-0000:00:1d.7-usb-0:4.1.1.2:1.0-scsi-0:0:0:0
pci-0000:00:1d.7-usb-0:4.1.1.3:1.0-scsi-0:0:0:0
pci-0000:00:1d.7-usb-0:4.1.1.4:1.0-scsi-0:0:0:0
pci-0000:00:1d.7-usb-0:4.1.2:1.0-scsi-0:0:0:0
pci-0000:00:1d.7-usb-0:4.1.3:1.0-scsi-0:0:0:0
pci-0000:00:1d.7-usb-0:4.1.4:1.0-scsi-0:0:0:0
pci-0000:00:1d.7-usb-0:4.2:1.0-scsi-0:0:0:0
pci-0000:00:1d.7-usb-0:4.3:1.0-scsi-0:0:0:0
pci-0000:00:1d.7-usb-0:4.4:1.0-scsi-0:0:0:0
pci-0000:00:1d.7-usb-0:4.4:1.0-scsi-0:0:0:0-part1
pci-0000:0b:01.0-scsi-0:0:1:0
pci-0000:0b:01.0-scsi-0:0:1:0-part1
pci-0000:0b:01.0-scsi-0:0:1:0-part2
From above, we can see I have only one card plugged into the reader (pci-0000:00:1d.7-usb-0:4.4:1.0-scsi-0:0:0:0-part1).
Going
mount /dev/disk/by-path/pci-0000\:00\:1d.7-usb-0\:4.4\:1.0-scsi-0\:0\:0\:0-part1
Works and places the card under /media/usbdisk/, however:
mount /dev/disk/by-path/pci-0000\:00\:1d.7-usb-0\:4.4\:1.0-scsi-0\:0\:0\:0-part1 slot1/
doesn't work, and returns "mount: can't get address for /dev/disk/by-path/pci-0000"
Any ideas and solutions would be great, I've seen the knowledge of a lot of the guys on here before so I'm hopeful someone can help me out.
Thanks