Matthew Garrett ([info]mjg59) wrote,
@ 2007-10-25 03:22:00
Previous Entry  Add to memories!  Tell a Friend  Next Entry
Entry tags:advogato, ubuntu

Linux-hero wrote about how Ubuntu kills your hard drive. 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.



(67 comments) - (Post a new comment)

Tag bug report
[info]puzzlement
2007-10-25 07:17 am UTC (link)
This entry probably won't show up on the aggregators you intend it to, because you've tagged it "advogato ubuntu" (one tag) rather than "advogato" and "ubuntu".

(Reply to this) (Thread)

Re: Tag bug report
[info]mjg59
2007-10-25 09:34 am UTC (link)
Wow, I suck. Or Livejournal's UI does, one or the other. Fixed, thanks.

(Reply to this) (Parent)(Thread)

Re: Tag bug report - [info]lionsphil, 2007-10-25 10:10 pm UTC
Re: Tag bug report - [info]kraig, 2007-10-29 07:38 pm UTC
Re: Tag bug report - [info]puzzlement, 2007-11-08 05:17 am UTC

(Reply from suspended user)
REDUCE your hdd lifespan?
[info]fragglet
2007-10-25 12:09 pm UTC (link)

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.

So it makes it worse?

(Reply to this) (Thread)

Re: REDUCE your hdd lifespan?
[info]mjg59
2007-10-25 12:18 pm UTC (link)
Yes, aggressive power management may result in a slightly lower life expectancy for your drive. That's one of the tradeoffs.

(Reply to this) (Parent)(Thread)

Re: REDUCE your hdd lifespan? - (Anonymous), 2007-10-25 05:35 pm UTC
Re: REDUCE your hdd lifespan? - [info]mjg59, 2007-10-26 08:55 am UTC
Re: REDUCE your hdd lifespan? - [info]anarchetic, 2007-10-29 11:43 pm UTC
Re: REDUCE your hdd lifespan? - [info]lionsphil, 2007-10-31 04:22 pm UTC
And Ubuntu pretends to correct the bug #1...
(Anonymous)
2007-10-25 02:16 pm UTC (link)
"There's certainly an argument that we should work around BIOSes, "

Microsofties themselves are always doing this sort of thing, buddy.
http://blogs.msdn.com/oldnewthing/archive/2003/08/28/54719.aspx

If you want to pretend Ubuntu is a desktop OS for the masses then you will have to do the dirty work involving working around hardware design stupidity. Ubuntu marketing is overrated and Windows is indeed a fine OS for the masses.

(Reply to this) (Thread)

Re: And Ubuntu pretends to correct the bug #1...
(Anonymous)
2007-10-25 03:59 pm UTC (link)
our assumption has been that your hardware manufacturer has a better idea what your computer is capable of than we do.

I like it a LOT more than

Microsofties themselves are always doing this sort of thing, buddy.

(Reply to this) (Parent)

Re: And Ubuntu pretends to correct the bug #1...
(Anonymous)
2007-10-25 05:48 pm UTC (link)
Windows is indeed a fine OS for masses of people who don't mind having their computer be a node in the storm supercomputer bot network.

That was a funny article to link to, given that it is about backwards compatibility with old hardware which is something that MS pretty much abandoned with Vista. Ubuntu supports more hardware than Windows (fact), and does it better (imho), and if you don't like their default configuration choices you can very easily change them yourself. And, you can try to convince them to change their defaults. I wonder what the windows equivalent of the hdparm command is... probably there are many commercial options which each perform a subset of its functions, and probably they don't come with detailed manuals like "man hdparm".

(Reply to this) (Parent)(Thread)

Re: And Ubuntu pretends to correct the bug #1... - [info]lionsphil, 2007-10-26 12:13 am UTC
Re: And Ubuntu pretends to correct the bug #1... - [info]mjg59, 2007-10-26 12:31 am UTC
Re: And Ubuntu pretends to correct the bug #1... - [info]lionsphil, 2007-10-26 09:21 am UTC
Re: And Ubuntu pretends to correct the bug #1... - [info]mjg59, 2007-10-26 11:45 pm UTC
Re: And Ubuntu pretends to correct the bug #1... - [info]anarchetic, 2007-10-29 11:51 pm UTC
Re: And Ubuntu pretends to correct the bug #1... - [info]lionsphil, 2007-10-31 04:18 pm UTC
Re: And Ubuntu pretends to correct the bug #1... - [info]anarchetic, 2007-10-31 10:25 pm UTC
Re: And Ubuntu pretends to correct the bug #1... - [info]lionsphil, 2007-10-31 10:48 pm UTC
Re: And Ubuntu pretends to correct the bug #1... - [info]anarchetic, 2007-10-31 10:59 pm UTC

(Reply from suspended user)
Helloooo, this is a critical bug and you are in denial
(Anonymous)
2007-10-25 09:45 pm UTC (link)
Please shut up about it being the BIOS's fault: Ubuntu screws your hard disk within months, Windows on THE SAME MACHINE does not. You must raise the priority of this bug as high as it takes to get it fixed. I have already gone back to suse.

(Reply to this) (Thread)

Re: Helloooo, this is a critical bug and you are in denial
[info]lionsphil
2007-10-25 10:56 pm UTC (link)
"Not our fault" is the standard mode of operation for Linux®-flavoured developers, because they live in a world of neat, modular boundaries and responsibilities.

The fact that pragmatism sometimes means that you have to do a Wrong Thing to actually work with the rest of the world sometimes escapes them. (Warning: completely unsubtle pointer to sore spot.)

In their defence, I am lead to believe that the kernel itself works around all kinds of stupid. Including brokenness in power mismanagement, which makes it odd that mjg is defending the "assume perfect BIOS" approach this time.

(Reply to this) (Parent)(Thread)

Re: Helloooo, this is a critical bug and you are in denial - [info]mjg59, 2007-10-26 12:21 am UTC
Re: Helloooo, this is a critical bug and you are in denial - [info]eode, 2007-10-31 01:53 am UTC
Re: Helloooo, this is a critical bug and you are in denial - (Anonymous), 2007-10-26 05:44 pm UTC
Re: Helloooo, this is a critical bug and you are in denial
[info]mjg59
2007-10-26 12:14 am UTC (link)
As far as I can tell, Suse doesn't do anything that would affect this either. If it happens in Ubuntu, it probably happens in Suse. If you can demonstrate otherwise, I'd be genuinely interested in working out why that's the case.

(Reply to this) (Parent)


[info]lionsphil
2007-10-25 10:06 pm UTC (link)
Should I be terrified to see a sleep 5 in there?

I hate the fact that "rat's nest of shell scripts" is the Linux® solution to almost anything.

(Reply to this) (Thread)


[info]mjg59
2007-10-26 12:15 am UTC (link)
No, it's to make it significantly less likely that we send IDE commands at the same time as the BIOS is doing so. If you have a magic solution for avoiding SMI screwing things without just disabling SMI, I'd be thrilled to hear it.

(Reply to this) (Parent)(Thread)

(no subject) - [info]lionsphil, 2007-10-26 12:24 am UTC
misconception
(Anonymous)
2007-10-26 08:33 am UTC (link)
You really don't understand it. The problem is not about manufacturers defaults nor changing the APM in Ubuntu. The defaults are good from notebook use view and leaving defaults settings can be ok.

The problem is that Ubuntu allows the disk "go to sleep" but right after that it "wakes it up". Constantly.

Instead it should sleep until some disk activity is needed.

On notebooks, you must solve the waking up and everything will be ok. Tweak some daemons, slow the flushing intervals, I don't know what. But *that problem* must be solved. And that *is* a problem in current Ubuntu.

(Reply to this) (Thread)

Re: misconception
[info]mjg59
2007-10-27 12:10 pm UTC (link)
Do you have any evidence at all that that's the case? We don't schedule multiple writeouts per second.

(Reply to this) (Parent)(Thread)

Re: misconception - (Anonymous), 2007-10-27 03:45 pm UTC
Re: misconception - [info]babbage, 2007-10-30 10:30 pm UTC
Re: misconception - [info]lionsphil, 2007-10-31 05:26 pm UTC
Re: misconception - [info]trs80 [typekey.com], 2007-11-01 04:55 am UTC
Re: misconception - [info]lionsphil, 2007-11-01 10:01 am UTC
Re: misconception - [info]trs80 [typekey.com], 2007-11-01 10:52 am UTC
Please help
(Anonymous)
2007-10-27 12:07 pm UTC (link)
I am using Ubuntu Gutsy on an IBM Thinkpad X20, which has due to its age an old pata drive. laptop-mode is disabled in /etc/default/acpi-support and I did "sudo hdparm -B 255 /dev/sda", too. I tried also values from 200 to 255. BUT: it is NOT working. This clicking sound is still there and smartctl reports also that "193 Load_Cycle_Count 0x0032 089 089 000 Old_age Always - 119875" is rising one or two counts per minute.
Note that this is not the disc shipped with the laptop. A new disc was built in, when I bought the refurbished laptop.

