Friday, February 17, 2012

Hard Disk Problems: Disabling Spindown

So I managed to upgrade my laptop's hard disk, and setup a dual-boot system with Windows 7 Ultimate and Debian/testing. It all seemed to be working just fine. I was pleased, and mildly surprised. It didn't last long, though.

The first sign of trouble was that my laptop would not come out of sleep mode ("suspend") - and this happened on both Windows and Linux. My theory, at the time, was that the antiquated SATA interface on my machine, and the new hard-disk's aggressive power management features, do not play well together. The common wisdom on the Net is that one has to prevent the OS from spinning down the hard disk when it goes to sleep.

Doing that on Windows 7 is left as an exercise to the reader. Linux, on the other hand, earns its reputation fair and square as a time-waster. You should add the following incantation to /etc/hdparm.conf:
/dev/sda {
        apm = 254
        spindown_time = 0
(where /dev/sda is the block device pointing to the hard-disk in question), and then restart hdparm (as root):
invoke-rc.d hdparm restart
The only trouble with this, is that it only works for the first time the system goes to sleep, and on the second time the system hangs again. This is caused by a long standing wishlist-bug in hdparm (see Ubuntu bug #199094 and Debian bug #510676), with a published fix, that has not been applied for some reason. Basically, most hdparm settings are lost upon resuming from suspend.

The fix is to create the a script /etc/pm/sleep.d/20hdparm, with the following contents:
# This script reinitializes the hard disk settings on resume.                                                                              

case $1 in
    /usr/sbin/invoke-rc.d hdparm start >/dev/null
    # Not needed                                                                                                                           
But even with this, I ended up completely disabling sleep/hibernation because I couldn't get the box to come out of hibernation, and I had some more hard disk trouble.

Stay tuned...

No comments:

Post a Comment