You are not logged in.

#1 2012-09-04 12:39:43

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

[SOLVED] Udev rule not getting picked up

Hey all,

I have made a udev rule (/etc/udev/rules.d/61-hdparm.rules) that doesn't get run. I have no clue why, as my second self-made udev rule (/etc/rules.d/50-powersave.rules) does work.

Here's the contents:

ACTION=="add", KERNEL=="sda", RUN+="/sbin/hdparm -S 0 -B 254 -a 2048 /dev/sda"

Can you help me troubleshoot this?

Last edited by Unia (2012-09-05 16:20:09)


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#2 2012-09-04 15:08:46

ctxfi-user
Member
Registered: 2010-10-31
Posts: 56

Re: [SOLVED] Udev rule not getting picked up

Hello Unia,

this works for me:

ACTION=="add", SUBSYSTEM=="block", ATTRS{model}=="SAMSUNG HM321HI", RUN+="/sbin/hdparm -B 254 /dev/$kernel"

To get ATTRS{model} for sdX use (trailing space will be ignored):

udevadm info --path=/block/sdX --attribute-walk | grep model

You can test your rule for sdX and study the output:

udevadm test /block/sdX

This should output somewhere:

run: '/sbin/hdparm ...'

If you still get this output with your rule, then the problem may could be the call of hdparm itself?!

Have fun!

Offline

#3 2012-09-04 15:37:51

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: [SOLVED] Udev rule not getting picked up

Thanks for the input ctxfi-user.

I ran udevadm test for my rule and I did get the desired output:

run: '/sbin/hdparm -S 0 -B 254 -a 2048 /dev/sda'

I know the rule is correct, because prior to using a udev rule to set it I had the exact same setting in /etc/rc.local, which worked - and also, when I run the command manually, I don't get any error messages.

EDIT: Oh, and when I run udevadm info --path=/block/sda --attribute-walk | grep model I get

syspath not found

EDIT2: Nevermind, got it now. I will test and see if your rule does work.

Last edited by Unia (2012-09-04 15:41:32)


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#4 2012-09-04 15:38:50

nierro
Member
From: Milan, Italy
Registered: 2011-09-02
Posts: 849

Re: [SOLVED] Udev rule not getting picked up

Hi Unia!
Can you tell me the reason why you're splitting the hdparm settings from your powersave script?
Well, as far as i can see it is what you're trying to reach here! wink
Thanks and sorry for the OT.
EDIT: oh, well, i see now in you script that you're using the same hdparm settings for ac and battery, so do not consider my post wink

Last edited by nierro (2012-09-04 15:40:15)

Offline

#5 2012-09-04 15:40:44

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: [SOLVED] Udev rule not getting picked up

nierro wrote:

Hi Unia!
Can you tell me the reason why you're splitting the hdparm settings from your powersave script?
Well, as far as i can see it is what you're trying to reach here! wink
Thanks and sorry for the OT.

These hdparm settings are the default I want to use. When I unplug my laptop, my powersave script overrides these settings with more aggresive power saving and when I plug it back in, it restores the defaults I try to set here.

EDIT: No, it's not the same. Look closely wink

Last edited by Unia (2012-09-04 15:52:26)


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#6 2012-09-04 16:03:33

nierro
Member
From: Milan, Italy
Registered: 2011-09-02
Posts: 849

Re: [SOLVED] Udev rule not getting picked up

Hdparm -S 6(0), damn i didn't noticed it! smile
By the way, i do not understand what do you mean: your 50-powersave.rules will override that anyway, whether you're on battery or on ac, because when udev is started, it will read your state and run the powersave script according to it.
Am i misunderstanding anything?

Offline

#7 2012-09-04 16:07:04

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: [SOLVED] Udev rule not getting picked up

nierro wrote:

Hdparm -S 6(0), damn i didn't noticed it! smile
By the way, i do not understand what do you mean: your 50-powersave.rules will override that anyway, whether you're on battery or on ac, because when udev is started, it will read your state and run the powersave script according to it.
Am i misunderstanding anything?

Darn, didn't think of that. So, what you're saying is that 50-powersave will run at boot and thus, set the correct settings?


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#8 2012-09-04 16:24:14

ctxfi-user
Member
Registered: 2010-10-31
Posts: 56

Re: [SOLVED] Udev rule not getting picked up

@Unia: Where is your harddrive? /dev/sda exists? Output of ls /sys/block?

Offline

#9 2012-09-04 16:41:01

nierro
Member
From: Milan, Italy
Registered: 2011-09-02
Posts: 849

Re: [SOLVED] Udev rule not getting picked up

@unia: yes i'm saying that big_smile

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor 
performance
cat /proc/sys/vm/dirty_ratio 
10

Just rebooted on ac mode...i do not link there my script, but trust me wink

Offline

#10 2012-09-04 17:39:31

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: [SOLVED] Udev rule not getting picked up

ctxfi-user wrote:

@Unia: Where is your harddrive? /dev/sda exists? Output of ls /sys/block?

Yes, it does exist. As I stated in my second edit, I think it works. The only thing I use to check if the correct hdparm settings are correct is the clicking sound, which I can't hear atm (busy surroundings) so I'll check in on this later.

However, what nierro said, does make sense. I think I'm going to remove the udev rule for hdparm altogether and just use that. But, again, will have to test this first wink


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#11 2012-09-04 18:54:34

nierro
Member
From: Milan, Italy
Registered: 2011-09-02
Posts: 849

Re: [SOLVED] Udev rule not getting picked up

Let us know smile

Offline

#12 2012-09-04 18:57:50

ctxfi-user
Member
Registered: 2010-10-31
Posts: 56

Re: [SOLVED] Udev rule not getting picked up

Unia wrote:
ctxfi-user wrote:

@Unia: Where is your harddrive? /dev/sda exists? Output of ls /sys/block?

Yes, it does exist.

I'm just curious... If /dev/sda exists, then /sys/block/sda should exist. And that means the following works (copy-paste-error?):

Unia wrote:

EDIT: Oh, and when I run udevadm info --path=/block/sda --attribute-walk | grep model I get

syspath not found
Unia wrote:

The only thing I use to check if the correct hdparm settings are correct is the clicking sound, which I can't hear atm (busy surroundings) so I'll check in on this later.

What? I mean, I know. But to get the values just use:

hdparm -a /dev/sda
hdparm -B /dev/sda
hdparm -S /dev/sda   <--- doesn't work for my drive! 

Or all together.

Edit: One additional note: Maybe the name of the rule was the problem in the way it got parsed to early... Have a look at /usr/lib/udev/rules.d/...

Last edited by ctxfi-user (2012-09-04 19:03:07)

Offline

#13 2012-09-05 16:19:57

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: [SOLVED] Udev rule not getting picked up

nierro was right, having the udev rule for my powersave script (which has the hdparm setting) suffices.

I'll mark this solved.

Thanks ctxfi-user and nierro!


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

Board footer

Powered by FluxBB