-   Linux - General (
-   -   how to execute a command automatically after resuming from suspend to RAM? (

bjharker 11-19-2008 08:38 PM

how to execute a command automatically after resuming from suspend to RAM?
Hi all-

I'm running Fedora 8 with the latest stable kernel on an HP dv2715nr laptop (AMD Turion64 X2, 2GB RAM, nVidia GeForce 7150M) and using KDE.

First, a little background. I have one of those laptops where some pretty aggressive settings are causing the hard-disk read-head to park repeatedly. The laptop is barely 6 months old and I'm already at 100000 parks (thank you smartctl). This is bad. :)

A temporary solution is to run:
# hdparm -B 254 /dev/sda

and the parking pretty much stops. Note: completely disabling APM with -B 255 doesn't stop the parking, but -B 254 is the least aggressive setting. Anyway, this solution is great and all, but I need to do it every time I reboot (which really isn't an issue since you can run it from rc.local). The problem is, how can I run this same command automatically when I resume from suspending to RAM? Is there a resume script somewhere that I can stick this command into?

Thanks for any help!

bjharker 11-20-2008 11:00 AM

So I created the following script in /etc/pm/sleep.d and chmod-ed it to 755:

# A script to automatically reset the APM disk settings to least-aggressive after
# resuming from suspend to RAM. This prevents the disk read-head from rapidly parking...

. /usr/lib/pm-utils/functions

case "$1" in
hdparm -B 254 /dev/sda

exit $?

but I still get the rapidly-parking head after resuming. I modeled this script after some info I found on the web about restoring a display that goes black upon resuming. Anyone have any ideas? Pleeeeeeease?

EDIT: sorry about the badly-written code. How do you get one of those nice "Code:" boxes?

PAix 11-20-2008 12:03 PM


Sorry, I am unable to answer your main question, but as for the nice little CODE boxes!
Above the reply window (towards the right) there is an icon "#". If you highlight your code and then hit that button, then it's job done.
Alternatively (command line bods) type [ code ] YOUR CODE HERE [/ code ]


No spaces of course

and the markup is not
    case sensitive
    but respects your indents etc
in a lovely box.

Good luck with your main issue. I hope someone knowlegable happens by shortly.

Even small wins can be counted as successes.

JZL240I-U 11-21-2008 02:26 AM

I don't really understand your script, particularly what you are sourcing. But what I can't get at all is how and where would the parameter get its value from? Is it really loaded with "thaw|resume"? Did you try to "echo $1"? Because if it is not "thaw|resume" you'll of course get the old behavior of the disk...

bjharker 11-22-2008 01:31 AM

To be honest, I'm not sure about the script either...but like I said, I basically copied it from something I found online, where it was used (with Fedora 8, btw) to correct a blank screen upon resuming from suspend to RAM. I just substituted the hdparm command. I'm open to suggestions...

JZL240I-U 11-24-2008 09:00 AM

Yeah, well, why don't you try

echo \$1 has the value of: $1
and have a look at the true value? At least then you'll know...

All times are GMT -5. The time now is 03:24 PM.