首页 php下载 php教程 电脑软件 手机软件 手机游戏 单机游戏 资讯文章 专题下载 标签合集

电源管理指南(Power Management Guide)

时间:2008-05-23

来源:fengaas

在手机上看
手机扫描阅读
(Power Management Guide)

Power Management Guide 电源管理指南

Content: 1. Introduction 2. Prerequisites 3. CPU Power Management 4. LCD Power Management 5. Disk Power Management 6. Power Management For Other Devices 7. Sleep States: sleep, standby, and suspend to disk 8. Troubleshooting

1.  Introduction 介绍

Capacity and lifetime of laptop batteries have improved much in the last years. Nevertheless modern processors consume much more energy than older ones and each laptop generation introduces more devices hungry for energy. That's why Power Management is more important than ever. Increasing battery run time doesn't necessarily mean buying another battery. Much can be achieved applying intelligent Power Management policies.

近几年笔记本电池的容量和寿命都大大提高了。但是现在的处理器同样需要消耗更多的能量,同时还有许多需要消耗能量的新设备。于是电源管理比之前更为重要。延长电池使用的时间并不是需要你多卖一块,更智能的电源管理策略也可以达到这个目标。

A Quick Overview 概述

Please notice that this guide describes Power Management for laptops. While some sections might also suite for servers, others do not and may even cause harm. Please do not apply anything from this guide to a server unless you really know what you are doing.

注意:这里的电源管理指南针对的是笔记本电脑,虽然其中有些设置也适用于服务器,但是有些设置会不适用,并可能引起一些异常。所以除非你知道自己在做什么,否则不要将其应用到服务器。

As this guide has become rather long, here's a short overview helping you to find your way through it.

由于本指南较长,这里给一个短的概述,以便你可以快速了解其内容。

{

The Prerequisites 必要条件chapter talks about some requirements that should be met before any of the following device individual sections will work.

此章说明了让下面的所有设备可以工作的必要条件。

This includes BIOS settings, kernel configuration and some simplifications in user land.

这包括BIOS设置,内核配置,和一些用户层面上的简化。(不明白这里简化指什么?)

The following three chapters focus on devices that typically consume most energy - processor, display and hard drive.

接下来的三章分别介绍需要能量最多的三个设备:处理器,显示器和硬件驱动。(这里说硬件驱动可能有些问题?)

Each can be configured seperately.

每一个都可以独立地进行配置。

CPU Power Management shows how to adjust the processor's frequency to save a maximum of energy without losing too much performance.

CPU电源管理说明了如何调整处理器的工作频率,从而节省大部分能量而不会明显降低性能。

A few different tricks prevent your hard drive from working unnecessarily often in Disk Power Management (decreasing noise level as a nice side effect).

硬盘电源管理给出了一些技巧,使硬盘在不必要的时候不工作,而且还能减少噪音。

Some notes on graphics cards, Wireless LAN and USB finish the device section in Power Management For Other Devices

其它设备的电源管理给出了一些显卡,无线网卡和USB设备方面的知识。

while another chapter is dedicated to the (rather experimental) sleep states.

另一章介绍了 睡眠状态 (这尚处于实验阶段)

Last not least Troubleshooting lists common pitfalls.

最后的一章介绍了一些见的错误。

}

Power Budget For Each Component 每个设备的能量预算


Figure 1.1: Power budget for each component



Figure 1.1: Power budget for each component

Nearly every component can operate in different states - off, sleep, idle, active to name a few - consuming a different amount of energy. Major parts are consumed by the LCD display, CPU, chipset and hard drives. Often one is able to activate OS-independent Power Management in the BIOS, but an intelligent setup in the operating system adapting to different situations can achieve much more.

几乎每一个组件都可以使之处于不同的状态--关闭,睡眠,空闲,活动--它们消耗的能量也不同。主要的部分就是LCD显示器,CPU,芯片组和硬盘。通常人们在BIOS设置里可以激活一些电源管理,但在操作系统里的智能设置可使你达到更高的目标。

2.  Prerequisites 必要条件

Before discussing the details of making individual devices Power Management aware, make sure certain requirements are met. After controlling BIOS settings, some kernel options want to be enabled - these are in short ACPI, sleep states and CPU frequency scaling. As power saving most of the time comes along with performance loss or increased latency, it should only be enabled when running on batteries. That's where a new runlevel battery comes in handy.

The BIOS Part BIOS部分

First have a look into your BIOS Power Management settings. The best way is to combine BIOS and operating system policies, but for the moment it's better to disable most of the BIOS part. This makes sure it doesn't interfere with your policies. Don't forget to re-check BIOS settings after you configured everything else.

先要看一看BIOS里面的设置,最好的策略是将BIOS和操作系统相结合。但这里请先暂时关闭BIOS部分,因为这样可以确保其不会和你的策略相冲突。不要忘记在设置完所有配置之后要检查一遍BIOS里的设置。


Setting USE Flags 设置USE标识

Please check that the acpi USE flag is set in /etc/make.conf. Other USE flags that might be interesting for your system are apm, lm_sensors, nforce2, nvidia, pmu. See /usr/portage/profiles/use*.desc for details. If you forgot to set one of these flags, you can recompile affected packages using the --newuse flag in emerge, see man emerge.

检查/etc/make.conf里面的USE设置,确保有“acpi",如果你的系统是apm的,还有一些标识:lm_sensors, nforce2, nvidia, pmu。查看/usr/portage/profiles/use*.desc,里面给出了很多细节。如果你编译程序时忘记了设置这些USE标识,请在修改完make.conf里面的USE设置后,使用--newuse参数重新编译相关软件包,此处参考emerge命令的手册页。

Configuring The Kernel 配置内核

ACPI (Advanced Configuration and Power Interface) support in the kernel is still work in progress. Using a recent kernel will make sure you'll get the most out of it.

内核对ACPI (高级配置和电源接口)的支持尚处于开发中,所以在使用新近的内核时,最好不要将其编译进入内核,而是以模块的方式使用。

There are different kernel sources in Portage. I'd recommend using gentoo-sources or tuxonice-sources. The latter contains patches for TuxOnIce, see the chapter about sleep states for more details. When configuring the kernel, activate at least these options:

在Portage中有不同的内核,推荐使用gentoo-sources或者tuxonice-sources。后面这个包含TuxOnIce的补丁,更多结节见sleep states章。在配置内核时,至少要激活以下选项:

Code Listing 2.1: Minimum kernel setup for Power Management (Kernel 2.6)

