You are not logged in.
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
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
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
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!
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
Last edited by nierro (2012-09-04 15:40:15)
Offline
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!
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
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
Hdparm -S 6(0), damn i didn't noticed it!
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
Hdparm -S 6(0), damn i didn't noticed it!
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
@Unia: Where is your harddrive? /dev/sda exists? Output of ls /sys/block?
Offline
@unia: yes i'm saying that
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
Offline
@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
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
Let us know
Offline
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?):
EDIT: Oh, and when I run udevadm info --path=/block/sda --attribute-walk | grep model I get
syspath not found
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
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