Explanation of Ubuntu Hard Drive Wear and Tear

EDIT:  This problem seems to be limited to laptop mode.  Read This if you want to see how to tell if you're affected. 

 

A recent bug report for Ubuntu Linux has confirmed that both the Feisty and Gutsy versions of Ubuntu cause some unnecessary wear and tear on a hard drive. The bug report reads:
“I run feisty (beta) on a Dell Inspiron 9400 with a Hitachi HTS541616J9SA00 hard drive. After booting, the drive's power management settings are such that it spins down A LOT. To give you some statistics: the drive is rated for 600,000 load/unload cycles, and after 2.5 months of running Feisty I'm already at more than 56,000 load/unload cycles (and only 150 power cycles), according to the SMART data. At this rate the drive will be dead after 2.5 years, and I don't even use this computer for more than a couple of hours each day.”
Definitely an interesting sounding find. But what exactly does it mean? That's what I thought when I read it, so I did a little research. Feel free to comment and correct me if I've gotten anything wrong.
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, the drive reported has a life span of 600,000 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).
The solution, as the original poster pointed out, is relatively simple:
“The fix?
hdparm -B 255 /dev/sda
and the spinning-down stops. I don't know what certain other OSes do with their drives at bootup, but the current behaviour is certainly deadly for the drive. Worse: nobody will notice, since smartmontools aren't installed by default. I noticed frequent clicking sounds earlier, but I didn't think those were spindowns since I hadn't specifically set the drive into any low-power mode. I only noticed this by accident after I got smartmontools working.”
What does that command do? Let’s break it down.
hdparm: This is a linux command designed to fetch and set certain attributes of ATA/IDE hard drives.
The -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. It will be interesting to see how the Ubuntu team decides to handle this. As of yet, the trouble ticket is unassigned.


Technorati Tags:

Thank you for the solution

Thank you for finding a solution to save our hard drives , I hope this will be fixed in next ubuntu

Two quick questions: (1)

Two quick questions: (1) does this affect desktops too? or only laptops w/ power saving turned on? wasn't clear from your post... (2) how do you make the fix permanent? I'm not that familiar with the commandline to know whether or not your solution gets wiped out everytime you reboot...

Why does it spin up so often ?

Have you considered, why does it spin up so often ?
With laptops, if there is no user activity, is it really important to wake up writing to disk ?
I know there are daemons running around and file atimes have to be updated and file systems have to be synced, but has anyone sat down and thought, if they are really important for laptop users ? Or could we for example put the noatime option as default, suspend some daemons and increase the interval of writing dirty buffers to disk, when there is no user activity?

esd,pulseaudio,arts,jackd?

then all daemons and buffers cleaned?what about ur sound server(s)?or font server like xfs?

the default value of the APM ?

I read that the solution is to set the APM to 255, meaning that no power management used at all.
But what is the default value set by Ubuntu if somehow i want to revert back ?

Default Setting

Running Ubuntu 7.04 (Feisty Fawn) with all current updates:

sudo hdparm -I /dev/sda
...
Advanced power management level: 128 (0x80)
...

solution doesn't work?

maybe it doesn't work for all drives?

$ sudo hdparm -B255 /dev/sda

/dev/sda:
setting Advanced Power Management level to disabled
HDIO_DRIVE_CMD failed: Input/output error

I had to run: sudo smartctl

I had to run:
sudo smartctl -d ata -a /dev/sda
As far as I can tell its something to do with a change in a library and the smartctl in Ubuntu not being/having the fix yet.

Maybe you don't have a

Maybe you don't have a serial-ATA hard drive... try sudo hdparm -B255 /dev/hda

I so reported this bug ages ago

It's true... and I reported a "strain" of this bug at the beginning of September just as Gutsy was being run through final tests. No one has ever changed the status on the bug-ticket, neither has anything more been said about it. I noticed it on my Dell notebook, and reported the findings immediately...

Bug-report can be found here:
https://bugs.launchpad.net/ubuntu/+bug/137420

It most definitely needs a more solid solution. On a notebook you hear it going on and off constantly and you can just sit and count all those spin-up spin-down cycles winding towards your hard drives ultimate destruction. Hmm.

limited to just Ubuntu?

Is this issue truly limited to just Ubuntu? What about other flavors like Fedora, Slackware or Suse? If it has been claimed that it's a BIOS/firmware related issue, and there is significant evidence to back it, maybe you should clean up the article -- or at least the title.