Power Management Options --->
[*] Power Management Support
[ ] Software Suspend

ACPI( Advanced Configuration and Power Interface ) Support --->
[*] ACPI Support
[ ] Sleep States
[ ] /proc/acpi/sleep (deprecated)
[*] AC Adapter
[*] Battery
<M> Button
<M> Video
[ ] Generic Hotkey
<M> Fan
<M> Processor
<M> Thermal Zone
< > ASUS/Medion Laptop Extras
< > IBM ThinkPad Laptop Extras
< > Toshiba Laptop Extras
(0) Disable ACPI for systems before Jan 1st this year
[ ] Debug Statements
[*] Power Management Timer Support
< > ACPI0004,PNP0A05 and PNP0A06 Container Driver (EXPERIMENTAL)

CPU Frequency Scaling --->
[*] CPU Frequency scaling
[ ] Enable CPUfreq debugging
< > CPU frequency translation statistics
[ ] CPU frequency translation statistics details
Default CPUFreq governor (userspace)
<*> 'performance' governor
<*> 'powersave' governor
<*> 'ondemand' cpufreq policy governor
<*> 'conservative' cpufreq governor
<*> CPU frequency table helpers
<M> ACPI Processor P-States driver
<*> CPUFreq driver for your processor

Here should add my own configurations


Decide yourself whether you want to enable Software Suspend, and Sleep States (see below). If you own an ASUS, Medion, IBM Thinkpad or Toshiba laptop, enable the appropriate section.

请自行决定是否要激活Software suspend(软件待机)和sleep states(睡眠状态)(详见下面)。如果你的机器是ASUS,Medion,IBM Thinkpad或Toshiba笔记本,请选择相应的选项。

The kernel has to know how to enable CPU frequency scaling on your processor. As each type of CPU has a different interface, you've got to choose the right driver for your processor. Be careful here - enabling Intel Pentium 4 clock modulation on a Pentium M system will lead to strange results for example. Consult the kernel documentation if you're unsure which one to take.

内核必须知道如何对你的处理器进行主频调整。因为不同的CPU具有不同的接口,所以你需要选择正确的驱动。这里需要注意,例如,在Pentium M系统上打开Intel Pentium 4 clock modulation选项将会导致奇怪的结果。如果你不确定应该如何选择,请查阅内核文档。 

Compile your kernel, make sure the right modules get loaded at startup and boot into your new ACPI-enabled kernel. Next run emerge sys-power/acpid to get the acpi daemon. This one informs you about events like switching from AC to battery or closing the lid. Make sure the modules are loaded if you didn't compile them into the kernel and start acpid by executing /etc/init.d/acpid start. Run rc-update add acpid default to load it on startup. You'll soon see how to use it.

编译内核,确保在启动把持ACPI的内核启动时将正确的模块加载。然后,运行emerge sys-power/acpid,编译acpi daemon。这个程序可以通知你一些事件,例如从AC交流电切换到电池,合上笔记本等等。如果没有将功能编译进内核,请确保模块已经加载。启动acpi daemon,运行:/etc/init.d/acpid start。运行rc-update add acpid default使其在每次开机时自动运行。很快你就可以看到如何使用它了。

Code Listing 2.2: Installing acpid

# emerge sys-power/acpid
# /etc/init.d/acpid start
# rc-update add acpid default

Creating A "battery" Runlevel 创建一个"battery"运行级(runlevel)

The default policy will be to enable Power Management only when needed - running on batteries. To make the switch between AC and battery convenient, create a runlevel battery that holds all the scripts starting and stopping Power Management.

缺省的策略是只在需要的时候启动电源管理--使用电池时。想要在交流电和电池之间很方便的切换,就需要创建一个runlevel,让它控制所有相电源管理相关的角本的启动和停止。

Note: You can safely skip this section if you don't like the idea of having another runlevel. However, skipping this step will make the rest a bit trickier to set up. The next sections assume a runlevel battery exists.

Code Listing 2.3: Creating a battery runlevel

# cd /etc/runlevels
# cp -a default battery

如果你不喜欢这个主意,可以跳过这部分,但是这会使后面的设置会有所不同,因为后面的章节都是假设此runlevel存在的。

Finished. Your new runlevel battery contains everything like default, but there is no automatic switch between both yet. Time to change it.

完成了。你的新runlevel现在和default完全一样,但是现在还不能在两者之间自动切换,现在来修改它。

Reacting On ACPI Events 对ACPI事件响应

Typical ACPI events are closing the lid, changing the power source or pressing the sleep button. An important event is changing the power source, which should cause a runlevel switch. A small script will take care of it.

典型的ACPI事件是合上笔记本,改变电源或者按下sleep按钮。一个重要的事件是改变电源,这会引起runlevel切换。用一个小角本来处理它。

First you need a script which changes the runlevel to default respectively battery depending on the power source. The script uses the on_ac_power command from sys-power/powermgmt-base - make sure the package is installed on your system.

首先你需要一个脚本来切换runlevel,这里用到一个命令on_ac_power。它来自sys-power/powermgmt-base软件包,所以要确保你的系统里安装了这个软件包。

Code Listing 2.4: Installing powermgt-base

# emerge powermgmt-base 

You are now able to determine the power source by executing on_ac_power && echo AC available || echo Running on batteries in a shell. The script below is responsible for changing runlevels. Save it as /etc/acpi/actions/pmg_switch_runlevel.sh.

现在你可以在shell里执行:on_ac_power && echo AC available || echo Running on batteries。它会给出你的电源来自交流电还是电池。下面的脚本负责改变runlevel。把它保存到/etc/acpi/actions/pmg_switch_runlevel.sh.文件中。

Code Listing 2.5: /etc/acpi/actions/pmg_switch_runlevel.sh

#!/bin/bash

# BEGIN configuration
RUNLEVEL_AC="default"
RUNLEVEL_BATTERY="battery"
# END configuration

if [ ! -d "/etc/runlevels/${RUNLEVEL_AC}" ]
then
logger "${0}: Runlevel ${RUNLEVEL_AC} does not exist. Aborting."
exit 1
fi

if [ ! -d "/etc/runlevels/${RUNLEVEL_BATTERY}" ]
then
logger "${0}: Runlevel ${RUNLEVEL_BATTERY} does not exist. Aborting."
exit 1
fi

