Hack script to stop excessive hard drive parking

Some laptop hard drives are set (by their manufacturers) to park their heads fairly soon after any drive accesses, to try and protect the drive from any damage caused by physical shock to the drive (e.g. such as if a laptop computer is dropped).  Unfortunately, this time period is quite short, and Linux would also access the drive, again, almost straight away.  This would result in the drive continually cycling the heads, and could prematurely wear out the mechanism.  Incidentally, the same situation happens if I run Windows Vista on the same laptop, but I have no solution for the problem on Windows.

My hack to resolve this turns off, or lessens the power management, on the hard drive.  I've done it in two parts:  The first is a commmand line in a bootup script, to set the power management parameter when the computer boots.  The other is adding the command in a script that'll be used after waking a computer up from hibernation or suspension.

In my case, it's Fedora 7 that I'm using, and hacked these scripts for.  Though they're probably applicable, if suitably modified, to other distributions.

Example scripts:


# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local

/sbin/hdparm -B255 /dev/sda
smartctl -d ata -a /dev/sda|grep Load_Cycle >> /var/log/messages

The first seven lines were already in the file, the last two are my additions.  The hdparm line resets the drive power management (you might want to lessen it, rather than disable it), and the smartctl line logs the head cycle count to keep an eye on things.  Ideally, the SMART daemon configuration might be modified to give you a warning if the cycle count had increased excessively, but I haven't explored doing that.



# This script turns off the power management in the internal hard drive
# when the computer thaws from hibernation or resumes from suspend,
# to stop the laptop hard drive parking its heads after a few seconds
# and the OS unparking them again, every few seconds, repeatedly
# (thereby, wearing the drive out extremely prematurely).
# The same hdparm command line is in the rc.local file to turn off
# power management on bootup and reboots.
# Alternative values to 255 could be used, instead, for less severe power
# management settings.  128 seems to be the (problematic) default.

case "$1" in

                /sbin/hdparm -B255 /dev/sda 



exit $?

Main sections:
contact details
business info
personal info
eBay & trading
“sales” ads
“wanted” ads
video production
misc info
website info/help
my computers
general info
desktop publishing
typing skills
WWW authoring
internet primer
turn it off?
electrical safety
why use Linux
why I use Linux
compatible hardware
feeling lucky?
Evolution signatures
installing software
auto NTPD restart
local DNS serving
restoring GRUB
overzealous HDD parking
Post-install customising
NFS serving
SMTP settings for Yahoo
time serving