Honestly, I read this article because it mentioned an issue regarding Ubuntu. Since it's been DUGG, you'll probably get a number of readers that have no idea where the issue stems from, but they sure remember reading that this particular flavor of Linux has a problem. Validated or not.

Are you attempting to provoke thought, or scare away potential converts?

This problem is not limited

This problem is not limited to just Ubuntu. I'm using gentoo, with the laptop-mode utilities installed. And had I not changed the configuration file, the default value for hdparm -B when running on battery is 1.

Part of the issue stems from the question of what a good value is. That's a highly subjective matter. Windows has a similar setting in its power preferences, where you can set how long the drive takes to spin down. The only real difference between these two is their default settings.

The fix is quite easy. While it's more of a setting preference than a fix, but perhaps a better default value would be welcomed.

Very useful, thanks.

Very useful, thanks.

Probably not just Linux, eh?

I imagine I am harder on my laptops than a lot of people, and I tend to by real cheap ones as well, but 2.5 years sounds like a great life time for a laptop drive based on my experience. That said, I've only been running Ubuntu for a few months now, and it was Windows 2K-XP before that, so I am going to to waaaaay out on a limb and claim that at least Windows does something similar. In fact, I would lay good money on the harsh setting when the laptop is unplugged.

Coming from another angle, you will find that it is difficult at best to get drive life specs from laptop vendors, but battery life is usually right near the top of all the marketing bullet points. So, laptop and OS vendors have a mutual interest in beating on the drives in favor of power consumption since not only does long battery life help sell more of their product from a marketing standpoint, but dead drives help sell them from a product replacement standpoint. Most of the laptop users I know will replace the whole thing if the drive dies since they don't even know it can be replaced.

Anyway, I think the harshest setting makes complete sense when unplugged, especially considering the lower risk of damage due to impact, but all that Ubuntu is missing in this case is a modification of this parameter, and several others like it, when the laptop is plugged in. Windows has had this feature set for years, and it should be trivial for Ubuntu/Linux folks to add it to the existing battery/power monitoring utility. Heck, for all I know, it is already in there. Anyone have the fu to check that?

Whoops! see "The Situation is somewhat" below