if on_ac_power
then
if [[ "$(</var/lib/init.d/softlevel)" != "${RUNLEVEL_AC}" ]]
then
logger "Switching to ${RUNLEVEL_AC} runlevel"
/sbin/rc ${RUNLEVEL_AC}
fi
elif [[ "$(</var/lib/init.d/softlevel)" != "${RUNLEVEL_BATTERY}" ]]
then
logger "Switching to ${RUNLEVEL_BATTERY} runlevel"
/sbin/rc ${RUNLEVEL_BATTERY}
fi

Dont forget to run chmod +x /etc/acpi/actions/pmg_switch_runlevel.sh to make the script executable. The last thing that needs to be done is calling the script whenever the power source changes. That's done by catching ACPI events with the help of acpid. First you need to know which events are generated when the power source changes. The events are called ac_adapter and battery on most laptops, but it might be different on yours.

不要忘记用chmod +x /etc/acpi/actions/pmg_switch_runlevel.sh命令其此脚本可执行。最后一件事就是要在电源改变时调用此脚本。这个ACPI事件将由acpid捕捉。首先你要知道当电源改变时产生哪个事件。在很多笔记本上此事件叫ac_adapter和battery,但有的不是。

Code Listing 2.6: Determining ACPI events for changing the power source

# tail -f /var/log/messages | grep "received event" 

Run the command above and pull the power cable. You should see something like this:

运行上面的命令,并插拔交流电源线,将会得到下面的信息:

Code Listing 2.7: Sample output for power source changes

[Tue Sep 20 17:39:06 2005] received event "ac_adapter AC 00000080 00000000"
[Tue Sep 20 17:39:06 2005] received event "battery BAT0 00000080 00000001"

The interesting part is the quoted string after received event. It will be matched by the event line in the files you are going to create below. Don't worry if your system generates multiple events or always the same. As long as any event is generated, runlevel changing will work.

重要的部分是引号内的字符串,它需要和接下来将要创建的文件中的事件行相符。如果你的系统中出现多个事件也不用担心,因为只要有任何一个事件产生,改变runlevel也可以正常工作。

Code Listing 2.8: /etc/acpi/events/pmg_ac_adapter

# replace "ac_adapter" below with the event generated on your laptop
# For example, ac_adapter.* will match ac_adapter AC 00000080 00000000
event=ac_adapter.*
action=/etc/acpi/actions/pmg_switch_runlevel.sh %e

Code Listing 2.9: /etc/acpi/events/pmg_battery

# replace "battery" below with the event generated on your laptop
# For example, battery.* will match battery BAT0 00000080 00000001
event=battery.*
action=/etc/acpi/actions/pmg_switch_runlevel.sh %e

Finally acpid has to be restarted to recognize the changes.

最后acpid需要重新启动来激活这些设置。

Code Listing 2.10: Finishing runlevel switching with acpid

# /etc/init.d/acpid restart 

Give it a try: Plug AC in and out and watch syslog for the "Switching to AC mode" or "Switching to battery mode" messages. See the Troubleshooting section if the script is not able to detect the power source correctly.

试一下:插入或拔出AC,观察系统日志信息 "Switching to AC mode" 或 "Switching to battery mode"。如果脚本无法检测到电源改变,见Troubleshooting section。

Due to the nature of the event mechanism, your laptop will boot into runlevel default regardless of the AC/battery state. This is fine when running from AC, but we'd like to boot into the battery runlevel otherwise. One solution would be to add another entry to the boot loader with the parameter softlevel=battery, but it's likely to forget choosing it. A better way is faking an ACPI event in the end of the boot process and letting pmg_switch_runlevel.sh script decide whether a runlevel change is necessary. Open /etc/conf.d/local.start in your favourite editor and add these lines:

由于事件机制,无论你使用AC还是电池,笔记本启动时自动进入的runlevel是default。这对于启动时用电源是合适的,但我们想要在使用电池时启动进入适当的runlevel。一个解决办法是在启动管理程序中加入一个项目,用参数softlevel=battery来表明启动后适用的runlevel,不过有时也许我们会忘记选择它。一个更好的办法是在启动过程的末尾假造一个ACPI事件,让pmg_switch_runlevel.sh脚本文件来确定应该使用哪个runlevel。打开/etc/conf.d/local.start,加入下面这一行内容。

Code Listing 2.11: Runlevel adjustment at boot time by editing local.start

# Fake acpi event to switch runlevel if running on batteries
/etc/acpi/actions/pmg_switch_runlevel.sh "battery/battery"

Prepared like this you can activate Power Management policies for individual devices.

准备好前面所述的一切,电源管理就可以正常启动了。

3.  CPU Power Management CPU电源管理

Mobile processors can operate at different frequencies. Some allow changing voltage as well. Most of the time your CPU doesn't need to run at full speed and scaling it down will save much energy - often without any performance decrease.

移动处理器可以在不同的频率下工作。有一些还允许改变电压。很多时候你的CPU不需要全速工作,你可以使它降频从而省电--通常不会感觉到性能降低。

Some Technical Terms 一些技术条款

CPU frequency scaling brings up some technical terms that might be unknown to you. Here's a quick introduction.

CPU频率调整有一些相关的技术条款,也许你不清楚,这里是一个简介。

First of all, the kernel has to be able to change the processor's frequency.

首先,内核必须支持变频。

The CPUfreq processor driver knows the commands to do it on your CPU. Thus it's important to choose the right one in your kernel. You should already have done it above.

处理器频率驱动CPUfreq processor driver可以使CPU理解内核的命令。所以为内核选择合适的驱动是非常重要的。这一步你应当已经在前面编译内核时做完了。

Once the kernel knows how to change frequencies, it has to know which frequency it should set.

一旦内核知道如何改变频率,它必须知道要把频率变到多少。

This is done according to the policy which consists of a CPUfreq policy and a governor.

这要根据你的策略来做,策略由两部分组成:CPU频率策略 CPUfreq policy 和 a 调节器 governor。

A CPUfreq policy are just two numbers which define a range the frequency has to stay between - minimal and maximal frequency.

CPU频率策略只由两个数字组成,它们定义了频率所处的区间:频率最小值和最大值。

The governor now decides which of the available frequencies in between minimal and maximal frequency to choose.

调节器现在可以决定此区间内的具体频率数值。

For example, the powersave governor always chooses the lowest frequency available, the performance governor the highest one.

节能调节器powersave governor总是选择最低频率,性能调节器performance governor总是选择最高频率。

The userspace governor makes no decision but chooses whatever the user (or a program in userspace) wants - which means it reads the frequency from /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed.

用户空间调节器没有确定的频率,它可以根据用户(或者是用户空间的程序)来设定频率,也就是说,它从/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed文件中读取频率。

