Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[resolved] Udev rule is not working!
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
biergaizi
n00b
n00b


Joined: 18 Dec 2011
Posts: 45
Location: Beijing, China

PostPosted: Mon Oct 01, 2012 4:16 am    Post subject: [resolved] Udev rule is not working! Reply with quote

I write a udev rule, but it's not working!

More information are avaliable here:
Code:

localhost biergaizi # cat /etc/udev/rules.d/91-change-schduler.rules
#SUBSYSTEMS=="usb", KERNEL=="sd??", ACTION=="add", RUN+="echo deadline > /sys/block/%k/queue/scheduler"
ACTION=="add", KERNEL=="sd??", RUN+="/usr/local/bin/USB"

localhost biergaizi # cat /usr/local/bin/USB
#!/bin/bash
echo 'Hello World!' >>"/home/biergaizi/udev.out"
exit

localhost biergaizi # ls -l /usr/local/bin/USB
-rwxr-xr-x 1 root root 66 10月  1 11:55 /usr/local/bin/USB


Why?
_________________
Keep It Simple, stupid.


Last edited by biergaizi on Wed Oct 03, 2012 3:46 am; edited 1 time in total
Back to top
View user's profile Send private message
PaulBredbury
Watchman
Watchman


Joined: 14 Jul 2005
Posts: 7310

PostPosted: Mon Oct 01, 2012 9:26 am    Post subject: Re: Udev rule is not working! Reply with quote

biergaizi wrote:
ACTION=="add", KERNEL=="sd??"

Maybe that runs *before* the partition is mounted read/write?

For kicks, try adding e.g. "sleep 10" to the start of your BASH script.
Back to top
View user's profile Send private message
biergaizi
n00b
n00b


Joined: 18 Dec 2011
Posts: 45
Location: Beijing, China

PostPosted: Mon Oct 01, 2012 2:39 pm    Post subject: Re: Udev rule is not working! Reply with quote

PaulBredbury wrote:
biergaizi wrote:
ACTION=="add", KERNEL=="sd??"

Maybe that runs *before* the partition is mounted read/write?

For kicks, try adding e.g. "sleep 10" to the start of your BASH script.


Please read my script carefully.
This script & udev rule is trying to write a file to my home folder (on my local hard drive), when a USB device is plugin.
Nothing to do with ro/rw.
_________________
Keep It Simple, stupid.
Back to top
View user's profile Send private message
biergaizi
n00b
n00b


Joined: 18 Dec 2011
Posts: 45
Location: Beijing, China

PostPosted: Wed Oct 03, 2012 3:45 am    Post subject: Reply with quote

This is my own mistake.

KERNEL=="sd??" matches to the device with a partition table (/dev/sda1) only. If your device doesn't have a partition table (/dev/sda), the rule isn't working.

You can change your rule to KERNEL=="sd?" to detect all kind of device.
_________________
Keep It Simple, stupid.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum