Difference between revisions of "Minimizing Power Consumption in Linux"

From JimboWiki
Jump to: navigation, search
Line 64: Line 64:
 
PowerTOP suggests this, I'm not sure exactly what it does yet:
 
PowerTOP suggests this, I'm not sure exactly what it does yet:
 
usbcore.autosuspend=1
 
usbcore.autosuspend=1
 +
[https://bugs.launchpad.net/ubuntu/+source/powertop/+bug/136549 apparently, it doesn't work in Ubuntu anyway]
 
===Automated Actions===
 
===Automated Actions===
 
====File Access Time Update====
 
====File Access Time Update====
Line 107: Line 108:
 
/etc/laptop-mode/
 
/etc/laptop-mode/
 
</pre>
 
</pre>
 +
[http://ubuntudemon.wordpress.com/2007/10/26/laptop-hardrive-killer-bug/#comment-31234 major configuration bug with laptop-mode]
 
===The Linux "tickless" Kernel Feature===
 
===The Linux "tickless" Kernel Feature===
 
Google this great feature.
 
Google this great feature.
 
==References==
 
==References==
 
<references/>
 
<references/>

Revision as of 19:06, 13 November 2007

Want to make your laptop battery last longer? Want to lower the power consumption of that awesome Linux based media PC you have? Here's where to start.

This article is written specifically for Ubuntu 7.10 (Gusty Gibbon), but the ideas expressed here can apply to any Linux distribution. Some of the higher-level thought can even be applied to other operating systems.

This page is incomplete
More work needs to be done on this page, so if something is missing, don't be surprised
1 Still working on finding ways to save power
2 Need to finish documenting others


Overview

The high level concept of battery discharge science that this article depends on is pretty simple - the more load (measured in Watts, abbreviated W) put onto a given battery of a set capacity (measured in Volt Hours, abbreviated Vh), the faster it will drain. So, if we want to make the battery last longer, we need to minimize the load or get a larger capacity battery - obviously.

Laptop batteries are expensive, and larger capacity usually means a heavier battery - so getting a new battery is probably not such a good idea. Of course, none of that battery stuff applies to the power consumption of a desktop machine - and I told you we could lower the power consumption of those too - so a new battery is definitely not the answer.

Instead of a bigger battery, we could consider physical devices that consume less power. For instance:

Device Typical Power Saving
Hard Drive Spinning platters, moving read/write head Solid state - no moving parts
CPU High power, full size processor Low power, limited size processor
Fans High speed, constant RPM fans Low speed, variable RPM fans
Graphics Always on, full power backlight Low power modes, variable backlight

Most of these power saving options are either ridiculously expensive (like solid state hard drives) or hard to change (such as laptop graphics cards). That means we have to reduce the power consumption of the computer through software.

How to Reduce Power Consumption

Intel PowerTOP

Intel makes an open source tool, called PowerTOP, which allows you to see which processes are forcing the computer to jump out of power save mode. It also gives recommendations for other ways to save power and will even automatically implement some of the suggested measures for you if you like. Ubuntu users can get PowerTOP from the apt repositories:

sudo apt-get install powertop

Run the tool as root for maximum benefit

sudo powertop

PowerTOP will cover most of the following topics automatically.

Eliminating Power Hungry Processes

Inefficient programs, like background file indexers or certain server processes, require your computer to come out of power save mode more often. Disable these programs to reduce power consumption. (PowerTOP will detect some such software, but others you'll have to use your brain for)

Hardware Settings

Certain pieces of physical hardware may have special power save features that are not taken advantage of by default.

CD-ROM Auto Poll

The idea of this setting is to detect CDs or memory sticks being inserted or removed. We can shut off the auto-poll for all drives to save even more power. Keep in mind, this will affect any auto-mounting features that you have in place in your distribution. (PowerTOP detects this very well, and implements a fix for you)

Wireless Powersave Mode

Wireless transmission takes a huge amount of power. If you don't need as much power - for instance, your laptop never gets very far from your access point - we can turn the transmission power down.

iwpriv eth1 set_power 5

Note that decreasing the transmission power of your wireless device will decrease the device's effectiveness. (PowerTOP detects this, and implements a fix.)

USB autosuspend

PowerTOP suggests this, I'm not sure exactly what it does yet: usbcore.autosuspend=1 apparently, it doesn't work in Ubuntu anyway

Automated Actions

File Access Time Update

Whenever a file is accessed, Linux performs a write to disk to update the access time. (Note that there is a disk write even if the file is already cached in memory.) Shutting off this feature, commonly referred to as atime, reduces disk activity, which decreases power consumption and increases system performance.[1]

There are a few different ways to disable the access time update. First, we can shut it off for individual files:

sudo chattr +A <filename>

or for whole directories (recursively):

sudo chattr -R +A <directory>

We can also shut it off for an entire mount point by changing /etc/fstab entries that look like this:

/dev/sda1       /      ext3    defaults,errors=remount-ro       0 1

into this:

/dev/sda1       /      ext3    defaults,noatime,errors=remount-ro       0 1

We can make the same change by doing a live remount, like this: (note that this change will not affect subsequent system reboots)

sudo mount -o noatime,remount,rw /dev/sda1

It's all well and good that we can shut off atime, but what does that break? Many mail tools compare the last write time with the last access time to decide if mail has been read. Many backup software depend on access times to make sure things get backed up properly.

There's a slightly different way to deal with access time updates, which addresses some of these concerns. It's called relatime and it's available since kernel version 2.6.20. Using the relatime option in place of the noatime option causes access times to be updated only if the current access time is before or at the same time as the last write time. (PowerTOP detects this. The fix recommended by PowerTOP is the live remount)

Virtual Memory Dirty Write Rate

PowerTOP suggests this: increase the VM dirty writeback time from 5.00 to 15 seconds with:

echo 1500 > /proc/sys/vm/dirty_writeback_centisecs

This wakes the disk up less frequenty for background VM activity[2]

Laptop-Mode

I'm not sure what this is, but it supposedly saves power. Need to figure out how to configure it.[3]

/etc/laptop-mode/

major configuration bug with laptop-mode

The Linux "tickless" Kernel Feature

Google this great feature.

References

  1. http://lwn.net/Articles/244829/
  2. http://www.mjmwired.net/kernel/Documentation/filesystems/proc.txt#1239
  3. http://www.mjmwired.net/kernel/Documentation/laptop-mode.txt