This doesn't sound like dynamic frequency changes yet and in fact it isn't.

这听起来还不是动态频率改变,实际上它也不是。

Dynamics however can be accomplished with various approaches.

动态频率改变可以通过几种方法来实现。

For example, the ondemand governor makes its decisions depending on the current CPU load. The same is done by various userland tools like cpudyn, cpufreqd, powernowd and many more. ACPI events can be used to enable or disable dynamic frequency changes depending on power source.

例如,需求调节器ondemand governor使频率根据当前CPU的负荷的决定。许多用户空间工具也是根据同样的原理来实现,如cpudyn, cpufreqd, powernowd等等。ACPI事件可以用来根据电能来源打开和关闭动态频率功能。

Setting The Frequency Manually 手动设置频率

Decreasing CPU speed and voltage has two advantages: On the one hand less energy is consumed, on the other hand there is thermal improvement as your system doesn't get as hot as running on full speed. The main disadvantage is obviously the loss of performance. Decreasing processor speed is a trade off between performance loss and energy saving.

降低CPU速度和电压有两处好处:一方面是更省电,另一方面是发热更少。主要的块处就是性能降低。降频需要在省电和性能之间取个平衡点。

Note: Not every laptop supports frequency scaling. If unsure, have a look at the list of supported processors in the Troubleshooting section to verify yours is supported.

注意:不是所有的笔记本都支持变频。如果不确定,查看在Troubleshooting章的处理器列表,来确定你的笔记本是否支持。

It's time to test whether CPU frequency changing works. Let's install another tool which is very handy for debugging purposes: sys-power/cpufrequtils

现在可以来试试CPU变频是否工作了。安装另一个工具,它是一个很方面的调试工具:sys-power/cpufrequtils

Code Listing 3.1: Checking CPU frequency

# emerge cpufrequtils
# cpufreq-info

Here is an example output:

下面是一个输出的例子:

Code Listing 3.2: Sample output from cpufreq-info

cpufrequtils 0.3: cpufreq-info (C) Dominik Brodowski 2004
Report errors and bugs to linux@brodo.de, please.
analyzing CPU 0:
driver: centrino
CPUs which need to switch frequency at the same time: 0
hardware limits: 600 MHz - 1.40 GHz
available frequency steps: 600 MHz, 800 MHz, 1000 MHz, 1.20 GHz, 1.40 GHz
available cpufreq governors: conservative, ondemand, powersave, userspace, performance
current policy: frequency should be within 924 MHz and 1.40 GHz.
The governor "performance" may decide which speed to use
within this range.
current CPU frequency is 1.40 GHz.

Now play around with cpufreq-set to make sure frequency switching works. Run cpufreq-set -g ondemand for example to activate the ondemand governor and verify the change with cpufreq-info. If it doesn't work as expected, you might find help in the Troubleshooting section in the end of this guide.

现在轮到cpufreq-set了,试着运行cpufreq-set -g ondemand来激活需求调节器,用cpufreq-info来查看更改是否生效。如果没有正常工作,请到本文末尾的Troubleshooting section章查看帮助。

Automated frequency adaption 自动频率适应

The above is quite nice, but not doable in daily life. Better let your system set the appropriate frequency automatically. There are many different approaches to do this. The following table gives a quick overview to help you decide on one of them. It's roughly separated in three categories kernel for approaches that only need kernel support, daemon for programs that run in the background and graphical for programs that provide a GUI for easy configuration and changes.

上面的方面工作的很好,但不是日常使用的方式。日常使用时我们需要让系统自动调节频率以适应需求。有很多方法完成这个功能。下面的表格简单介绍了各种方法,以便你进行选择。它们粗略地分为三种,kernel表示此方法只需要内核支持即可,daemon表示需要一个后台运行的程序,而graphical表示程序会提供一个用户介面以方便地修改配置。

Name Category Switch decision Kernel governors Further governors Comments
'ondemand' governor Kernel CPU load N.A. N.A. Chooses maximal frequency on CPU load and slowly steps down when the CPU is idle. Further tuning through files in /sys/devices/system/cpu/cpu0/cpufreq/ondemand/. Still requires userland tools (programs, scripts) if governor switching or similar is desired.
'conservative' governor Kernel CPU load N.A. N.A. Unlike the ondemand governor, conversative doesn't jump to maximum frequency when CPU load is high, but increases the frequency step by step. Further tuning through files in /sys/devices/system/cpu/cpu0/cpufreq/ondemand/. Still requires userland tools (programs, scripts) if governor switching or similar is desired.
cpudyn Daemon CPU load Performance, powersave Dynamic Also supports disk standby - notice however that laptop mode in most cases will do a better job.
cpufreqd Daemon Battery state, CPU load, temperature, running programs and more All available None Sophisticated (but somewhat complicated) setup. Extendible through plugins like sensor monitoring (lm_sensors) or coordinating some NVidia based graphics card memory and core. Cpufreqd is SMP aware and can optionally be controlled manually at runtime.
powernowd Daemon CPU load None Passive, sine, aggressive Supports SMP.
ncpufreqd Daemon Temperature None Powersave, performance Toggles the used governor between performance and powersave depending on system temperature. Very useful on laptops with notorious heat problems.
speedfreq Daemon CPU load None Dynamic, powersave, performance, fixed speed Easy to configure with a nice client/server interface. Requires a 2.6 kernel. Unmaintained, broken and thus removed from Portage. Please switch to cpufreqd if you're still using it.
gtk-cpuspeedy Graphical None None None Gnome application, a graphical tool to set CPU frequency manually. It does not offer any automation.
klaptopdaemon Graphical Battery state All available None KDE only, 'ondemand' governor required for dynamic frequency scaling.

While adjusting the frequency to the current load looks simple at a first glance, it's not such a trivial task. A bad algorithm can cause switching between two frequencies all the time or wasting energy when setting frequency to an unnecessary high level.

根据CPU负荷来改变频率乍一看很简单,可实际上却不是。一个不好的算法会使得CPU在两个频率之间变来变去,或者将频率设置在一个没必要的高频上,而浪费了很多能量。

Which one to choose? If you have no idea about it, try cpufreqd:

用哪个好呢?如果你不知道,不妨试试cpufreqd:

Code Listing 3.3: Installing cpufreqd

# emerge cpufreqd 

cpufreqd can be configured by editing /etc/cpufreqd.conf. The default one that ships with cpufreqd may look a bit confusing. I recommend replacing it with the one from former Gentoo developer Henrik Brix Andersen (see below). Please notice that you need cpufreqd-2.0.0 or later. Earlier versions have a different syntax for the config file.

