Hard Disk frequent head unloads (Disk Clicking whilst idle?) - Possible Solution?

I created a thread about a problem a I had with my hard disk clicking whilst idle little while ago and I may now have stumbled upon a possible solution. The strange thing with the problem is that Ubuntu/Kubuntu didn’t cause this problem but Opensuse 11.2 does.

I installed Fedora 13 to have a glimpse of what all the fuss was about and noticed that I had the same problem (hard disk clicking whilst idle ~ every 20 secs or so). Now there’s a wiki on this subject and a few bug reports:

https://ata.wiki.kernel.org/index.php/Known_issues

Problem Description

Some ATA harddrives perform very frequent head unloads under Linux significantly shortening their lifespans.
Root cause

The inactivity timer for head unload is configured too aggressively either via ATA APM (Advanced Power Management) feature or other non-standard means. Such aggressive settings are very fragile to changes in IO pattern and under Linux many such drives unload their heads only to re-load them shortly. Note that this relentless unloading/reloading cycle can also be triggered under Windows by installing programs which can alter the IO pattern (e.g. certain vaccine programs which runs in background).

Now two of the listed models with this problem are basically identical to my model (Dell Inspiron 1520) and basically share the same hardware: Dell Vostro 1500 and XPS 1520.

The workaround listed is to:

set APM to 254

Furthermore, there is a script: Storage-Fixup which can also be downloaded from opensuse software search. Indeed there is a report of this for a Vostro 1500:
Gmane Loom

The report suggests looking at:
Disk Power Management - openSUSE
which lists a method to create a configuration file to management disk power management:

/etc/pm/config.d/disk and

the power management script:

/etc/pm/power.d/disk

My question is whether I could download the storage-fixup rpm (https://ata.wiki.kernel.org/index.php/Known_issues#storage-fixup has a description of it and it can be found: Software.openSUSE.org) and install it to (hopefully) solve the issue or should I follow the method given in:
Disk Power Management - openSUSE

to set APM to 254:

# Configure disk power management settings to ensure both
# long disk life and good power management.
#
# Space delimited list of disk devices this affects.
#
DEVICES_DISK_PM_NAMES="/dev/sda"
#
#
# Power management modes
#
# Powersave mode off
#  Disable APM and spin-down
#
DEVICES_DISK_PM_POWERSAVE_OFF="hdparm -q -B 255 -q -S 0"
#
# Powersave mode on
# Enable APM to conservative 200 and set spin-down for 21 minutes
#
DEVICES_DISK_PM_POWERSAVE_ON="hdparm -q -B 200 -q -S 252"

Here are some further discussions on the topic if needed:
https://bugzilla.novell.com/show_bug.cgi?id=386555
https://bugs.launchpad.net/fedora/+source/pm-utils/+bug/59695

Thanks for any help in advance!

Well I seem to have solved the issue. Basically, the problem is something that affects a few hard drive models (see: https://ata.wiki.kernel.org/index.php/Known_issues for an incomplete list). The problem is:

Modern laptop drives have indeed the ability to suspend their activity (unloading the heads, as far as I understand). This reduces the power consumption of the disk, which is obviously good for a laptop on battery. However, a hard drive can only sustain a limited number of load cycles, so you don’t want this to happen too frequently.

So this issue can kill your harddrive faster. Indeed using smartmon tools I noticed that my load cycle count was increasing fairly rapidly after just 5-10 mins usage. “Luckily” since I haven’t been using Linux much my load cycle count value was only 69000 (The typical lifetime rating for laptop (2.5-in) hard drives is 300,000 to 600,000 load cycles)

The script storage-fixup is a script that solves the issue for specific hard drives (since each one needs unique values set). Unfortunately since my hard drive/laptop model was not on the list I would have to do it manually.

The fix involves using the hdparm utility to adjust the aggressive power management set by the manufacturers (who only had windoze in mind when configuring values).

Using hdparm we have to change two parameters:

-B Set Advanced Power Management feature, if the drive supports it. A low value means aggressive power management and
a high value means better performance. Possible settings range from values 1 through 127 (which permit spin-
down), and values 128 through 254 (which do not permit spin-down). The highest degree of power management is
attained with a setting of 1, and the highest I/O performance with a setting of 254. A value of 255 tells hdparm
to disable Advanced Power Management altogether on the drive (not all drives support disabling it, but most do).

and

-S Set the standby (spindown) timeout for the drive. This value is used by the drive to determine how long to wait
(with no disk activity) before turning off the spindle motor to save power. Under such circumstances, the drive
may take as long as 30 seconds to respond to a subsequent disk access, though most drives are much quicker. The
encoding of the timeout value is somewhat peculiar. A value of zero means “timeouts are disabled”: the device
will not automatically enter standby mode. Values from 1 to 240 specify multiples of 5 seconds, yielding timeouts
from 5 seconds to 20 minutes. Values from 241 to 251 specify from 1 to 11 units of 30 minutes, yielding timeouts
from 30 minutes to 5.5 hours. A value of 252 signifies a timeout of 21 minutes. A value of 253 sets a vendor-
defined timeout period between 8 and 12 hours, and the value 254 is reserved. 255 is interpreted as 21 minutes
plus 15 seconds. Note that some older drives may have very different interpretations of these values.

You can temporarily fix the issue by using the command (as root):

hdparm -B 254 -S 242 /dev/sdb

Note these values (254 and 242) are specific to hard drives (some do not support all values such as 255 (to switch off 255, so some googling and try and error may be needed before setting them). -B gives me better performance (less power management) and -S 242 means standbying the hard drive after 1 hour (to ensure that it doesn’t heat up).

You can check that you were succesful by issuing the command:

hdparm -I /dev/sda

(assuming sda is your hard drive)

and see if the output for APM gives the value 254 (mine was originally 128).

After issuing this command in Fedora the hard disk clicking stopped and the load cycle count didn’t increase for 15 mins (as opposed to an increase of 10-20 earlier).

To make this fix permanent:

Power saving by enabling hard disk AdvancedPM mode HOW TO - openSUSE

Essential reading before any even tries this:

https://ata.wiki.kernel.org/index.php/Known_issues#storage-fixup
https://bugzilla.novell.com/show_bug.cgi?id=386555
Power saving by enabling hard disk AdvancedPM mode HOW TO - openSUSE
Fedora 9 Sulphur on a Dell Latitude D430

since messing with hdparm without reading the man page could screw up your drive.

Sorry to bump this thread, but I’m having this problem on my recently installed 11.4 as well (I’m new to OpenSUSE). Used to have it in Ubuntu too, although it was fixed in 10.10 (or at least the problem no longer occurred, not sure whether it was actually fixed or just a coincidence of changed disk activity behavior). Does anyone know whether the above mentioned permanent fix can be applied to 11.4, or if perhaps another solution exists by now? Thanks.

By the way, is there anyone who knows whether it is safe to simply add the line

hdparm -B 254 /dev/sda

to /etc/rc.d/boot.local, as an alternative workaround?