注意:

The Funtoo Linux project has transitioned to "Hobby Mode" and this wiki is now read-only.

Difference between revisions of "Power Management"

From Funtoo
Jump to navigation Jump to search
m
 
Line 2: Line 2:
Note: This page is a work in progress.
Note: This page is a work in progress.


== Who is this for? ==
== Use case ==


The majority of people who will be interested in power management on Funtoo will be split into the following two cases:
The majority of people who will be interested in power management on Funtoo will be split into the following two cases:
Line 8: Line 8:
* Laptop users
* Laptop users
* Low Power Workstation/Server users
* Low Power Workstation/Server users
This article is currently almost exclusively directed at laptop users.
This article is currently almost exclusively directed at laptop users.
==== Why bother? ====
Battery life, environmentalism, obsessiveness.
The author of this article saw a huge improvement in battery life after setting up necessary options, jumping from a 5:37 hour ACPI estimate to over 11 hours! (Thinkpad T420, 9-cell battery)
We've only got one planet right now, resources are limited, so why not use them wisely? Saving power reduces strain on your infrastructure and might save a couple furry bear cubs down the road. Also note that a reduction in power consumption means a reduction in your electricity bill.


== The trade-off ==
== The trade-off ==

Latest revision as of 10:18, June 15, 2015

Note: This page is a work in progress.

Use case

The majority of people who will be interested in power management on Funtoo will be split into the following two cases:

  • Laptop users
  • Low Power Workstation/Server users

This article is currently almost exclusively directed at laptop users.

The trade-off

First of all, you need to decide how much performance (if any) you're willing to sacrifice for a reduction in power.

Tools like laptop-mode and cpufreqd can cause a reduction in performance, however with careful configuration you can make this minimal while maintaining most of the benefits. Throughout this guide make sure to read comments in configuration files and decide what you need and want.

Getting started


Using Gentoo's resources

You'll find a fantastically written starter guide on the Gentoo site [1], note however that you are not required to use Gentoo-Sources. (Making your own kernel is a boatload of fun though! You're missing out.)

Laptop-mode-tools

Laptop-mode-tools should be reasonably well configured out of the box.

vim /etc/laptop-mode/laptop-mode.conf

Make sure it's enabled:

###############################################################################
# Enable/Disable laptop-mode-tools execution
# ------------------------------------------
# Set it to 0 to completely disable laptop-mode-tools from running
###############################################################################
#
ENABLE_LAPTOP_MODE_TOOLS=1

Next declare when to use laptop-mode:

# Enable laptop mode when on battery power.
#
ENABLE_LAPTOP_MODE_ON_BATTERY=1

# Enable laptop mode when on AC power.
#
ENABLE_LAPTOP_MODE_ON_AC=0

Next you will probably be safe to enable AUTO_MODULES with:


ENABLE_AUTO_MODULES=1

However, provided you're not using HAL (You shouldn't be, it's deprecated and is replaced by udev) you may want to disable the HAL module explicitly:

vim /etc/laptop-mode/conf.d/hal-polling.conf
----
CONTROL_HAL_POLLING=0

Finally, lets start up laptop_mode, then add it to our init.

/etc/init.d/laptop_mode start

rc-update add laptop_mode default

Triggering events upon power state/level

You can set up certain events to happen when a particular power state is reached through the use of udev rules. For example if you have a laptop and want it to hibernate (using sys-power/hibernate-script) when the battery reaches a low level (1%) then you can do the following:

Find the power supplies on the system:

root # ls /sys/class/power_supply

Find the parameters for each:

root # udevadm info --attribute-walk /sys/class/power_supply/[what previous command gave you, eg AC]

Using this information you can then create a rule:

   /etc/udev/rules.d/99-lowbat.rules
## HIBERNATE IF BATTERY IS LOW
SUBSYSTEM=="power_supply", ATTR{type}=="Battery", ATTR{status}=="Discharging", ATTR{capacity}=="1", RUN+="/usr/sbin/hibernate"

To load this new rule:

root # udevadm control --reload