how to execute a command automatically after resuming from suspend to RAM?
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
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?
So I created the following script in /etc/pm/sleep.d and chmod-ed it to 755:
#!/bin/bash
#
# 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
thaw|resume)
hdparm -B 254 /dev/sda
;;
*)
;;
esac
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?
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 ]
Code:
No spaces of course
Code:
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.
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...
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...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.