cpufreqd可以通过编辑/etc/cpufreqd.conf来修改设置。缺省的配置文件看起来有点令人困惑。我推荐用Gentoo开发成员Henrik Brix Andersen的替换掉它(见下面)。请注意你需要的版本是cpufreqd-2.0.0或更高。低版本程序配置文件的语法是不同的。

Code Listing 3.4: /etc/cpufreqd.conf (cpufreqd-2.0.0 and later)

[General]
pidfile=/var/run/cpufreqd.pid
poll_interval=3
enable_plugins=acpi_ac, acpi_battery
enable_remote=1
remote_group=wheel
verbosity=5
[/General]

[Profile]
name=ondemand
minfreq=0%
maxfreq=100%
policy=ondemand
[/Profile]

[Profile]
name=conservative
minfreq=0%
maxfreq=100%
policy=conservative
[/Profile]

[Profile]
name=powersave
minfreq=0%
maxfreq=100%
policy=powersave
[/Profile]

[Profile]
name=performance
minfreq=0%
maxfreq=100%
policy=performance
[/Profile]

[Rule]
name=battery
ac=off
profile=conservative
[/Rule]

[Rule]
name=battery_low
ac=off
battery_interval=0-10
profile=powersave
[/Rule]

[Rule]
name=ac
ac=on
profile=ondemand
[/Rule]

Now you can start the cpufreqd daemon. Add it to the default and battery runlevel as well.

现在你可以打开后台进程cpufreqd。把它加到default和battery两个runlevel中。

Code Listing 3.5: Starting cpufreqd

# rc-update add cpufreqd default battery
# rc

Sometimes it can be desirable to select another policy than the daemon chooses, for example when battery power is low, but you know that AC will be available soon. In that case you can turn on cpufreqd's manual mode with cpufreqd-set manual and select one of your configured policies (as listed by cpufreqd-get). You can leave manual mode by executing cpufreqd-set dynamic.

有时你会需要选择一个不同于daemon程序的策略,例如当电池电量很少,但你知道很快就能用交流电了。这时,你可以打开cpufreqd的手动模式:cpufreqd-set manual并选择一个配置策略(可选择的策略在cpufreqd-get中列出)。当执行cpufreqd-set dynamic时离开手动模式。

Warning: Do not run more than one of the above programs at the same time. It may cause confusion like switching between two frequencies all the time.

警告:不要同时运行多个变频程序。这会引起混乱,例如在两个频率之间来回切换。

Verifying the result

验证结果

The last thing to check is that your new policies do a good job. An easy way to do so is monitoring CPU speed while working with your laptop:

最后,检查一个新策略工作得怎么样。一个简单的方法是当你用笔记本工作时运行下面的命令:

Code Listing 3.6: Monitoring CPU speed

# watch grep \"cpu MHz\" /proc/cpuinfo 

If /proc/cpuinfo doesn't get updated (see Troubleshooting), monitor the CPU frequency with sys-apps/x86info:

如果/proc/cpuinfo没有更新(见Troubleshooting),用sys-apps/x86info监测CPU频率。

Code Listing 3.7: Alternative CPU speed monitoring

# watch x86info -mhz 

Depending on your setup, CPU speed should increase on heavy load, decrease on no activity or just stay at the same level. When using cpufreqd and verbosity set to 5 or higher in cpufreqd.conf you'll get additional information about what's happening reported to syslog.

根据你的设置不同,CPU速度在负荷高时会增加,在没有活动时降频或者停留在那里。当用cpufreqd和冗长设置为5或更高时,你会得到更多信息,它们都会被记录在syslog中。

4.  LCD Power Management

As you can see in figure 1.1, the LCD display consumes the biggest part of energy (might not be the case for non-mobile CPU's). Thus it's quite important not only to shut the display off when not needed, but also to reduce it's backlight if possible. Most laptops offer the possibility to control the backlight dimming.

Standby settings

The first thing to check is the standby/suspend/off timings of the display. As this depends heavily on your windowmanager, I'll let you figure it out yourself. Just two common places: Blanking the terminal can be done with setterm -blank <number-of-minutesM>, setterm -powersave on and setterm -powerdown <number-of-minutesM>. For X.org, modify /etc/X11/xorg.conf similar to this:

Code Listing 4.1: LCD suspend settings in X.org

Section "ServerFlags"
Option "blank time" "5" # Blank the screen after 5 minutes (Fake)
Option "standby time" "10" # Turn off screen after 10 minutes (DPMS)
Option "suspend time" "20" # Full suspend after 20 minutes
Option "off time" "30" # Turn off after half an hour
[...]
EndSection

[...]

Section "Monitor"
Identifier [...]
Option "DPMS"
[...]
EndSection

Backlight dimming

Probably more important is the backlight dimming. If you have access to the dimming settings via a tool, write a small script that dims the backlight in battery mode and place it in your battery runlevel. The following script should work on most IBM Thinkpads and Toshiba laptops. You've got to enable the appropriate option in your kernel (IBM Thinkpads only). For Toshiba laptops, install sys-power/acpitool and skip configuration of thinkpad_acpi (formerly called ibm_acpi) as described below.

Warning: Support for setting brightness is marked experimental in thinkpad_acpi. It accesses hardware directly and may cause severe harm to your system. Please read the thinkpad_acpi website

To be able to set the brightness level, the thinkpad_acpi module has to be loaded with the experimental parameter.

Code Listing 4.2: automatically loading the thinkpad_acpi module

(Please read the warnings above before doing this!)
# echo "options thinkpad_acpi experimental=1" >> /etc/modules.d/thinkpad_acpi
# /sbin/update-modules
# echo thinkpad_acpi >> /etc/modules.autoload.d/kernel-2.6
# modprobe thinkpad_acpi

This should work without error messages and a file /proc/acpi/ibm/brightness should be created after loading the module. An init script will take care of choosing the brightness according to the power source.

Code Listing 4.3: /etc/conf.d/lcd-brightness

# See /proc/acpi/ibm/brightness for available values
# Please read /usr/src/linux/Documentation/thinkpad-acpi.txt

# brightness level in ac mode. Default is 7.
BRIGHTNESS_AC=7

# brightness level in battery mode. Default is 4.
BRIGHTNESS_BATTERY=4

Code Listing 4.4: /etc/init.d/lcd-brightness

#!/sbin/runscript

set_brightness() {
if on_ac_power
then
LEVEL=${BRIGHTNESS_AC:-7}
else
LEVEL=${BRIGHTNESS_BATTERY:-4}
fi

if [ -f /proc/acpi/ibm/brightness ]
then
ebegin "Setting LCD brightness"
echo "level ${LEVEL}" > /proc/acpi/ibm/brightness
eend $?
elif [[ -e /usr/bin/acpitool && -n $(acpitool -T | grep "LCD brightness") ]]
then
ebegin "Setting LCD brightness"
acpitool -l $LEVEL >/dev/null || ewarn "Unable to set lcd brightness"
eend $?
else
ewarn "Setting LCD brightness is not supported."
ewarn "For IBM Thinkpads, check that thinkpad_acpi is loaded into the kernel"
ewarn "For Toshiba laptops, you've got to install sys-power/acpitool"
fi
}

start() {
set_brightness
}

stop () {
set_brightness
}

When done, make sure brightness is adjusted automatically by adding it to the battery runlevel.

Code Listing 4.5: Enabling automatic brightness adjustment

# chmod +x /etc/init.d/lcd-brightness
# rc-update add lcd-brightness battery
# rc

5.  Disk Power Management

Hard disks consume less energy in sleep mode. Therefore it makes sense to activate power saving features whenever the hard disk is not used for a certain amount of time. I'll show you two alternative possibilities to do it. First, laptop-mode will save most energy due to several measures which prevent or at least delay write accesses. The drawback is that due to the delayed write accesses a power outage or kernel crash will be more dangerous for data loss. If you don't like this, you have to make sure that there are no processes which write to your hard disk frequently. Afterwards you can enable power saving features of your hard disk with hdparm as the second alternative.

Increasing idle time - laptop-mode

Recent 2.6 kernels include the so-called laptop-mode. When activated, dirty buffers are written to disk on read calls or after 10 minutes (instead of 30 seconds). This minimizes the time the hard disk needs to be spun up.

Code Listing 5.1: Automated start of laptop-mode

# emerge laptop-mode-tools 

laptop-mode-tools has its configuration file in /etc/laptop-mode/laptop-mode.conf. Adjust it the way you like it, it's well commented. Run rc-update add laptop_mode battery to start it automatically.

Recent versions (1.11 and later) of laptop-mode-tools include a new tool lm-profiler. It will monitor your system's disk usage and running network services and suggests to disable unneeded ones. You can either disable them through laptop-mode-tools builtin runlevel support (which will be reverted by Gentoo's /sbin/rc) or use your default/battery runlevels (recommended).

