1

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

3 Answers3

2

I had the same problem and sat on it for 3 days trying to get the @#$%! SME to mount the USB HDD. I wanted to do an external USB backup and it refused to mount it correctly. Giving me similar errors as you indicated. Not quite the same problem per-say as its a HDD and not SD card, but certainly similar none the less.

If you do a cat /proc/mdstat you will see the HDDs listed in your RAID configuration, it will however also show you that there is another drive, currently not mounted, as an optional drive to add to the RAID. In my case it was sdc, as sda and sdb made up the RAID.

I then removed the partition on sdc using fdisk /dev/sdc, added a new primary partition and saved it. mkfs.ext3 -L MyLabel /dev/sdc1 (give it a label name) mkdir -p /media/usbdevice

removed it, wait a few seconds and plug it back in. egrep "(kernel|fstab|scsi).*(usb|USB)" /var/log/messages should now show you that it mounted the usb drive with a label.

viola fstab-sync did its job and you're good to go.

Andreas
  • 21
  • 2
0

Since SME Server has hal and udev you can write a small Python script/daemon (that link talks about USB devices, but you can modify it for any storage type) that detects the media insertions and performs the operations.

Ignacio Vazquez-Abrams
  • 45,019
  • 5
  • 78
  • 84
0

You're looking for a program called halevt. Be advised you'll need to be comfortable with editing XML to get it to do what you want.

LawrenceC
  • 1,192
  • 6
  • 14