Linux power optimisation guide v1.03

Status
Not open for further replies.

amdfangirl

Expert
Ambassador
Introduction - Linux power optimisation guide v 1.03
This guide is designed to assist and aid inexperienced Linux users to increase battery life in response to the common complaint of lower battery life in Linux.
Be warned that in many instances, the power saving advice may reduce the overall performance of your laptop, a trade-off some deem worthy for added battery life.

If you do not understand what you are doing, please ask! Tweaking without knowing is a bad idea!

Tweaks were performed on a Lenovo s10e with Fedora 15. Tweaks may not apply to all distributions.

Inbuilt Power Saving Programmes
Many Linux distributions contain methods of conserving power, such as lowering the screen brightness or making the disk idle when not in-use. These are distribution specific, so rather than listing all of them, you will probably find them in your system settings. These should be your first port-of-call.

Power Management Tweaks
Depending on your distribution, there may be guides already set up for your distribution of Linux. For example Fedora maintains a list of common tweaks to lower power consumption.
It is best to refer to each individual distribution's guides if they already exist. However, many of the tweaks mentioned below should work for any distribution.

Fedora - Simple tips to reduce power usage
Use a properly dimensioned system for the job (no need for overpowered systems for simple Desktop use e.g.)
For servers consolidate services on fewer systems to maximise efficiency of each system
Enforce turning of systems that are not used (e.g. company policy)
Unplug and/or turn of peripherals that aren't used (e.g. external USB devices, monitors, printers, scanners)
Turn of unused hardware already in BIOS.
Disable power hungry features.
Enable CPU scaling if supported for ondemand CPU governor. DONT use powersave governor, typically uses more power than ondemand (race to idle).
Put network card to 100 mbit/10 mbit:
10 mbit: ethtool -s eth0 advertise 0x002
100 mbit: ethtool -s eth0 advertise 0x008
Doesn't work for every card
Put harddisk to spindown fast and full power saving:
hdparm -S240 /dev/sda (20m idle to spindown)
hdparm -B1 /dev/sda (Max powersave mode)
Make sure writes to hd don't wake it up too quickly:
Set flushing to once every 5 minutes
echo "30000" > /proc/sys/vm/dirty_writeback_centisecs
Enable laptop mode
echo "5" > /proc/sys/vm/laptop_mode
Use relatime for your / partition
mount -o remount,relatime /
Disable CD-ROM polling from HAL (prevents popups when a CD is inserted):
hal-disable-polling --device /dev/scd0
Enable USB autosuspend by adding the following to the kernel boot commandline:
usbcore.autosuspend=5
Screensaver needs to dpms off the screen, not just make colors black. To turn of monitor after 120s when X is running:
xset dpms 0 0 120
Source: http://fedoraproject.org/wiki/Features/PowerManagement#Simple_user_tips_for_improving_power_usage

Linux Power Regression
For users running the 2.6.38 kernel and beyond, a problem has arisen from the 2.6.38 kernel changes resulting in significantly higher power consumption.

For users of the 3.2 kernel there is a kernel patch available!

1.png


The power-saving feature known as 'pcie_aspm' has been disabled on computers whose BIOS reports it to be incompatible or suggests it to be turned off. 'pcie_aspm' is designed to power down unused PCI-E lanes.

An incomplete list of BIOSes that do not support this are avalible at: http://www.phoronix.com/scan.php?page=news_item&px=OTk4NQ

To determine whether 'pcie_aspm' is enabled or not, navigate to this location with your file manager.

/sys/module/pcie_aspm/parameters

There should be a file named 'policy'.

If the file says
Code:
default performance [powersave]
'pcie_aspm' is enabled.

To force 'pcie_aspm' to function, please add the following to the boot command line in GRUB:

Code:
pcie_aspm=force

Please be warned that this may affect the stability of your system and cause freezes. Please back up data before attempting.

Use either of these commands to summon GRUB config.

Code:
su
gedit /etc/grub.conf

or

Code:
sudo gedit /etc/grub.conf

Reference Phoronix article: http://www.phoronix.com/scan.php?page=article&item=linux_2638_aspm&num=1

Installable Programmes
Powertop: http://www.lesswatts.org/projects/powertop/
Powertop is a Linux power monitoring programme designed to reduce the power consumption of laptops by offering power consumption optimisation advice. This is an invaluable tool for beginner and experienced Linux users alike.

You can easily install this programme in Ubuntu, Linux Mint, Fedora and other various distributions.

Powertop is often included with the mainstream distributions.

Ubuntu, Mint and derivatives
Code:
sudo apt-get install powertop
Fedora, Mandriva and derivatives
Code:
yum install powertop

Powertop, regardless of the distributions is launched from terminal.
Code:
su
sudo powertop

You should be presented with a screen similar to this:
6133128845_177c38bd51_b.jpg


Use the arrow keys to navigate the interface.

A list of suggestions can be found as seen here.
6133673432_14112b6e60_b.jpg


You may find a brief guide on how to interpret these suggestions at: http://docs.fedoraproject.org/en-US/Fedora/14/html/Power_Management_Guide/PowerTOP.html

cpufrequtils:
For the more advanced and adventurous, cpufrequtils is a programme which allows the throttling of CPUs to reduce power consumption. Obviously lowering the clock speed will also lower the performance of the system. A well written guide by the Arch Linux team is available.

Guide: https://wiki.archlinux.org/index.php/CPU_Frequency_Scaling

This sticky has been marked for improvement by amdfangirl. Suggestions and comments are appreciated. Contributors will be noted.
 
Status
Not open for further replies.