Wednesday, October 31, 2007

Hard drive performance in Ubuntu

The hard drive problem in Ubuntu systems is for real.
How do i know if I am affected ?
Step-1
Install smartmontools by doing "sudo apt-get install smartmontools"

Step-2
Type "sudo smartctl -d ata -a /dev/sda1 | grep Load_Cycle_Count " on your commandline.
I am assuming that your HDD device is /dev/sda
You should get an output like this:

193 Load_Cycle_Count 0x0032 001 001 000 Old_age Always - 262930

Do this again after about 5 mins. If you see a drastic change (> about 15) in the number "262930" (your number will be different), then you ARE AFFECTED!! And proceed ahead. If not .. stop here.

Rectifying the issue:


Step-3
Type "sudo hdparm -B 254 /dev/sda"
This sets the power management level of your HDD to 254. This is how the values are interpreted:
1 = aggressive power management = good battery life = most hard-drive load cycles = most hard drive wear and tear
255 = no power management = bad battery life = least HDD load cycles = least wear and tear (the hard drive is almost always on).

It turns out that by default, ubuntu does not "touch" the HDD power management, and it is set by the firmware to "128". Unfortunately, that still results in excessive load cycles on the hard drive (and so the constant "clicking" noise I would hear on my machine .. apparently it was my HDD head clicking into position and getting stacked away constantly!). I don't think that this is a problem with Ubuntu.

Step-4 making this a permanent solution
You can add the above to your /etc/profile file. It is a systemwide startup script.
Hope this helps.!

1 comment:

jakel said...

Hey Madhu! So you use linux eh? I'd like to start using it more. What version do you recommend for me if I wanted to run a small webserver? What version if I just want to dual boot and use it for personal use and software testing?

thx
-Jake