Skip to main content
3 of 5
Thanks, salutations and username (profile!) not necessary on SO/SX http://meta.stackoverflow.com/a/3021/186664
Anthon
  • 81.4k
  • 42
  • 174
  • 228

udev rule not working

I have created a udev rules which is supposed to mount a usb device, backup some datas et cleanup everything. I am actually working on a Debian server.

There is the information about my usb device that I have with lsusb

Bus 001 Device 003: ID 054c:0243 Sony Corp. MicroVault Flash Drive

(Actually the lsusb returns more Bus / Device, but I have to write them by hand since I am not posting from my Debian machine :))

Then I have written my udev rule called :

95-usb_back.rules

into

/etc/udev/rules.d/

(I used 95 because the backup script takes some secondes and I want to run it as later as I can for avoiding to delay other stuff)

And finally the rule itself :

ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="054c", ATTR{idProduct}=="0234", RUN+="/usr/local/bin/mount_usb"
ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="054c", ATTR{idProduct}=="0234", RUN+="/usr/local/bin/backup_database"

I have tried this too :

ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="054c", ATTR{idProduct}=="0234", RUN+="bash /usr/local/bin/mount_usb"

Unsuccessfully :(

Then I restart udev

sudo /etc/init.d/udev restart

And when I plug my usb device I got a weird message :

[1348.295280] sd 6:0:0:0: [sdc] Assuming drive cache: write throught

twice

But nothing happen, not usb device mounted, no data backed up

I looked with tail -f /var/log/message

And the USB drive looks like detected :

usb 1-3: Product Storage Media 
usb 1-3 Manufacturer Sony`
...

Something must be wrong somewhere but I don't know what, neither where :(

Edit : Since I've been a little bit lazy because I can't rewrite everything from my server, please ask for further informations if needed, such as the script or more logs messages :)

Edelweiss
  • 111
  • 1
  • 1
  • 3