Code Listing 5.2: Sample output from running lm-profiler

# lm-profiler
Profiling session started.
Time remaining: 600 seconds
[4296896.602000] amarokapp
Time remaining: 599 seconds
[4296897.714000] sort
[4296897.970000] mv
Time remaining: 598 seconds
Time remaining: 597 seconds
[4296900.482000] reiserfs/0

After profiling your system for ten minutes, lm-profiler will present a list of services which might have caused disk accesses during that time.

Code Listing 5.3: lm-profiler suggests to disable some services

Program: "atd"
Reason: standard recommendation (program may not be running)
Init script: /etc/init.d/atd (GUESSED)

Do you want to disable this service in battery mode? [y/N]: n

To disable atd as suggested in the example above, you would run rc-update del atd battery. Be careful not to disable services that are needed for your system to run properly - lm-profiler is likely to generate some false positives. Do not disable a service if you are unsure whether it's needed.

Limiting Write Accesses

If you don't want to use laptop-mode, you must take special care to disable services that write to your disk frequently - syslogd is a good candidate, for example. You probably don't want to shut it down completely, but it's possible to modify the config file so that "unnecessary" things don't get logged and thus don't create disk traffic. Cups writes to disk periodically, so consider shutting it down and only enable it manually when needed.

Code Listing 5.4: Disabling cups in battery mode

# rc-update del cupsd battery 

You can also use lm-profiler from laptop-mode-tools (see above) to find services to disable. Once you eliminated all of them, go on with configuring hdparm.

hdparm

The second possibility is using hdparm. Skip this if you are using laptop-mode. Otherwise, edit /etc/conf.d/hdparm and add the following values to your drive entries. This example assumes your hard drive is called hda:

Code Listing 5.5: Using /etc/conf.d/hdparm for disk standby

hda_args="-q -S12"

This will activate power management for your hard drive. If you ever want to deactivate power management, you can edit /etc/conf.d/hdparm and change the values to -q -S0, or just run hdparm -q -S0 /dev/hda.

See man hdparm for the options. Though you can always start hdparm manually when you are on battery power by running /etc/init.d/hdparm start, it's much easier to automate its startup and shutdown. To do so, add hdparm to the battery runlevel so that it will automatically enable power management.

Code Listing 5.6: Automate disk standby settings

# rc-update add hdparm battery 

Important: Be careful with sleep/spin down settings of your hard drive. Setting it to small values might wear out your drive and lose warranty.

Other tricks

Another possibility is to deactivate swap in battery mode. Before writing a swapon/swapoff switcher, make sure there is enough RAM and swap isn't used heavily, otherwise you'll be in big problems.

If you don't want to use laptop-mode, it's still possible to minimize disk access by mounting certain directories as tmpfs - write accesses are not stored on a disk, but in main memory and get lost with unmounting. Often it's useful to mount /tmp like this - you don't have to pay special attention as it gets cleared on every reboot regardless whether it was mounted on disk or in RAM. Just make sure you have enough RAM and no program (like a download client or compress utility) needs extraordinary much space in /tmp. To activate this, enable tmpfs support in your kernel and add a line to /etc/fstab like this:

Code Listing 5.7: Editing /etc/fstab to make /tmp even more volatile

none /tmp tmpfs size=32m 0 0

Warning: Pay attention to the size parameter and modify it for your system. If you're unsure, don't try this at all, it can become a performance bottleneck easily. In case you want to mount /var/log like this, make sure to merge the log files to disk before unmounting. They are essential. Don't attempt to mount /var/tmp like this. Portage uses it for compiling...

6.  Power Management For Other Devices

Graphics Cards

In case you own an ATI graphics card supporting PowerPlay (dynamic clock scaling for the graphics processing unit GPU), you can activate this feature in X.org. Open /etc/X11/xorg.conf and add (or enable) the DynamicClocks option in the Device section. Please notice that this feature will lead to crashes on some systems.

Code Listing 6.1: Enabling ATI PowerPlay support in X.org

Section "Device"
[...]
Option "DynamicClocks" "on"
EndSection

Wireless Power Management

Wireless LAN cards consume quite a bit of energy. Put them in Power Management mode just like your hard drives.

Note: This script assumes your wireless interface is called wlan0; replace this with the actual name of your interface.

Add the following option to /etc/conf.d/net to automatically enable power management for your wireless card:

Code Listing 6.2: Automated WLAN Power Management

iwconfig_wlan0="power on"

See man iwconfig for details and more options like the period between wakeups or timeout settings. If your driver and access point support changing the beacon time, this is a good starting point to save even more energy.

USB Power Management

There are two problems with USB devices regarding energy consumption: First, devices like USB mice, digital cameras or USB sticks consume energy while plugged in. You cannot avoid this (nevertheless remove them in case they're not needed). Second, when there are USB devices plugged in, the USB host controller periodically accesses the bus which in turn prevents the CPU from going into sleep mode. The kernel offers an experimental option to enable suspension of USB devices through driver calls or one of the power/state files in /sys.

Code Listing 6.3: Enabling USB suspend support in the kernel

Device Drivers
USB support
[*] Support for Host-side USB
[*] USB suspend/resume (EXPERIMENTAL)

7.  Sleep States: sleep, standby, and suspend to disk

ACPI defines different sleep states. The more important ones are

  • S1 aka Standby
  • S3 aka Suspend to RAM aka Sleep
  • S4 aka Suspend to Disk aka Hibernate

They can be called whenever the system is not in use, but a shutdown is not wanted due to the long boot time.

Sleep (S3)

The ACPI support for these sleep states is marked experimental for good reason. APM sleep states seem to be more stable, however you can't use APM and ACPI together.

Code Listing 7.1: Kernel configuration for the various suspend types

 Power Management Options --->
[*] Power Management support
ACPI (Advanced Configuration and Power Interface) Support --->
[*] ACPI Support
[*] Sleep States

Once your kernel is properly configured, you can use the hibernate-script to activate suspend or sleep mode. Let's install that first.

Code Listing 7.2: Installing the hibernate-script

# emerge hibernate-script 

Some configuration has to be done in /etc/hibernate. The default package introduces a few configuration files for each sleep state. Options that are common to all suspend methods are placed in common.conf; make sure this file is properly set up for your system.

To configure sleep, edit sysfs-ram.conf in /etc/hibernate. UseSysfsPowerState mem is already setup correctly, but if you need to make further changes to this particular sleep state (or any other sleep state) you should add them to /etc/hibernate/hibernate.conf. The comments and option names will guide you. If you use nfs or samba shares over the network, make sure to shutdown the appropriate init scripts to avoid timeouts.

Note: For more information on setting up sleep states, read man hibernate.conf.

Ready? Now is the last chance to backup any data you want to keep after executing the next command. Notice that you probably have to hit a special key like Fn to resume from sleep.

Code Listing 7.3: Calling sleep

# hibernate-ram 

If you're still reading, it seems to work. You can also setup standby (S1) in a similar way by editing sysfs-ram.conf and changing "UseSysfsPowerState mem" to "UseSysfsPowerState standby". S3 and S4 are the more interesting sleep states due to greater energy savings however.

Hibernate (S4)

This section introduces hibernation, where a snapshot of the running system is written to disk before powering off. On resume, the snapshot is loaded and you can go on working at exactly the point you called hibernate before.

Warning: Don't exchange non hot-pluggable hardware when suspended. Don't attempt to load a snapshot with a different kernel image than the one it was created with. Shutdown any NFS or samba server/client before hibernating.

There are two different implementations for S4. The original one is swsusp, then there is the newer tuxonice (former suspend2) with a nicer interface (including fbsplash support). A feature comparison is available at the tuxonice Homepage. There used to be Suspend-to-Disk (pmdisk), a fork of swsusp, but it has been merged back.

TuxOnIce is not included in the mainline kernel yet, therefore you either have to patch your kernel sources with the patches provided by tuxonice.net or use sys-kernel/tuxonice-sources.

The kernel part for both swusp and TuxOnIce is as follows:

Code Listing 7.4: Kernel configuration for the various suspend types

Power Management Options --->
(hibernate with swsusp)
[*] Software Suspend
(replace /dev/SWAP with your swap partition)
(/dev/SWAP) Default resume partition

(hibernate with TuxOnIce)
Enhanced Hibernation (TuxOnIce)
--- Image Storage (you need at least one writer)
[*] File Writer
[*] Swap Writer
--- General Options
[*] LZF image compression
(replace /dev/SWAP with your swap partition)
(swap:/dev/SWAP) Default resume device name
[ ] Allow Keep Image Mode

The configuration for swsusp is rather easy. If you didn't store the location of your swap partition in the kernel config, you can also pass it as a parameter with the resume=/dev/SWAP directive. If booting is not possible due to a broken image, use the noresume kernel parameter. The hibernate-cleanup init script invalidates swsusp images during the boot process.

Code Listing 7.5: Invalidating swsusp images during the boot process

# rc-update add hibernate-cleanup boot 

To activate hibernate with swsusp, use the hibernate script and set UseSysfsPowerState disk in /etc/hibernate/sysfs-disk.

Warning: Backup your data before doing this. Run sync before executing one of the commands to have cached data written to disk. First try it outside of X, then with X running, but not logged in.

If you experience kernel panics due to uhci or similar, try to compile USB support as module and unload the modules before sending your laptop to sleep mode. There are configuration options for this in common.conf

Code Listing 7.6: Hibernating with swsusp

# nano -w /etc/hibernate/common.conf
(Make sure you have a backup of your data)
# hibernate

The following section discusses the setup of TuxOnIce including fbsplash support for a nice graphical progress bar during suspend and resume.

The first part of the configuration is similar to the configuration of swsusp. In case you didn't store the location of your swap partition in the kernel config, you have to pass it as a kernel parameter with the resume=swap:/dev/SWAP directive. If booting is not possible due to a broken image, append the noresume parameter. Additionally, the hibernate-cleanup init script invalidates TuxOnIce images during the boot process.

Code Listing 7.7: Invalidating TuxOnIce images during the boot process

# rc-update add hibernate-cleanup boot 

Now edit /etc/hibernate/suspend2.conf, enable the TuxOnIce options you need. Do not enable the fbsplash options in common.conf just yet.

Code Listing 7.8: Hibernating with TuxOnIce

# nano -w /etc/hibernate/suspend2.conf
(Make sure you have a backup of your data)
# hibernate

Please configure fbsplash now if you didn't do already. To enable fbsplash support during hibernation, the sys-apps/tuxonice-userui package is needed. Additionally, you've got to enable the fbsplash USE flag.

Code Listing 7.9: Installing tuxonice-userui

# echo "sys-apps/tuxonice-userui fbsplash" >> /etc/portage/package.use
(It may be marked ~arch, so first it must be keyworded)
# echo "sys-apps/tuxonice-userui" >> /etc/portage/package.keywords
# emerge tuxonice-userui

The ebuild tells you to make a symlink to the theme you want to use. For example, to use the livecd-2005.1 theme, run the following command:

Code Listing 7.10: Using the livecd-2005.1 theme during hibernation

# ln -sfn /etc/splash/livecd-2005.1 /etc/splash/suspend2 

If you don't want a black screen in the first part of the resume process, you have to add the tuxoniceui_fbsplash tool to your initrd image. Assuming you created the initrd image with splash_geninitramfs and saved it as /boot/fbsplash-emergence-1024x768, here's how to do that.

Code Listing 7.11: Adding tuxoniceui_fbsplash to an initrd image

# mount /boot
# mkdir ~/initrd.d
# cp /boot/fbsplash-emergence-1024x768 ~/initrd.d/
# cd ~/initrd.d
# gunzip -c fbsplash-emergence-1024x768 | cpio -idm --quiet -H newc
# rm fbsplash-emergence-1024x768
# cp /usr/sbin/tuxoniceui_fbsplash sbin/
# find . | cpio --quiet --dereference -o -H newc | gzip -9 > /boot/fbsplash-tuxonice-emergence-1024x768

Afterwards adjust grub.conf (or lilo.conf) so that your TuxOnIce kernel uses /boot/fbsplash-tuxonice-emergence-1024x768 as initrd image. You can now test a dry run to see if everything is setup correctly.

Code Listing 7.12: Test run for fbsplash hibernation

# tuxoniceui_fbsplash -t 

Afterwards open /etc/hibernate/common.conf and activate the fbsplash options. Execute hibernate and enjoy.

8.  Troubleshooting

Q: I'm trying to change the CPU frequency, but /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor does not exist.

A: Make sure your processor supports CPU frequency scaling and you chose the right CPUFreq driver for your processor. Here is a list of processors that are supported by cpufreq (kernel 2.6.7): ARM Integrator, ARM-SA1100, ARM-SA1110, AMD Elan - SC400, SC410, AMD mobile K6-2+, AMD mobile K6-3+, AMD mobile Duron, AMD mobile Athlon, AMD Opteron, AMD Athlon 64, Cyrix Media GXm, Intel mobile PIII and Intel mobile PIII-M on certain chipsets, Intel Pentium 4, Intel Xeon, Intel Pentium M (Centrino), National Semiconductors Geode GX, Transmeta Crusoe, VIA Cyrix 3 / C3, UltraSPARC-III, SuperH SH-3, SH-4, several "PowerBook" and "iBook2" and various processors on some ACPI 2.0-compatible systems (only if "ACPI Processor Performance States" are available to the ACPI/BIOS interface).

Q: My laptop supports frequency scaling, but /sys/devices/system/cpu/cpu0/cpufreq/ is empty.

A: Look for ACPI related error messages with dmesg | grep ACPI. Try to update the BIOS, especially if a broken DSDT is reported. You can also try to fix it yourself (which is beyond the scope of this guide).

Q: My laptop supports frequency scaling, but according to /proc/cpuinfo the speed never changes.

A: Probably you have activated symmetric multiprocessing support (CONFIG_SMP) in your kernel. Deactivate it and it should work. Some older kernels had a bug causing this. In that case, run emerge x86info, update your kernel as asked and check the current frequency with x86info -mhz.

Q: I can change the CPU frequency, but the range is not as wide as in another OS.

A: You can combine frequency scaling with ACPI throttling to get a lower minimum frequency. Notice that throttling doesn't save much energy and is mainly used for thermal management (keeping your laptop cool and quiet). You can read the current throttling state with cat /proc/acpi/processor/CPU/throttling and change it with echo -n "0:x" > /proc/acpi/processor/CPU/limit, where x is one of the Tx states listed in /proc/acpi/processor/CPU/throttling.

Q: When configuring the kernel, powersave, performance and userspace governors show up, but that ondemand thing is missing. Where do I get it?

A: The ondemand governor is only included in recent kernel sources. Try updating them.

Q: Battery life time seems to be worse than before.

A: Check your BIOS settings. Maybe you forgot to re-enable some of the settings.

Q: My battery is charged, but KDE reports there would be 0% left and immediately shuts down.

A: Check that battery support is compiled into your kernel. If you use it as a module, make sure the module is loaded.

Q: My system logger reports things like "logger: ACPI group battery / action battery is not defined".

A: This message is generated by the /etc/acpi/default.sh script that is shipped with acpid. You can safely ignore it. If you like to get rid of it, you can comment the appropriate line in /etc/acpi/default.sh as shown below:

Code Listing 8.1: Disabling warnings about unknown acpi events

 *) # logger "ACPI action $action is not defined"

