I've got a
udev rule that triggers a shell script that copies photos off my CF card when I insert the card into my USB card reader. This worked fine for a while. But after a recent upgrade it has stopped working.
The problem (AFAICT) is that inserting the CF card into the USB reader is no longer triggering any
udev events, so my script never runs. (Even the entries in
/dev/disk/by-label/ don't show up on insert, and
dmesg shows nothing about the insert.)
I can cause the
udev events to trigger if I run
fdisk -l /dev/sdf (or
sdh or whatever device it is that seems to be where the CF card will appear). I've verified the
udev events with
udevadm monitor, and by running
udevd --debug. After I manually trigger the system, the script works fine from this point.
I'm running Debian 6.0 (Squeeze), and I'm pretty confident it was the upgrade from Lenny a couple months back that changed the behavior, but I'm not sure if it was some subtle change in
udev (perhaps I'm listening for the wrong events?) or some change in the kernel or USB stack? Anyway, anyone have suggestions for how to fix this? Or suggestions for getting more debugging info out of the usb-storage module?
This is the udev rule I'm using:
KERNEL=="sd??", SUBSYSTEM=="block", RUN+="/usr/local/bin/hot-add"
Update #1: Trigger on blockdev and partition changes
I added a rule to trigger on just the block device instead of on a partition (in case that might show up), but it doesn't trigger when I insert the CF card either:
KERNEL=="sd?", SUBSYSTEM=="block", RUN+="/usr/local/bin/hot-add-disk"
Oddly, if I run
fdisk -l /dev/sdf to trigger recognition of the CF card, I get a "changed" event for
/dev/sdf (even though I never got an "add" event).
add uevent triggers
For my setup, if I do (as root)
echo add > /sys/block/sdf/uevent with the CF card inserted but otherwise unrecognized, that will trigger all the
udev events properly and all my scripts run correctly.
udevadm info --query=all --name=sdf before and after inserting the CF card shows no difference. If I inject the 'add' event and re-run the
udevadm command I get a bit more output (there is some information about disk partitions).
Update #3: USB key vs. CF card in USB reader
Inserting a vanilla USB key triggers all the
udev events immediately and works just fine. Inserting a CF card into the USB card reader does not. For the card reader, it seems that the USB device "exists" even when no CF card is inserted (so a
/sys/block/sdf entry exists), but with the USB key, the
/sys/block/sdj only exists while the USB key is plugged in.
Update #4: Maybe fixed in 2.6.38
This Ubuntu bug has an update (the last one) that claims the bug was no longer present in a 2.6.38 kernel.
Update #5: Not fixed (in 3.2.0)
I've upgraded the kernel a couple times, and even changed the motherboard I'm using, and I still see the same problem. I'm currently at a 184.108.40.206 kernel. And
udev version 164.