Posted by: The Chhamanator | March 6, 2008

Harddisk problem in Ubuntu

A bug report for Ubuntu Linux has confirmed that both the Feisty and Gutsy versions of Ubuntu as well as several other Linux distros cause some unnecessary wear and tear on a hard drive. The bug report reads:

Load/Unload refers to a device that controls the position of the sliders on a hard drive. If you think about a hard drive as an old fashioned record player, the platters of the hard drive would be the record, while the sliders on the hard drive would be the needle. The only difference here is that the sliders never actually make contact with the platters. Instead, an air current provided by the platters rotating keeps the slider and the platter apart by a precise distance known as the flying height. Significant damage to the disk could occur if the slider was in contact with the platter during a sudden jarring moment (like dropping your laptop). To provide a bit of safety in mobile applications (and in some cases desktop as well) load/unload technology was introduced. Essentially, there is a small device that moves the slider off the platter. When data needs to be accessed, the sliders position themselves back over the platters and make contact with them only once they’ve reached the proper rotational speed.

To apply what we’ve just learned, every harddrive has a life span, represented as load/unload cycles before the precisely machined tolerances in the drive begin to deteriorate. Somewhere along the line, the drives are being asked to spin down very frequently. These are factors controlled by a power management utility within the drive called Advanced Power Management, or apm, and are dictated by Ubuntu after boot-up. The problem is simply that the drives are spinning up and down too often, and the sliders are being forced to roll on and off the ramp where they’re stored when in off use, causing wear and tear on the slider assembly (not to mention the motor spinning the drive). Thus, your harddrive will be useless long before the supposed lifespan.

Symptoms of this bug are:
* Frequent HD clicks — more than one per 3 minutes while idle, louder than the typical access sounds. Often more than twice per minute. On some disks, the click is very quiet
* Rapidly Increasing Load_Cycle_Count as displayed in the final number in “sudo smartctl -a /dev/hda | grep Load_Cycle_Count” (where /dev/hda is replaced with your own hard disk device, you need to install smartmontools to run this command.)
* Early hard disk failure never stay parked, due to very frequent disk activity. Thus this cycle occurs often, thus wearing out the drive, and any comparative benefit is negligible (whereas, if the– some disks are cut down to less than a year of actual uptime.

The problem is only present due to the existence of *all three* of the following factors:
* Hardware is set (default or otherwise) to aggressive power management, causing heads to park. (default behaviour of many drives)
* Disk is touched often, causing heads to unpark. (default behaviour of many distributions)
* Drives are spec’d to a limited number of these cycles. (600,000 is the most common, although some may be spec’d higher or lower).

Reasonable Limits / Criteria for a fix:
* There should be fewer than ~15 load cycles per hour, except during heavy usage while on battery.
* This provides a life expectancy of over four years, which is reasonable for a hard disk.

The solution, as the original poster pointed out, is relatively simple:
sudo hdparm -B 255 /dev/sda
and the spinning-down stops. Since smartmontools aren’t installed by default in Ubuntu, it will be difficult to detect this symptom. To install smartmontools simply “sudo apt-get install smartmontools” from the console.

What does that command do? Let’s break it down.

sudo: You execute the command in super user mode.
hdparm: This is a linux command designed to fetch and set certain attributes of ATA/IDE hard drives.
-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. A value of 255 will disable apm on the drive.
and /dev/sda is obviously the disk drive in question.
A relatively simple fix for a somewhat complicated problem. The only issue here is that battery life will be adversely affected, however that’s better than having a hard drive that’s dead two years after you bought it.

TDB from launchpad provided the permanent solution to the problem as follows:

1) make a file named “99-hdd-spin-fix.sh”. The important thing is starting with “99”.
2) make sure the file contains the following 2 lines (fix it if you have PATA HDD):
#!/bin/sh
hdparm -B 255 /dev/sda
3) copy this file to 3 locations:
/etc/acpi/suspend.d/
/etc/acpi/resume.d/
/etc/acpi/start.d/

Source:

https://bugs.launchpad.net/ubuntu/+source/acpi-support/+bug/59695
http://www.linux-hero.com/rant/explanation-ubuntu-hard-drive-wear-and-tear

Advertisements

Responses

  1. IMHO this is not a Ubuntu specific issue, esp. not to call it a bug. This had been in Linux for long. Actually, hdparam was also there since ages and all one can say is that by default the IDE parameters are not fine-tuned in default linux distro. I had encountered this issue years ago (not remember, in which distro). May be other distros now have some default optimization (tune ups) but Ubuntu hasn’t done that. (I never checked if others do any tune up still or not) but once you have finally set up a distro and frozen hard disk (finally going to use it for long time) you should do the tune up as mentioned above.

    Interestingly, there is one more similar issue – if you wish to highly optimize disk access, you must pay very careful attention to partition scheme and geometry. e.g. swap area should be somewhere in the middle of geometry to minimize radial movement of head during mem swap operations, another one to watch is partition /var. Perhaps googling for this may yield interesting results.

    BTW, i came to your blog via some other article and I really liked it. esp. MNNIT related topics.

  2. Thanks for the compliment and for the insightful comment. Much appreciated.

  3. I seem to recall that this bug has actually been fixed about… halfway through Gutsy’s time as stable Ubuntu.

  4. sir ,i found it interesting ..great

    • thanks debug 🙂

  5. hello sir ..
    Can ypu post me how to install window XP in virtual box …
    i tried much but it gives error that “virtual box kernal driver” is not installed in the system .. i tried after that but i am not able to install XP ….
    thanks in advance …

  6. I don’t know about you guys, but since I tried Ubuntu I’ve lost (3)Three Hard Drives, and I don’t think that it is coincidence at all. What I did was: install it side by side with windows xp and that was it, I did not realize the problem until the third HDD. Too bad for me.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: