LWN.net Logo

Advertisement

Front, Kernel, Security, Distributions, Development. See your byline here on LWN.net.

Advertise here

Laptops, power management, and Ubuntu

Laptops, power management, and Ubuntu

Posted Nov 8, 2007 14:28 UTC (Thu) by kevinbsmith (guest, #4778)
Parent article: Laptops, power management, and Ubuntu

Thanks for a great article! We really needed some objective, level-headed, fact-based
information about this. My 2-year old Ubuntu-from-birth laptop is affected (1.2 million
cycles), and the fixes mentioned in the thread didn't help. The linked wiki page is a sad
jumble of incomplete suggestions, as of this moment.

This article was the first place I have seen that explained that none of the fixes (hdparm)
would have any effect unless laptop mode was on. Other posts had led me to believe that I was
better off with laptop mode off.

I wish it had gone a little farther, though:

How can I tell if I am in laptop mode or not? First I had to find the laptop_mode FAQ page
(http://www.samwel.tk/laptop_mode/faq), which says "cat /proc/sys/vm/laptop_mode. If it
contains a nonzero value, then laptop mode is enabled, if it says 0, then it isn't." Ok, I'm
not in laptop mode.

How can I turn on laptop mode? It looks like the answer is in "man laptop-mode.conf".

Then there are several different suggestions (on that wiki page, in the launchpad thread, and
in various blogs) for how to ensure the spin-down settings persist across reboots, and in both
AC and Battery mode. How should one decide which method to use? Are some better than others?
Can I just change laptop-mode.conf can nothing else? Will all of approaches work on any
system? Should I just choose one at random?

Are there any distros that are *not* affected? If so, we might learn something from them. Are
there any "reasonable" changes that Ubuntu and others should make right away? Should they at
least notify users during install that further user action is required to avoid destroying
hardware?

Finally, how would one enable relatime? Since the lwn article in August, has there been more
research into what problems it might cause? This one probably deserves its own follow-up
article, since Fedora has decided to set it as the default.



(Log in to post comments)

Laptops, power management, and Ubuntu

Posted Nov 8, 2007 16:36 UTC (Thu) by kevinbsmith (guest, #4778) [Link]

(Replying to self)

The answer for how to enable laptop mode is not in "man laptop-mode.conf". I fiddled with
that, and tried to run /etc/init.d/laptop_mode, and tried to run laptop_mode init. 

laptop_mode status says "Laptop Mode is NOT allowed to run: /var/run/laptop-mode-enabled does
not exist."

running sudo laptop_mode gives the unhelpful and contradictory:
state:      closed
yes
Laptop mode disabled, active.

So even though cat /proc/sys/vm/laptop_mode says I'm in laptop mode (2), my cycle count
continues to increase at a rate of one/minute.

Laptops, power management, and Ubuntu

Posted Nov 8, 2007 23:47 UTC (Thu) by jwb (guest, #15467) [Link]

> state:      closed
> yes
> Laptop mode disabled, active.

That is hilarious.  Laptop mode has always been a questionable hack, at least the one shipped
by Ubuntu.  At one point Ubuntu was shipping both laptop_mode and laptop_mode_tools, which
were contradictory even though their packages didn't claim to conflict.  On my PowerBook
(where the brilliant firmware cannot be blamed) laptop mode would spin my disk down after *1
second* of inactivity.  No joke.  Then the disk would spin up again right away.  The drain on
the battery was tremendous.  I had to purge laptop_mode (or was it laptop_mode_tools) and
reboot the machine to make it stop doing that.

Laptops, power management, and Ubuntu

Posted Nov 13, 2007 10:39 UTC (Tue) by mdz@debian.org (subscriber, #14112) [Link]

Ubuntu has not shipped laptop-mode, ever.  It has never even entered the main repository.

Of course, you are welcome to install arbitrary packages from universe and tweak them to suit
your needs, but you must also take responsibility for the results.

Laptops, power management, and Ubuntu

Posted Nov 13, 2007 15:42 UTC (Tue) by jwb (guest, #15467) [Link]

Ubuntu shipped laptop-mode in the "main" component (aka the official, supported component) in
Warty, Hoary, and Breezy.  That's three times, not "never" as you say.

Laptops, power management, and Ubuntu

Posted Nov 13, 2007 16:02 UTC (Tue) by mdz@debian.org (subscriber, #14112) [Link]

You're right, I didn't look back that far (over two years now).  That laptop-mode is an
Ubuntu-specific tool which is long obsolete and will be removed from universe as well.

In any case, it was removed from main when laptop-mode-tools was added (in 6.06), so it
remains true that Ubuntu did not in fact ship them both.

Laptops, power management, and Ubuntu

Posted Nov 13, 2007 10:35 UTC (Tue) by mdz@debian.org (subscriber, #14112) [Link]

You don't actually want laptop mode enabled unless you've made a great effort to optimize the
rest of the system to make it useful (that's why it's disabled by default).  Enabling it will
just result in the disk spinning up and down a lot, which is what most people investigating
this issue want to avoid.

Laptops, power management, and Ubuntu

Posted Nov 13, 2007 15:14 UTC (Tue) by kevinbsmith (guest, #4778) [Link]

Actually, my 2-year old laptop had Ubuntu pre-installed. I have never even heard of
laptop-mode until last month, so it was never enabled. And yet my drive has 1.2 million
cycles. 

So your post continues to add to my confusion, and offers yet another suggestion ("remove
laptop mode") that won't solve the problem for me.

As for your other post at 10:39:

   Of course, you are welcome to install arbitrary packages from 
   universe and tweak them to suit your needs, but you must also 
   take responsibility for the results.

More invalid blame of the user. I didn't install what you think I installed, thank you very
much.

1255838 cycles and counting. Still increasing at 5000 per day. Sigh.

Laptops, power management, and Ubuntu

Posted Nov 13, 2007 15:21 UTC (Tue) by mdz@debian.org (subscriber, #14112) [Link]

Don't be silly; reread the comments I was responding to.  I addressed two points:

1. That Ubuntu provided two conflicting tools for enabling laptop mode (it hasn't)

2. That enabling laptop mode would be a good way to prevent a high number of load/unload
cycles (it isn't)

I didn't suggest that you remove the tools for laptop-mode, though I did recommend against
enabling it.

If you want to set default power management settings for your disk in Ubuntu, /etc/hdparm.conf
is probably the best way to go about it.

Laptops, power management, and Ubuntu

Posted Nov 13, 2007 17:15 UTC (Tue) by kevinbsmith (guest, #4778) [Link]

I apologize for misunderstanding which of the two laptop modes you were talking about. Still,
it's clear that neither is causing my problems. And other folks have suggested that enabling
laptop mode (with appropriate settings) is a way to solve the problem. (Some folks say the
hdparm -B setting is ignored if you are not in laptop mode).

I appreciate the pointer to /etc/hdparm.conf. It's not mentioned on Ubuntu's wiki page, and I
don't remember seeing it anywhere else. I just added this to mine:

/dev/sda {
        apm = 254
        spindown_time = 240
}


Unfortunately, I can't find any way to confirm that I added it correctly. I have no idea
whether those commands are in effect or not. I rebooted.

But my cycle count continues to increase by 4/minute, so it hasn't solved my problem.

I also checked my BIOS, and there are no settings there to control how the hard drive behaves.
And I re-ran hdparm directly (-B 254 and -S 240), and my cycle count continues to increase at
the same rate.


Laptops, power management, and Ubuntu

Posted Nov 23, 2007 19:52 UTC (Fri) by kevinbsmith (guest, #4778) [Link]

Quick update, in case it helps someone else. It seems that my Samsung drive ignores hdparm
settings unless you first do:

  sudo smartctl -o on /dev/sda

Don't ask me why. It makes no sense. But it worked. My load cycle count has finally stopped
increasing. At this point, my drive seems to be ignoring the hdparm -B parameters (stuck at
128 according to hdparm -I), but seems to be paying attention to -S (not fully confirmed).
When I suspended for 10 minutes, my load cycle went up by exactly one, which is a good sign.

Here is my forum post (basically what I just said here):
  http://ubuntuforums.org/showpost.php?p=3825166&postco...

At this point, I suspect that if I can get my system to stop accessing the drives every few
seconds, the heads will park when idle, as they should. Next quest: Find a good guide to how
to configure relatime. Why is that so hard to find?

Laptops, power management, and Ubuntu

Posted Nov 8, 2007 16:58 UTC (Thu) by tialaramex (subscriber, #21167) [Link]

You haven't understood the article at all.

You need not be using laptop mode to see high load / unload count. Without laptop mode your
disk uses the manufacturer's power on setttings, and if those include aggressive APM then you
may see an increasing count in this SMART old age parameter as a result.

Ubuntu (and everyone else) are just pointing out that unless you enable laptop mode their
software isn't touching these settings at all, and therefore any responsibility for the
settings must lie with the disk manufacturer.

As to whether you're "better off" with or without laptop mode, that depends what you want to
achieve. If one or the other option was just "better" then obviously it would always be set
that way.

If your hard disk dies within the warranty period, demand a replacement. If it doesn't, what
are you worrying about? And meanwhile remember to take regular backups. All good advice
without the hysteria about a SMART parameter that's not intended for end users to look at.

Laptops, power management, and Ubuntu

Posted Nov 8, 2007 19:29 UTC (Thu) by kevinbsmith (guest, #4778) [Link]

Unforunately, this is the kind of user-hostile response that is common in the other blog posts
and threads. Paraphrasing: "Your hard drive might die. Tough. Not our fault." 

I'm about a year or two out of warranty. If my drive dies for preventable reasons, I will
still be disappointed and annoyed. Should I not be "worried" about the expense, downtime, and
possible loss of even a few hours of work?

The point isn't to find blame. The point is to 

a) figure out what *I* can do to save my drive (or at this point maybe what I can do to save
the replacement drive I'll have to buy), and then 

b) figure out what distros could do to let other folks know that they need to do something to
save their drives, and then 

c) figure out if there is something distros can do to avoid the problem (even though the root
cause may be the drive and/or BIOS settings).

I have read that MS Windows overrides the disk and/or BIOS settings to avoid, or at least
minimize this problem. From a technical purist standpoint, It may be annoying to have to do
this, but sometimes such impurities are the least-bad option.

Real people are going to have to spend real money replacing real hardware. Let's try to
minimize that cost (and landfill usage), shall we?

Laptops, power management, and Ubuntu

Posted Nov 9, 2007 16:08 UTC (Fri) by lorien420 (guest, #44036) [Link]

I've never read these comments as user-hostile. The distro saying we won't touch these
settings isn't telling you they don't care, it's saying that it doesn't seem like something we
should do. Maybe if they find the magic number that everybody loves this won't be a problem.
Right now they have the people with dying laptop hard drives screaming at them. If they tweak
the number, maybe it will silence those people but anger some other user? Maybe the number
they pick will be wrong and instantly kill the hard drive? The right answer isn't clear, which
is why they're falling back on, "We won't touch it unless you explicitly tell it to."

Laptops, power management, and Ubuntu

Posted Nov 9, 2007 18:19 UTC (Fri) by kevinbsmith (guest, #4778) [Link]

Let's look at the two issues seperately.

As far as I can tell, none of the distros have offered any official advice about how to deal
with this problem. That is a "we don't care" attitude. If the distros won't help, who will?
The minimum I would find acceptable is to advise users that there may be a problem, and
suggest possible things the user can do to mitigate. 

If you can point me to anything like that, please do. I have not yet found any official (or
unofficial) step-by-step instructions for things to try. Vague advice like "use hdparm" or
"turn on laptop mode" don't count.

It would be even better if they could find a way to "fix" it in software.

The comment posted above was, in my opinion, hostile to users. Notably: "If your hard disk
dies within the warranty period, demand a replacement. If it doesn't, what are you worrying
about?" Other forum posts elsewhere have been even worse.

There *is* a problem. We as a community *need* to find a solution. As I said, that might just
be providing step-by-step instructions so each user can manually tweak their machine to their
own preferences. And letting folks know they need to do that to avoid losing their drives. We
don't even have that yet.

Laptops, power management, and Ubuntu

Posted Nov 9, 2007 19:17 UTC (Fri) by lorien420 (guest, #44036) [Link]

While we may disagree on the "user-hostility" idea, I think you're definitely right that
people need to be informed about potential problems like this no matter whose fault it really
is.

Actually, I would say that's a general problem. As a community we have lots of resources to
find out about the problems and do our own sifting for solutions, but it seems like this
process is sometimes unnecessary. In this case for this bug, there's actually a metric for
when the distro can guess that something is going wrong (e.g., check every hour to see if the
spin count is increasing at an inappropriately high rate).

Unfortunately, there aren't that many tools to get this sort of information, at least not for
a desktop distribution. I think it would be interesting to see an interface along the lines of
Fedora's SELinux Troubleshooter for things like this. Maybe every hour a cron job starts up to
check for common errors with metrics like this. If there is one, an icon displays in the task
bar to tell you about it and point you towards some proposed fixes with all the requisite
warnings about changing your hardware defaults?

Laptops, power management, and Ubuntu

Posted Nov 9, 2007 12:46 UTC (Fri) by canatella (subscriber, #6745) [Link]

Maybe the 1.2 million cycles are due to a previous installation, or maybe it's a bug in your
smart implementation (I've read about that somewhere). Anyway, the number which is important
to you today is the number of cycle per day or per hour. If the head parks 1000 times a day,
the drive will reach the 600000 cycles in two years. So if you hope to have your disk last at
least 3 years, check that your cycle number per day is less than 600000/(365 * 3) => 547.

Laptops, power management, and Ubuntu

Posted Nov 9, 2007 18:24 UTC (Fri) by kevinbsmith (guest, #4778) [Link]

Yesterday I was just below 1235000, and today I'm at 1239893, so the number is still
increasing very quickly. Several cycles per minute that the computer is turned on.

Laptops, power management, and Ubuntu

Posted Nov 11, 2007 13:23 UTC (Sun) by hein.zelle (guest, #33324) [Link]

I'm a bit surprised by remarks like "if you hope to keep your drive for 3 years".  I'm used to
ide drives lasting 10 years and up in desktops.  I would _at the very least_ expect a drive to
last for the common lifetime of a computer.  These days i use a linux machine at least 3,
usually 4-5 years before performance drops too far behind.  Anything less is not an acceptable
"expected lifetime", to me.



Copyright © 2012, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds