Notice from qwijibow:
Ignore all scripts on this page, auto probing of USB card readers is handld by the Hardware Abstraction Layer. Make sure HAL is installed, and the daemon "hald" runs during boot-up (or at least before you start using the usb card reader)
However, the first post will still be of use for help installing the usb card reader drivers.
My Multi-Slot USB card reader didnt work exactly how i liked itout the box, so i made a few tweaks.
Here's how and why.
my Card reader is a 21 in 1 Memory card reader, which has 4 slots for cards, and is capable of using upto 4 different cards at once.
All 4 cards run off the SAME single usb connection (without an internal USB hub)
This adds an unseen consiquence.
Bu doing this, we forfeit USB's hot plug abilities.
For example, a single card reader will use its hotplug abbility's to reset the usb drivers when a new card is inserted or removed, causing the kernel to re-scan the device, and detect vital things like the cards size, partiton table read/write etc etc.
Multi slots cannot do this.
Imagine One card is in use, and we insert a second, if the device was to use the normal hot-plug trigger, the in use device would be re-set. possably losing data.
######################
Question: Ahaaaaa !
But windows seems to be able to detect new cards beeing inserted just fine !
and without upsetting other cards in use... How does windows do this ?
######################
######################
Answer: Windows does not use the hotplug usb feature either, it polls each of the 4 slots every second or 2, asking them if they have a card inserted, if the answer changes from no to yes, it knows a card was inserted, if the answer changes from yes to no, it knows a card was removed.
######################
So, a simple solution may be to implement the windows method into a linux script.
The script would be fairly simple, somthing like
CODE
white true
do
/sbin/hdparm -z /dev/sdX || sleep 9
sleep 1
done
replace X with the slot character [a-z]
This script loops round checking the usb card reader for new cards every second.
if a card is in use, the script waits 10 seconds untill it continues checking.
This basically how windows does it.
BUT i hate this method for 3 reasons.
1) The disk activity light constantly flickers, annoying, as my card reader is eye hight, and its distracting.
2) Its a messy solution, and possably slows down performance of the card reader.
3) it fills the messages log will /dev/sdX is busy mesages.
People are always saying how customisable linux is, and how its so easy.. so lets show off, and
make a better solution.
BUT first off, lets make sure your multi slot cad reader is working.
make sure the following modules are loaded (run lsmod as root, and look for the following enteries)
QUOTE
sg
sd_mod
usb_storage
scsi_mod
ohci_hcd
ehci_hcd <== Only needed for USB version 2.0
usbcore
sd_mod
usb_storage
scsi_mod
ohci_hcd
ehci_hcd <== Only needed for USB version 2.0
usbcore
if any of those are missing, run the following comand as root, for each missing module
CODE
modprobe <name of mising module>
if the above command ever returns a module not found, dont worry, the module if porbabl in-bult into your kernel by your distro makers, and noesnt need to be loaded speratly.
now, just to make sure your card reader is supported, run the following command.
CODE
dmesg | grep scsi
you should see output similar to the following.
NOTE: you will have extra enteries if you also have SCSI disks as opposed to IDE disks.
If you dont know what SCSI is, you probably dont have SCSI disks
QUOTE
scsi0 : SCSI emulation for USB Mass Storage devices
Attached scsi removable disk sda at scsi0, channel 0, id 0, lun 0
Attached scsi generic sg0 at scsi0, channel 0, id 0, lun 0, type 0
Attached scsi removable disk sdb at scsi0, channel 0, id 0, lun 1
Attached scsi generic sg1 at scsi0, channel 0, id 0, lun 1, type 0
Attached scsi removable disk sdc at scsi0, channel 0, id 0, lun 2
Attached scsi generic sg2 at scsi0, channel 0, id 0, lun 2, type 0
Attached scsi removable disk sdd at scsi0, channel 0, id 0, lun 3
Attached scsi generic sg3 at scsi0, channel 0, id 0, lun 3, type 0
Attached scsi removable disk sda at scsi0, channel 0, id 0, lun 0
Attached scsi generic sg0 at scsi0, channel 0, id 0, lun 0, type 0
Attached scsi removable disk sdb at scsi0, channel 0, id 0, lun 1
Attached scsi generic sg1 at scsi0, channel 0, id 0, lun 1, type 0
Attached scsi removable disk sdc at scsi0, channel 0, id 0, lun 2
Attached scsi generic sg2 at scsi0, channel 0, id 0, lun 2, type 0
Attached scsi removable disk sdd at scsi0, channel 0, id 0, lun 3
Attached scsi generic sg3 at scsi0, channel 0, id 0, lun 3, type 0
look at the "lun x" enteries, you SHOULD see on lun for each slot in your card reader.
i have lun 0 to lun 3 (4 slots)
If you only see one lun, and have more than 1 slot, your kernel needs a re-compile.
This is very un-likely, but if this is you, reply here, and i wil help you do this.
basically you need to go to
Device Drivers -> SCSI ->
and select "PROBE ALL LUNS ON SCSI DEVICE"
and re-compile.
Each slot will be accessable as a differant /dev/sdX1 device.
Insert your memory cards, then un-plug the reader, and plug it back in.
###########
QUESTION: why did we have to re-plug it in ?
ANSWER:
Remember what i talked about above ?
because no cards were inserted when you turned the computer on / loaded the drivers, then no cards were detected, linux has not re-scanned the device, so still thinks no cards are inserted, re-plugging it in, caused linux to re-scan the device and find new cards.
###########
I am NOW going to show you how to make linux re-scan for new cards all by itself, when needed, withoout user interaction.
you will need to install sudo if sudo is not already installed (it probably is !)
edit /etc/sudoers with the following command AS ROOT
CODE
visudo -f /etc/sudoers
and add the following line. to the end of the file.
QUOTE
%users ALL = NOPASSWD:/sbin/hdparm -z /dev/sd[a-e]
this will allow normal users to probe the memory cards without the root password
(if you have more than 5 SCSI devices + memory card slots, edit the "[a-e]"
if in doubt [a-z] will allow ou to use all of them.
now make some mount points for your memry cards.
CODE
mkdir /mnt/sda
mkdir /mnt/sdb
mkdir /mnt/sdc
mkdir /mnt/sdd
chmod 777 -R /mnt/sd*
now edit /etc/fstab
add the following lines
QUOTE
/dev/sda1 /mnt/sda auto noauto,user,sync 0 0
/dev/sdb1 /mnt/sdb auto noauto,user,sync 0 0
/dev/sdc1 /mnt/sdc auto noauto,user,sync 0 0
/dev/sdd1 /mnt/sdd auto noauto,user,sync 0 0
/dev/sdb1 /mnt/sdb auto noauto,user,sync 0 0
/dev/sdc1 /mnt/sdc auto noauto,user,sync 0 0
/dev/sdd1 /mnt/sdd auto noauto,user,sync 0 0
AND FINALLY....
we are going to program a *FAKE MOUNT*
The job of this, is to replace the real mount.
it will snoop at what the computer wants mount to do.
if mount is beeing called to mount a memory card, it will probe that card first.
re-scanning its partiton table.
cd into /bin/ and rename the mount program
CODE
cd /bin
mv mount mount-real
now add the fake mount.
save the following file as root, to /bin/mount.
Notice from qwijibow:
This version of the mount script is obsolite, use the mount script, and install instruction from post =6 of this thread !!!!
CODE
#!/bin/bash
# Code by Chris Stones (chris.stones@ googles email [i hate spam])
# If you can think of a better way of doing this ( patch the usb_storage drivers ?) Please let me know;)
# fake mount !!!!
# intercept parameters to mount.
# may need to re-scan the media pannel for new / removed cards before mounting.
#this script assumes you have sudo setup to allow regular users to run hdparm -z /dev/sd[a-z]
#add line "%users ALL = NOPASSWD:/sbin/hdparm -z /dev/sd[a-e]" to /etc/sudoers
#this script ALSO assumes the mount points are /mnt/sd[a-z]
#if anyone can edit this script to parse /etc/fstab, please do so, and let me know.
test_wait() {
if [ ! -f $1 ]; then
sleep 1
fi
}
probe() {
sudo /sbin/hdparm -z $1 > /dev/null
test_wait $1"1"
test_wait $1"1"
test_wait $1"1"
}
if [ `echo $1| head -c 7` = "/mnt/sd" ]; then
probe "/dev/"`echo $1 | tail -c 4`
fi
# call real mount
/bin/mount-real $1 $2 $3 $4 $5 $6 $7
now make the script executable
CODE
chmod +x /bin/mount
This little script is quite simple, if you call mount with parameter "/mnt/sd[a-d]"
the script will instruct the kernel to re-scan the device you are about to mount.
it then waits upto 3 seconds for the kernel to find a card, and add a /dev/sd[a-d]1 device node.
it then passes control to the real mount.
If you are NOT mounding a usb card reader show, control is passed instantly to the real mount.
Try it out, you should now be ableo to mound your cards like so
CODE
mount /mnt/sda
or with KDE's graphical mount tools (or gnome / whatever graphical envronment you use)
So, what do you think ??
Better solution that constant probing ? or do you prefere the Windows method ?