(Reply to this) (Thread)

Re: Please help
(Anonymous)
2007-10-27 12:10 pm UTC (link)
hmmm mysterious. with -B 230 it works and I don't know why.

(Reply to this) (Parent)(Thread)

Re: Please help - (Anonymous), 2007-10-30 02:24 pm UTC
Re: Please help - (Anonymous), 2007-10-30 08:08 pm UTC
Re: Please help - (Anonymous), 2007-11-01 07:42 pm UTC
Confused - worried!
(Anonymous)
2007-10-30 08:01 pm UTC (link)
Parent indicated that if ENBABLE_LAPTOP_MODE is set to false, then there's no issues.

I have false set and on first reading about this issue, I checked the cycle count.

It was averaging about 4 cycles a minute.

hdparm -B 255 /dev/hda

That fixed the problem, however...

What IS the normal load_cycle_count?

This is where my lack of knowledge leaves me cold.
I understand that the average laptop HD load cycle count is around 600000.
I understand that there's a problem when we have 4 counts a minute!

What I don't understand is how many it is normally *supposed* to be.

I await an official patch/response from Ubuntu, which I am sure will be arriving very soon ...

;)

(Reply to this) (Thread)

Re: Confused - worried!
(Anonymous)
2007-10-30 08:16 pm UTC (link)
My mistake.

In /etc/laptop-mode/laptop-mode.conf

ENABLE_LAPTOP_MODE_ON_BATTERY

was set to 1

... but ...

I'm on AC power and was still getting the high load_cycle_count ?

Setting that to 0 once again fixed the cycle count...

Confused again!

(Reply to this) (Parent)(Thread)

Re: Confused - worried! - (Anonymous), 2007-10-30 11:56 pm UTC
simple fix
(Anonymous)
2007-10-30 08:18 pm UTC (link)
cat /usr/local/bin/noloadunload.pl
#!/usr/bin/perl
use warnings;
use strict;
open(HDA, "/dev/hda") or open(HDA, "/dev/sda");

while (1) {
my $blok = rand() * 70000000000;
my $kupa;
seek HDA, $blok, "SEEK_SET";
read HDA, $kupa, 1024;
sleep 3;
}

(Reply to this) (Thread)

Re: simple fix
(Anonymous)
2007-10-31 09:15 am UTC (link)
Don't run this: it will overwrite your harddisk with random data.

(Reply to this) (Parent)

Re: simple fix - (Anonymous), 2007-10-31 01:43 pm UTC
Re: simple fix - (Anonymous), 2007-11-09 01:44 pm UTC
lawl - [info]madfire, 2007-11-09 09:47 pm UTC
Interesting fact
(Anonymous)
2007-10-31 02:23 pm UTC (link)
I have a IBM Thinkpad Z60m Laptop. It's about 1.5 years old. I used dapper, edgy, feisty on this laptop. Now I'm under gutsy gibbon. I wiped my hdd before each installation.
Now according to smartctl I have Power_On_Hours = 5628, and Load_Cycle_Count = 196651. That gives me 196651/5628 = 34.94 per hour at average. But now I estimate my Load_Cycle_Count growth as ~200-300 cycles per hour. Note this is much above average. Is there something wrong with my calculations?
I run my latop on ac power 99.5% of the time, my laptop_mode is turned off.

HDD: TOSHIBA MK1032GSX

Something changed in these 1.5 years. I don't know what.

Best regards, Alex

(Reply to this) (Thread)

Re: Interesting fact
[info]mjg59
2007-10-31 02:42 pm UTC (link)
Bear in mind that the raw values do not necessarily correspond to reality in any interesting way - an increase of 1 in power_on_hours is not required to indicate that the drive has been on for an hour, and an increase of a certain amount in the load_cycle_count is not necessarily that many cycles. It's up to the firmware of the drive to interpret that.

As for what's changed - nothing. Different usage patterns will result in the rate increasing differently, and it's quite possible that you're currently doing something that increases the rate at which they're generated. Our investigation strongly suggests that MacOS and Windows go through similar bursts but have an average rate similar to ours.

(Reply to this) (Parent)


[info]landley
2007-10-31 04:45 pm UTC (link)
> 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.

I have one of those Dell laptops that came preinstalled with Ubuntu 7.04. I've had it less than a year, still running the default OS image (and even the same kernel if clicking the upgrade widget hasn't replaced it), and my Load_Cycle_Count is 195422. At 1076 Power_On_Hours (which sounds about
right), that's 181 per hour, or one every 20 seconds.

> 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.

I bought this thing from Dell, and left it running on Dell's defaults. Unfortunately, I'm not sure Dell even pretends to know anything about inside of the rebadged Quanta laptops it sells. Maybe Matt Domsch would know...

(Reply to this)


(Anonymous)
2007-10-31 11:09 pm UTC (link)
Hmm!

sudo smartctl -d ata -a /dev/sda has reported that my HDD is nearly 70 years old!!!

9 Power_On_Hours 0x0032 099 099 000 Old_age Always - 607333

(Reply to this)


[info]mattcaron
2007-11-01 01:04 pm UTC (link)
For what it's worth, my Load Count is perfectly reasonable

ENABLE_LAPTOP_MODE is true, all other HDD related stuff is defaults (I needed to use laptop mode to cap the CPU speed so the damned thing would stop overheating. This happens in both Linux and Windows, so no fault there).
193 Load_Cycle_Count        0x0012   060   060   000    Old_age   Always  -  600690

This means there have been 3 cycles in 24 hours, and this includes a suspend to ram action last night when I went to bed, plus 2 more as the laptop sat idle for several hours. Also, the laptop is 3 years old, so all of this seems reasonable to me.

Hardware:
=== START OF INFORMATION SECTION ===
Model Family:     Hitachi Travelstar 7K60
Device Model:     HTS726060M9AT00
Serial Number:    MRH403M4GA7RHB
Firmware Version: MH4OA6BA
User Capacity:    60,011,642,880 bytes
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   6
ATA Standard is:  ATA/ATAPI-6 T13 1410D revision 3a
Local Time is:    Thu Nov  1 09:03:54 2007 EDT
SMART support is: Available - device has SMART capability.
SMART support is: Enabled


On a Thinkpad r50p.

(Reply to this)

Wrong assumption
(Anonymous)
2008-05-12 05:21 pm UTC (link)
Hi,

"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."

The laptop manufacturer expects the OS to minimize disk access. That means that if Ubuntu is not willing to enable laptop-mode, it MUST DISABLE APM. This is really important, and IMO obvious. It is WRONG to let a drive sit at APM=128 when not using laptop_mode. Just how is it going to save any power ?? Power comes from parking/spinning down, and that is not going to happen with standard kernel settings (flush every 5 seconds).

This is definitely something Ubuntu must manage, the hardware defaults are assuming the OS is not going to thrash every 5 seconds!

(Reply to this)

Hello I'm new here
(Anonymous)
2008-07-29 11:19 pm UTC (link)
I've recently joined and wanted to introduce myself :)

(Reply to this)

XFyRdmVvbcPTCVxfjMc
(Anonymous)
2008-08-04 05:49 am UTC (link)
far.txt;3;3

(Reply to this)

Thanks!
[info]deep_endolith
2008-11-12 10:27 pm UTC (link)
the basic takeaway message is that Ubuntu doesn't touch your hard drive power management settings by default

In other words: Ubuntu (and only Ubuntu) is killing your hard drive.

Mine went past 1 million load cycles before I found out about this bug. It typically cycles over 250 times per minute.

I've confirmed that it doesn't do this in Windows XP, but does in Intrepid (despite the "Fix Released" on Launchpad).

Yet all I see is denial and "not our fault". You're killing users' hardware! Take some responsibility and make sure it's fixed. I don't understand why this isn't a top priority.

(Reply to this) (Thread)

Re: Thanks!
[info]deep_endolith
2008-11-12 10:32 pm UTC (link)
250 times per hour, that is. :)

(Reply to this) (Parent)

RdqwOURYNqtZJA
(Anonymous)
2008-11-20 12:43 pm UTC (link)
comment5,

(Reply to this)

easy fix:
(Anonymous)
2009-01-18 03:48 am UTC (link)
buy an SSD. :)

(Reply to this)


(67 comments) - (Post a new comment)

Create an Account
Forgot your login or password?
Login w/ OpenID
English • Español • Deutsch • Русский…