Somehow I missed the comment below from some one who appears to be involved with Ubuntu. He/she mostly address my question about modifying such parameters on plug and unplug. (A nice gui for all this would be ideal in the long term, but I'm sure there are other priorities.)

I hope the rest of my comments are useful to some anyway.

I have seen this behaviour

I have seen this behaviour on all Dell laptops we have bought recently (Latitude D630/D830), and it is present in Windows XP as well. A fix is to add sth. like

/dev/sda {
apm 254
}

to /etc/hdparm.conf and to add a startup link with

sudo ln -s /etc/init.d/hdparm /etc/rcS.d/S07hdparm

then what about latest kernel drivers(libata)

with kernel 2.6.19 onwards libata merged pata.and distros like ubuntu enabled old pata drivers for detection.hdparm works with sata too OK>but some CD/DVD drives have problem with new drivers,for eg enabling DMA.
my que-will the new libata drivers for sata fixes the @OP's issue?
thx.

Could this also happen on a Macbook Pro?

I have an Apple Macbook Pro and I upgraded the drive to 160gb "Momentus Seagate" drive.
Now I can hear a noise like the heads parking every few mins, I have checked the OSX power setting and disabled the option to shut down the drives when possible but still i hear the noise.

After reading this I would like to check my drive. Could I check this with the SMARTmon tools on a mac, in VMware running XP for example?

The smartmontools man-page

The smartmontools man-page mentions something about working in Darwin (OSX).

http://smartmontools.sourceforge.net

Could I check this with the

Could I check this with the SMARTmon tools on a mac, in VMware running XP for example?

Nope, that would only check the virtual machines harddrive. OS X should have some utilities, and I wouldn't be the least surprised if you found hdparm after firing up a terminal.

But I'm not sure since i don't (yet) own a Mac.

Naming

Y'know, it'd be less offensive to call anonymous users "AnonymousCoward" if it was actually possible for people to put their real name in when submitting a comment. All I've got are subject and comment boxes, no box for the name.

AnonymousCoward sounds like

AnonymousCoward sounds like homage to slashdot. Don't worry about it. It just sounds normal.

...and fixed!

Let me know if you have any other ideas about how I can improve the site.

 

Thanks for reading!

 

Brian

SMART

Just cause SMART says you have X number of powercycles, doesn't mean your hard-drive is gonna fail as soon as that number is reached...

Point Taken

Like I said earlier, this site is really new.  I'll try and make the changes tonite.

 Thanks for reading!

 

brian

The situation is somewhat

The situation is somewhat less clear than you might think from the article, but the basic takeaway message is that Ubuntu doesn't touch your hard drive power management settings by default. In almost all cases, it's more likely to be your BIOS or the firmware on your hard drive.

The script that's executed when you plug or unplug your laptop is /etc/acpi/power.sh. The relevant sections are:

function laptop_mode_enable {
...
$HDPARM -S $SPINDOWN_TIME /dev/$drive 2>/dev/null
$HDPARM -B 1 /dev/$drive 2>/dev/null
}

That is, when the laptop_mode_enable function is called, we set the drive power parameters. Now, by default laptop_mode_enable isn't called:

if [ x$ENABLE_LAPTOP_MODE = xtrue ]; then
(sleep 5 && laptop_mode_enable)&
fi

because ENABLE_LAPTOP_MODE is false in the default install (check /etc/default/acpi-support). This means that, by default, we do not alter the hard drive power settings. In other words, the APM settings that your drive is using in Ubuntu are the ones that your BIOS programmed into it when the computer started. This is supported by the fact that people see this issue after resuming from suspend. We don't touch the hard drive settings at that point, so the only way it can occur is if your BIOS or drive default to this behaviour.

If you enable laptop mode, then we will enable aggressive power management on the drive and that may lead to some reduction in hard drive lifespan. That's a fairly inevitable consequence of laptop mode, since it only makes sense if the laptop enages in aggressive power management. But, as I said, that's not the default behaviour of Ubuntu.

There's certainly an argument that we should work around BIOSes, but in general our assumption has been that your hardware manufacturer has a better idea what your computer is capable of than we do. If a laptop manufacturer configures your drive to save power at the cost of life expectancy, then that's probably something you should ask your laptop manufacturer about.

FUD

I appreciate that there are people looking out for the bulk of us who don't check our hdparms, SMARTconfig, etc.

However it seems that this is just looking for publicity as the correct way to address this is using one of the many established ways of communicating with the ubuntu maintainers and development crew. Such ways include: email, bug reports, mailing lists, forums, etc.

Please use the proper channels FIRST and THEN whip out the soapbox.

Thank you and drive-thru.

Well, might be fud in your

Well, might be fud in your opinion.
The thing is that was a KNOWN bug and nothing was done.

And also Ive done in my laptop and the "clickings" really went down considerably.

another script affecting spindown

Hi,
There is also script /etc/apm/event.d/20hdparm. This script also sets the spin-down timeout by calling hdpadm -S

The behavior is controled by the APMD_DRIVES and APMD_SPINDOWN variables. So, check it out.

0x100

Sliders?

I've never heard of heads in a hard drive referred to as "sliders".

Comments are now enabled

Sorry if anyone has been trying to post a comment and have been unable to.  This site is pretty new, and I hadn't installed the keys for reCaptcha yet.  I've fixed the problem.

Thanks for all the comments on digg.com! 

brian

aka

root

SATA Raid Controller

What if your drives are connected via raid controller and presented as a LUN? Does this bug still affect your drives?

This problem has been around

This problem has been around since as long as I can remember on laptop with a Hitachi drive. My laptop is fine for the first hour is so after it's booted but after that it begins parking straight away after every read or write operation, increasing initial seek time to something like 50 - 75ms and destroying the drive.

The fact it only happened about 1 hour after it booted made me think it was a Linux problem, but if Linux doesn't touch the drive's APM settings it must be a firmware issue.

Still, I wrote a script ages ago to fix it.

I have this problem too

I have this same problem. I disabled powermanagemnt in the bios, did $sudo hdparm -B255 /dev/sda1 and $sudo hdparm -S0 /dev/sda1 and none of these worked. I am still getting 5 spins per minute.

I have no idea where to go from here. No changes to the -B or -S switches made any difference, not even in reducing the number of spins. Smartctl reports my drive as pre-fail on two options and old-age on everything else.

I don't hear that much activity with the drive (maybe just quiet?), so I almost wonder if the smartctl software is mis-reporting the information in the raw data column of output.

For anyone reading this, you can get a vendor specific readout by doing: $sudo smartctl -A /dev/sda.

Replace sda with your drive name.

If smartctl doesn't seem to recognize your drive try the -d ata switch: $sudo smartctl -d ata -A /dev/sda.

I am using Kubuntu Feisty on a dell latitude c610 laptop.

don't worry

Pre-fail and Old_age don't mean your drive is in pre-fail state! It's only true if the normalized value is less than threshold.

here's a excerpt from smartctl man page:

"TYPE" of the Attribute. Attributes are one of two possible types: Pre-failure or Old age. Pre-failure Attributes are ones which, if less than or equal to their threshold values, indicate pending disk failure. Old age, or usage Attributes, are ones which indicate end-of-product life from old-age or normal aging and wearout, if the Attribute value is less than or equal to the threshold. Please note: the fact that an Attribute is of type ’Pre-fail’ does not mean that your disk is about to fail! It only has this meaning if the Attribute´s current Normalized value is less than or equal to the threshold value.

> I did $sudo hdparm -B255

> I did $sudo hdparm -B255 /dev/sda1 and $sudo hdparm -S0 /dev/sda1

Have you tried using /dev/sda instead of /dev/sda1?

try using "sudo hdparm -B

try using "sudo hdparm -B 254 /dev/sda"
to check what value u catually have run "sudo hdparm -I /dev/sda | grep power"
form me 255 doenst work and 254 works (dell 1501 laptop)

Ubuntu harddrive killer all bogus FUD

I'm not sure I believe the "bug" that has been filed regarding the laptop drive load/unload cycle count. (#59695 in acpi-support listed on launchpad.net)
To date, it appears to be unfounded and unsupported by anyone of note. I think the following document from Hitachi paints load/unload cycles in a positive light and is worth reading:
http://www.hitachigst.com/tech/techlib.nsf/techdocs/9076679E3EE4003E86256FAB005825FB/$file/LoadUnload_white_paper_FINAL.pdf

My final point is this: if this were truly a problem, wouldn't this be in the best interest of the harddrive manufacturers to either make a change with their hardware operation -or- pressure BIOS vendors to make a change in theirs to prevent this from happening? The answer to this is an unqualified 'yes'. The hardware manufacturers would be replacing people's harddrives still under warranty for failing in such a short time....all for free. Definitely not in their best interest.

I suspect the smartctl command either displays load/unload values incorrectly or the value it reports is being mis-interpreted.

That is an informative

That is an informative article about the technology. Still I worry about my drive. I racked up 125021 load cycles in 2 months. Even if my drive makes a million load cycles thats less than a year and a half. I guess it will still be under warranty then.

Some people have asked why peoples hardrives are not breaking right and left due to this but I remember hearing that hardrive failure is the most common reason for computers to go in for repair. Maybe its just how the industry works.

Hard Disk Crashes

Well, actually.
Since I have switched to linux (10 years ago) I have experienced 5 or 6 hard disk crashes. This on my main system. Over the years I have tried multiple hard disk vendors and my computers are used for normal day-to-day usage. So no server function. My computer runs between 4 to 12 hours each day.
Every possible cause has been checked (cooling, vendors, fysical stability, ... ). This is a normal home computer.
Still all my disks crash after a little over 2 years (always too late for waranty).
I don't know if this is normal. It doesn't feel normal.
This article "feels" related even though this is a desktop computer. I can certainly relate to the ticking sound. :-/
I will now check on the "loadcycle" in smartmon tools, it's a path i haven't checked before.

I think you must have been

I think you must have been unlucky with the disks.

I myself typically had my disk working for a little less than 3 years running windows only, and they tended to break down prior to my warranty would expire - have had some luck there I guess :)

The last 7 years however, I have only had one hard drive die on me - that is it even did not die fully, but I replaced it anyway - it was my external backup disk. My Dell laptop disk are still going strong on its 5 year running Gentoo Linux almost exclusively! I had it on virtually 24/7 keeping it on as a local server too. The sound card have failed, so has the firewire, and it has only USB version 1.1 so I have now mostly replaced it just before Christmas.

I in fact was surprised the disk did outlast my need for once - mostly all of my previous laptops have had disk failures between 2 and 3 years after buying them, this one did not, but is the first I ran close to exclusive Linux on. What I want to say is that lifespan of laptop disks in my experience tend to be poor, and does not seem related with OS.

thanks a lot for this. i

thanks a lot for this. i have a brand new dell m1330 and was going to switch back to vista if i couldn't fix that clicking.