LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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

Reply
 
Search this Thread
Old 11-19-2008, 07:38 PM   #1
bjharker
LQ Newbie
 
Registered: Jan 2006
Distribution: Fedora 8 & 11, CentOS 5, Debian Etch, Slackware 12.2
Posts: 26

Rep: Reputation: 15
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!
 
Old 11-20-2008, 10:00 AM   #2
bjharker
LQ Newbie
 
Registered: Jan 2006
Distribution: Fedora 8 & 11, CentOS 5, Debian Etch, Slackware 12.2
Posts: 26

Original Poster
Rep: Reputation: 15
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?

Last edited by bjharker; 11-20-2008 at 10:05 AM.
 
Old 11-20-2008, 11:03 AM   #3
PAix
Member
 
Registered: Jul 2007
Location: United Kingdom, W Mids
Distribution: SUSE 11.0 as of Nov 2008
Posts: 195

Rep: Reputation: 40
Hi,

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.


Even small wins can be counted as successes.
 
Old 11-21-2008, 01:26 AM   #4
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE 13.1 / 12.3_64-KDE, Ubuntu 14.04, Fedora 20, Mint 17, Chakra
Posts: 3,675

Rep: Reputation: Disabled
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...
 
Old 11-22-2008, 12:31 AM   #5
bjharker
LQ Newbie
 
Registered: Jan 2006
Distribution: Fedora 8 & 11, CentOS 5, Debian Etch, Slackware 12.2
Posts: 26

Original Poster
Rep: Reputation: 15
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...
 
Old 11-24-2008, 08:00 AM   #6
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE 13.1 / 12.3_64-KDE, Ubuntu 14.04, Fedora 20, Mint 17, Chakra
Posts: 3,675

Rep: Reputation: Disabled
Yeah, well, why don't you try
Code:
echo \$1 has the value of: $1
and have a look at the true value? At least then you'll know...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Some Way to Execute a CGI Command Automatically des_a Programming 3 10-27-2007 06:18 PM
How to automatically execute a command (TrueCrypt) on mount cbonar Linux - General 2 08-27-2006 10:42 AM
is it possible to automatically execute a command when cd is mounted? LiquidSlumber Linux - Software 1 03-26-2006 01:18 AM
Software Suspend - freezes while resuming TazG Linux - Software 2 08-11-2004 10:19 AM
? to add a command to execute automatically when xwindows loads up Kasperisa Linux - Newbie 2 08-02-2003 10:16 AM


All times are GMT -5. The time now is 11:51 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration