Friday, November 7, 2008

Resolving the APM issue, reducing HD Load_Cycle.


There is a noticeable issue for whom using Linux (say Ubuntu) on laptops, which is the HD load cycle.

When you leave your laptop on battery power, HD generates a strange sound, maybe 3 time per minute or once every 10 seconds, this is the sound of parking/unparking.

This happens even during activity, and this severely shortens the life of hard drives, this bug is reported on the launchpad under the name: " Bug #59695 : High frequency of load/unload cycles on some hard disks may shorten lifetime".

Now, I think they managed to resolve the problem in the latest Ubuntu release 8.10. Yet, I am using Ubuntu 8.04.1 Hardy and the problem still exist.

Therefore, I have fixed this problem temporally until there is an official fix for this issue in the next update.

My solution will effectively keep this parameter at reasonable amount: 193 Load_Cycle_Count. You can know your number by executing this command in a shell: 'sudo smartctl -a /dev/sda', you have to install "smartmontools" program before you can use this command.

1. install smartmontools by issuing this command in a shell: 'sudo aptitude install smartmontools'
2. create a new file named: "hdparm" in the /etc/init.d
3. edit /etc/hdparm.conf to add the following lines in it:

/dev/sda { #Your HD's name maybe different
apm = 255
spindown_time = 0

4. edit /etc/init.d/hdparm to add the following line in it:
hdparm -B 255 /dev/sda #Or whatever your HD name is.
hdparm -S0 /dev/sda #Or whatever your HD name is.

5. give hdparm execute permission: 'sudo chmod +x /etc/init.d/hdparm'
6. edit /etc/acpi/ 'nano /etc/acpi/', to replace the 1 from the command '$HDPARM -B 1 /dev/$drive 2>/dev/null' with 255, the new command will be: '$HDPARM -B 255 /dev/$drive 2>/dev/null'
7. update the rc by issuing this command: 'sudo update-rc.d hdparm defaults', this will make hdparm script start at boot time.

This will reduce the number of spinning down per min/hour/day significantly.