Q: I have a Dell Inspiron 51XX and I don't get any ACPI events.

A: This seems to be a kernel bug. Read on here.

Q: I activated the DynamicClocks option in xorg.conf and now X.org crashes / the screen stays black / my laptop doesn't shutdown properly.

A: This happens on some systems. You have to disable DynamicClocks.

Q: I want to use TuxOnIce, but it tells me my swap partition is too small. Resizing is not an option.

A: If there is enough free space on your system, you can use the filewriter instead of the swapwriter. The hibernate-script supports it as well. More information can be found in /usr/src/linux/Documentation/power/tuxonice.txt.

Q: I just bought a brand new battery, but it only lasts for some minutes! What am I doing wrong?

A: First follow your manufacturer's advice on how to charge the battery correctly.

Q: The above didn't help. What should I do then?

A: Some batteries sold as "new" are in fact old ones. Try the following:

Code Listing 8.2: Querying battery state

$ grep capacity /proc/acpi/battery/BAT0/info
design capacity: 47520 mWh
last full capacity: 41830 mWh

If the "last full capacity" differs significantly from the design capacity, your battery is probably broken. Try to claim your warranty.

Q: My problem is not listed above. Where should I go next?

A: Don't fear to contact me, Dennis Nienhüser, directly. The Gentoo Forums are a good place to get help as well. If you prefer IRC, try the #gentoo-laptop channel at irc.freenode.net.

相关阅读 更多

热门下载

更多