Ubuntu and clicking sound from the harddrive

I have experienced that my harddrive makes a clicking sound about every 10th second on my Ubuntu 9.10 and a fix to this problem is to disable APM using hdparm.
This behaviour comes from very activ APM modes that some drive manufacturers use and that leads to excessive head parking and can reduce a harddrives life.

You can perform a quick test if your drive is affected by this issue

# hdparm -B 255 /dev/sda

Some harddrives do not accept value 255 (disable APM), then you could try value 254 (almost disabled APM).

A permanent fix to this issue is to add the following line to your /etc/hdparm.conf file

/dev/sda {
        apm = 255
}

In my example the sda drive is clicking. These settings is not active until you have rebooted your machine.

To verify that the value is active you could issue the command

# sudo hdparm -I /dev/sda | grep "Advanced power management level:"

Determine the number load cycles your harddrive has gone through

# sudo aptitude install smartmontools
# sudo smartctl -A /dev/sda|grep "Load_Cycle_Count"

These examples has been tested on my HP 8530p and worked like a charm.