/[gentoo]/xml/htdocs/doc/en/power-management-guide.xml
Gentoo

Diff of /xml/htdocs/doc/en/power-management-guide.xml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.48 Revision 1.49
1<?xml version='1.0' encoding="UTF-8"?> 1<?xml version='1.0' encoding="UTF-8"?>
2<!DOCTYPE guide SYSTEM "/dtd/guide.dtd"> 2<!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
3<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/power-management-guide.xml,v 1.48 2011/08/17 07:19:29 swift Exp $ --> 3<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/power-management-guide.xml,v 1.49 2011/09/23 18:41:52 swift Exp $ -->
4 4
5<guide> 5<guide>
6<title>Power Management Guide</title> 6<title>Power Management Guide</title>
7 7
8<author title="Author"> 8<author title="Author">
9 <mail link="earthwings@gentoo.org">Dennis Nienhüser</mail> 9 <mail link="swift"/>
10</author> 10</author>
11<author title="Editor">
12 <mail link="chriswhite@gentoo.org">Chris White</mail>
13</author>
14<author title="Editor">
15 <mail link="nightmorph"/>
16</author>
17 11
18<abstract> 12<abstract>
19Power Management is the key to extend battery run time on mobile systems like 13In recent years, power management has become one of the differentiating
20laptops. This guide assists you setting it up on your laptop. 14features in the quest for finding the perfect laptop. Yet, the operating system
15must support the various power saving functionalities too. In this guide, we
16cover how to setup your Gentoo installation so it manages power-hungry resources
17in a flexible yet automated manner.
21</abstract> 18</abstract>
22 19
23<!-- The content of this document is licensed under the CC-BY-SA license --> 20<!-- The content of this document is licensed under the CC-BY-SA license -->
24<!-- See http://creativecommons.org/licenses/by-sa/2.5 --> 21<!-- See http://creativecommons.org/licenses/by-sa/2.5 -->
25<license/> 22<license/>
26 23
27<version>4</version> 24<version>5</version>
28<date>2011-08-17</date> 25<date>2011-09-22</date>
29 26
30<chapter> 27<chapter>
31<title>Introduction</title> 28<title>Introduction</title>
32<section> 29<section>
30<title>About this document...</title>
31<body>
32
33<p>
34This document describes the setup of power management features on your laptop.
35Although some of the information in this guide can be applied to power
36management for servers, it is not the intention of this document to go that
37route. Please be careful when applying this on a non-laptop system.
38</p>
39
40<p>
41Within this document, we will focus primarily on the laptop mode tools since it
42offers a complete set of functionalities. However, we will also refer to other
43tools that might offer a more detailed approach on individual settings. In such
44cases, you will need to disable the feature from the laptop mode tools so that
45both tools do not fight over the same resource control.
46</p>
47
33<body> 48</body>
49</section>
50<section>
51<title>About laptop_mode</title>
52<body>
34 53
54<p>
55The <c>laptop_mode</c> setting is an in-kernel configuration setting that
56optimizes I/O, allowing disks to spin down properly (and not be woken up
57immediately afterwards for queued operations).
58</p>
59
60</body>
61</section>
62<section>
63<title>About laptop-mode-tools</title>
64<body>
65
66<p>
67The <e>Laptop Mode Tools</e> is a software package
68(<c>app-laptop/laptop-mode-tools</c>) which allows the user to optimize power
69saving functions. It allows managing the <c>laptop_mode</c> setting in the Linux
70kernel, but has additional features allowing you to tweak other power-related
71settings on the system.
72</p>
73
74</body>
75</section>
76</chapter>
77
78<chapter>
79<title>Linux Kernel Configuration</title>
80<section>
81<title>Minimum kernel setup</title>
82<body>
83
84<p>
85There are different kernel sources in Portage. We recommend using
86<c>gentoo-sources</c>, but if you want advanced hibernation support you might
87need <c>tuxonice-sources</c>. To enable proper power management features in the
88Linux kernel, enable at least the following settings:
89</p>
90
91<pre caption="Minimum kernel setup for Power Management (Kernel 2.6)">
92<![CDATA[
93General setup --->
94 [*] Configure standard kernel features (expert users) --->
95
96Power management and ACPI options --->
97 [*] ACPI (Advanced Configuration and Power Interface) Support --->
98 <*> AC Adapter
99 <*> Battery
100 -*- Button
101 -*- Video
102 <*> Fan
103 <*> Processor
104 <*> Thermal Zone
105 [*] Power Management Timer Support
106
107 [*] CPU Frequency scaling --->
108 [*] CPU Frequency scaling
109 <*> 'performance' governor
110 <*> 'powersave' governor
111 <*> 'userspace' governor
112 <*> 'ondemand' governor
113 <*> 'conservative' governor
114 <*> ACPI Processor P-States driver
115]]>
116</pre>
117
118<p>
119Don't forget to enable the CPU frequency scaling driver for your CPU, located
120right after the <e>ACPI Processor P-States driver</e> mentioned above.
121</p>
122
123<p>
124Build and install the new kernel (if necessary) and reboot.
125</p>
126
127</body>
128</section>
35<!-- 129<!--
36 Remove this note after 6 months - ETA 01/02/2012 130<section id="kernelconfig">
37 By then, we can assume that OpenRC migrations are not that frequent 131<title>Additional kernel configuration entries</title>
38 anymore and this note can be dropped. 132<body>
39 ~ Sven Vermeulen 133
134<p>
135Further down this guide, additional kernel settings might be suggested. To
136lessen the effort to maintain the guide, and to make sure settings are correctly
137identified, we will use the kernel configuration short-hand notations. These
138notations are simple strings, like <c>CONFIG_USB_SUSPEND</c>. But how to read
139this?
140</p>
141
142<p>
143Well, then you configure your kernel (through <c>make menuconfig</c>), you can
144search through the configuration settings for a particular entry. Press <c>/</c>
145while configuring the Linux kernel and type the setting
146(<c>CONFIG_USB_SUSPEND</c>). The software will tell you what the setting is,
147what it is for, when you can select it (i.e. on which settings it depends before
148you can see it) but most importantly, where you can find it.
149</p>
150
151<pre caption="Result of a search operation during menuconfig">
152<![CDATA[Symbol: USB_SUSPEND [=n]
153Type : boolean
154Prompt: USB runtime power management (autosuspend) and wakeup
155 Defined at drivers/usb/core/Kconfig:93
156 Depends on: USB_SUPPORT [=y] && USB [=y] && PM_RUNTIME [=n]
157 Location:
158 -> Device Drivers
159 -> USB support (USB_SUPPORT [=y])
160 -> Support for Host-side USB (USB [=y]) ]]>
161</pre>
162
163</body>
164</section>
40--> 165-->
41<impo>
42Since the introduction of OpenRC, the <c>pmg_switch_runlevel.sh</c> script
43needs to be updated. If you have issues after the OpenRC upgrade, please update
44this script according to this guide.
45</impo>
46
47<p>
48Capacity and lifetime of laptop batteries have improved much in the last years.
49Nevertheless modern processors consume much more energy than older ones and
50each laptop generation introduces more devices hungry for energy. That's why
51Power Management is more important than ever. Increasing battery run time
52doesn't necessarily mean buying another battery. Much can be achieved applying
53intelligent Power Management policies.
54</p>
55
56</body>
57</section>
58<section>
59<title>A Quick Overview</title>
60<body>
61
62<p>
63Please notice that this guide describes Power Management for <e>laptops</e>.
64While some sections might also suite for <e>servers</e>, others do not and may
65even cause harm. Please do not apply anything from this guide to a server
66unless you really know what you are doing.
67</p>
68
69<p>
70As this guide has become rather long, here's a short overview helping you to
71find your way through it.
72</p>
73
74<p>
75The <uri link="#doc_chap2">Prerequisites</uri> chapter talks about some
76requirements that should be met before any of the following device individual
77sections will work. This includes BIOS settings, kernel configuration and some
78simplifications in user land. The following three chapters focus on devices
79that typically consume most energy - processor, display and hard drive. Each
80can be configured separately. <uri link="#doc_chap3">CPU Power Management</uri>
81shows how to adjust the processor's frequency to save a maximum of energy
82without losing too much performance. A few different tricks prevent your hard
83drive from working unnecessarily often in <uri link="#doc_chap5">Disk Power
84Management</uri> (decreasing noise level as a nice side effect). Some notes on
85graphics cards, Wireless LAN and USB finish the device section in <uri
86link="#doc_chap6">Power Management For Other Devices</uri> while another
87chapter is dedicated to the (rather experimental) <uri link="#doc_chap7">sleep
88states</uri>. Last not least <uri link="#doc_chap8">Troubleshooting</uri> lists
89common pitfalls.
90</p>
91
92</body>
93</section>
94<section>
95<title>Power Budget For Each Component</title>
96<body>
97
98<figure link="/images/energy-budget.png" short="Which component consumes how
99much energy?" caption="Power budget for each component"/>
100
101<p>
102Nearly every component can operate in different states - off, sleep, idle,
103active to name a few - consuming a different amount of energy. Major parts are
104consumed by the LCD display, CPU, chipset and hard drives. Often one is able to
105activate OS-independent Power Management in the BIOS, but an intelligent setup
106in the operating system adapting to different situations can achieve much more.
107</p>
108
109</body>
110</section>
111</chapter> 166</chapter>
112 167
113<chapter> 168<chapter>
114<title>Prerequisites</title> 169<title>Using Laptop Mode Tools</title>
115<section>
116<body>
117
118<p>
119Before discussing the details of making individual devices Power Management
120aware, make sure certain requirements are met. After controlling BIOS settings,
121some kernel options want to be enabled - these are in short ACPI, sleep states
122and CPU frequency scaling. As power saving most of the time comes along with
123performance loss or increased latency, it should only be enabled when running
124on batteries. That's where a new runlevel <e>battery</e> comes in handy.
125</p>
126
127</body>
128</section> 170<section>
129<section> 171<title>Installation</title>
130<title>The BIOS Part</title>
131<body>
132
133<p>
134First have a look into your BIOS Power Management settings. The best way is to
135combine BIOS and operating system policies, but for the moment it's better to
136disable most of the BIOS part. This makes sure it doesn't interfere with your
137policies. Don't forget to re-check BIOS settings after you configured
138everything else.
139</p>
140
141</body> 172<body>
142</section>
143<section>
144<title>Setting USE Flags</title>
145<body>
146 173
147<p>
148Please check that the <c>acpi</c> USE flag is set in
149<path>/etc/make.conf</path>. Other USE flags that might be interesting for your
150system are <c>apm</c>, <c>lm_sensors</c>, <c>nforce2</c>, <c>nvidia</c>,
151<c>pmu</c>. See <path>/usr/portage/profiles/use*.desc</path> for details. If
152you forgot to set one of these flags, you can recompile affected packages using
153the <c>--newuse</c> flag in <c>emerge</c>, see <c>man emerge</c>.
154</p> 174<p>
155 175It comes to no surprise that installation of the <e>Laptop Mode Tools</e>
156</body> 176software is easily done through <c>emerge laptop-mode-tools</c>. However, this
157</section> 177package takes on additional, optional settings through USE flag configuration.
158<section> 178So let's first take a look at the supported USE flags and what they mean to the
159<title>Configuring The Kernel</title> 179package.
160<body>
161
162<p> 180</p>
163ACPI (Advanced Configuration and Power Interface) support in the kernel is 181
164still work in progress. Using a recent kernel will make sure you'll get the 182<table>
165most out of it. 183<tr>
184 <th>USE flag</th>
185 <th>Description</th>
186 <th>Suggested when...</th>
187</tr>
188<tr>
189 <ti>acpi</ti>
190 <ti>
191 Depend on <c>sys-power/acpid</c> so that changes in the system are
192 captured and power saving features are automatically enabled/disabled.
193 </ti>
194 <ti>your laptop is not too old (~ year 2003 and later)</ti>
195</tr>
196<tr>
197 <ti>apm</ti>
198 <ti>
199 Depend on <c>sys-apps/apmd</c> so that changes in the system are captured
200 and power saving features are automatically enabled/disabled.
201 </ti>
202 <ti>your laptop is very old</ti>
203</tr>
204<tr>
205 <ti>bluetooth</ti>
206 <ti>
207 Depend on <c>net-wireless/bluez</c>, enabling the <c>laptop-mode-tools</c>
208 to manage bluetooth settings (enabling/disabling the service based on
209 battery availability)
210 </ti>
211 <ti>your laptop (and kernel) supports bluetooth</ti>
212</tr>
213<tr>
214 <ti>scsi</ti>
215 <ti>
216 Depend on <c>sys-apps/sdparm</c>, enabling the <c>laptop-mode-tools</c> to
217 manage SCSI (<e>and not</e> SATA) disk parameters.
218 </ti>
219 <ti>your laptop uses SCSI disks</ti>
220</tr>
221</table>
222
166</p> 223<p>
167 224As you can see, there are two USE flags that seem to collide: <c>acpi</c> and
225<c>apm</c>. So what's the deal there?
168<p> 226</p>
169There are different kernel sources in Portage. I'd recommend using 227
170<c>gentoo-sources</c> or <c>tuxonice-sources</c>. The latter contains patches 228<ul>
171for TuxOnIce, see the chapter about <uri link="#doc_chap7">sleep states</uri> 229 <li>
172for more details. When configuring the kernel, activate at least these options: 230 The <c>apm</c> USE flag enables support for <e>Advanced Power
231 Management</e>, an older (before year 2000) standard for power management
232 features within a system.
233 </li>
234 <li>
235 The <c>acpi</c> USE flag enables support for <e>Advanced Configuration and
236 Power Interface</e>, the successor of APM. All modern laptops support ACPI.
237 </li>
238</ul>
239
173</p> 240<p>
174 241Depending on your system, you will either need <c>acpi</c> or <c>apm</c> set. In
175<pre caption="Minimum kernel setup for Power Management (Kernel 2.6)"> 242the remainder of this guide, we assume that your laptop is recent enough to use
176Power management and ACPI options ---&gt; 243ACPI.
177[*] Power Management support
178 [ ] Software Suspend
179
180 ACPI( Advanced Configuration and Power Interface ) Support ---&gt;
181 [ ] Deprecated /proc/acpi/ files
182 [*] AC Adapter
183 [*] Battery
184 &lt;M&gt; Button
185 &lt;M&gt; Video
186 [ ] Generic Hotkey
187 &lt;M&gt; Fan
188 &lt;M&gt; Processor
189 &lt;M&gt; Thermal Zone
190 &lt; &gt; ASUS/Medion Laptop Extras
191 &lt; &gt; IBM ThinkPad Laptop Extras
192 &lt; &gt; Toshiba Laptop Extras
193 (0) Disable ACPI for systems before Jan 1st this year
194 [ ] Debug Statements
195 [*] Power Management Timer Support
196 &lt; &gt; ACPI0004,PNP0A05 and PNP0A06 Container Driver (EXPERIMENTAL)
197
198 CPU Frequency Scaling ---&gt;
199 [*] CPU Frequency scaling
200 [ ] Enable CPUfreq debugging
201 &lt; &gt; CPU frequency translation statistics
202 [ ] CPU frequency translation statistics details
203 Default CPUFreq governor (userspace)
204 &lt;*&gt; 'performance' governor
205 &lt;*&gt; 'powersave' governor
206 &lt;*&gt; 'ondemand' cpufreq policy governor
207 &lt;*&gt; 'conservative' cpufreq governor
208 &lt;*&gt; CPU frequency table helpers
209 &lt;M&gt; ACPI Processor P-States driver
210 &lt;*&gt; <i>CPUFreq driver for your processor</i>
211</pre>
212
213<p> 244</p>
214Decide yourself whether you want to enable Software Suspend, and Sleep States 245
215(see below). If you own an ASUS, Medion, IBM Thinkpad or Toshiba laptop, enable
216the appropriate section.
217</p> 246<p>
218 247So, with the USE flags set, let's install <c>laptop-mode-tools</c>.
219<p>
220The kernel has to know how to enable CPU frequency scaling on your processor.
221As each type of CPU has a different interface, you've got to choose the right
222driver for your processor. Be careful here - enabling <c>Intel Pentium 4 clock
223modulation</c> on a Pentium M system will lead to strange results for example.
224Consult the kernel documentation if you're unsure which one to take.
225</p>
226
227<p>
228Compile your kernel, make sure the right modules get loaded at startup and boot
229into your new ACPI-enabled kernel. Next run <c>emerge sys-power/acpid</c> to
230get the acpi daemon. This one informs you about events like switching from AC
231to battery or closing the lid. Make sure the modules are loaded if you didn't
232compile them into the kernel and start acpid by executing <c>/etc/init.d/acpid
233start</c>. Run <c>rc-update add acpid default</c> to load it on startup. You'll
234soon see how to use it.
235</p>
236
237<pre caption="Installing acpid">
238# <i>emerge sys-power/acpid</i>
239# <i>/etc/init.d/acpid start</i>
240# <i>rc-update add acpid default</i>
241</pre>
242
243</body>
244</section>
245<section>
246<title>Creating A "battery" Runlevel</title>
247<body>
248
249<p>
250The default policy will be to enable Power Management only when needed -
251running on batteries. To make the switch between AC and battery convenient,
252create a runlevel <c>battery</c> that holds all the scripts starting and
253stopping Power Management.
254</p> 248</p>
255 249
256<note> 250<note>
257You can safely skip this section if you don't like the idea of having another 251If you have USE="acpi" set, the installation will pull in <c>acpid</c>. However,
258runlevel. However, skipping this step will make the rest a bit trickier to set 252the current stable ACPI daemon (2.0.9) does not support the new ACPI interfaces
259up. The next sections assume a runlevel <c>battery</c> exists. 253within the Linux kernel (using the netlink interface). As such, we recommend
254unmasking <c>sys-power/acpid-2.0.12</c> (or higher). For more information about
255unmasking packages, please read
256<uri link="/doc/en/handbook/handbook-amd64.xml?part=3&amp;chap=3">Mixing Software
257Branches</uri> in the Gentoo Handbook.
260</note> 258</note>
261 259
262<pre caption="Creating a battery runlevel"> 260<pre caption="Installing laptop-mode-tools">
263# <i>cd /etc/runlevels</i> 261# <i>emerge laptop-mode-tools</i>
264# <i>cp -a default battery</i>
265</pre>
266
267<p>
268Finished. Your new runlevel <c>battery</c> contains everything like
269<c>default</c>, but there is no automatic switch between both yet. Time to
270change it.
271</p> 262</pre>
272 263
273</body> 264</body>
274</section>
275<section> 265</section>
276<title>Reacting On ACPI Events</title> 266<section>
267<title>Configuration</title>
268<body>
269
270<p>
271Having <c>laptop-mode-tools</c> installed on your system does not automatically
272enable the power management features that you might need. To configure the
273package, first take a look at <path>/etc/laptop-mode/laptop-mode.conf</path>.
274This is the main configuration file for the package and is pretty well described
275(through comments).
276</p>
277
278<p>
279But it is not the only configuration file to work with. The Laptop Mode Tools
280package supports plugins (or modules) which have their own configuration
281file(s). These files are located in <path>/etc/laptop-mode/conf.d</path> and are
282named after the module they represent (such as
283<path>intel-sata-powermgmt.conf</path>).
284</p>
285
286<p>
287Now, one of the important settings in each configuration file is if the Laptop
288Mode Tools package should govern a particular setting or not. This is important
289when you want to combine <c>laptop-mode-tools</c> with other services like
290<c>cpufreqd</c>. In this example case, you will need to set
291<c>CONTROL_CPU_FREQUENCY=0</c>:
292</p>
293
294<pre caption="Editing /etc/laptop-mode/conf.d/cpufreq.conf">
295# <i>nano -w /etc/laptop-mode/conf.d/cpufreq.conf</i>
296CONTROL_CPU_FREQUENCY=<i>0</i>
297</pre>
298
299<p>
300The next few sections will help you configure <c>laptop-mode-tools</c> to suit
301your needs. When you are finished, start the <c>laptop_mode</c> service and make
302sure it is started when you boot up your system.
303</p>
304
305<pre caption="Starting the laptop_mode service">
306# <i>/etc/init.d/laptop_mode start</i>
307# <i>rc-update add laptop_mode default</i>
308</pre>
309
277<body> 310</body>
311</section>
312<section>
313<title>How does laptop-mode-tools work</title>
314<body>
278 315
279<p>
280Typical ACPI events are closing the lid, changing the power source or pressing
281the sleep button. An important event is changing the power source, which should
282cause a runlevel switch. A small script will take care of it.
283</p> 316<p>
284 317When running the <c>laptop_mode</c> service, the software will check in which
318state your system is in. The states are defined as:
285<p> 319</p>
286First you need a script which changes the runlevel to <c>default</c> 320
287respectively <c>battery</c> depending on the power source. The script uses the 321<ul>
288<c>on_ac_power</c> command from <c>sys-power/pm-utils</c> - make sure the 322 <li>
289package is installed on your system. 323 <e>Battery</e>, in the configuration files using the <c>BATT_</c> prefix, is
324 active when the system is running on battery power
325 </li>
326 <li>
327 <e>AC</e>, in the configuration files using the <c>AC_</c> prefix, is active
328 when the system is running on AC power
329 </li>
330 <li>
331 <e>Laptop Mode</e>, in the configuration files using the <c>LM_</c> prefix,
332 is active when <e>laptop mode</e> is enabled
333 </li>
334 <li>
335 <e>No Laptop Mode</e>, in the configuration files using the <c>NOLM_</c>
336 prefix, is active when <e>laptop mode</e> is disabled
337 </li>
338</ul>
339
290</p> 340<p>
291 341The <c>AC/BATT_</c> and <c>LM/NOLM_</c> prefixes can be combined (so you can
292<pre caption="Installing pm-utils"> 342have a <c>AC_LM_</c> prefix).
293# <i>emerge pm-utils</i>
294</pre>
295
296<p> 343</p>
297You are now able to determine the power source by executing <c>on_ac_power 344
298&amp;&amp; echo AC available || echo Running on batteries</c> in a shell. The
299script below is responsible for changing runlevels. Save it as
300<path>/etc/acpi/actions/pmg_switch_runlevel.sh</path>.
301</p> 345<p>
302 346When the <c>laptop_mode</c> service is started, it will switch modes based on
303<pre caption="/etc/acpi/actions/pmg_switch_runlevel.sh"> 347events that occur (and of course based on the configuration settings). For
304#!/bin/bash 348instance, the setting <c>ENABLE_LAPTOP_MODE_ON_BATTERY=1</c> will make sure that
305 349the laptop mode tools switch to <e>laptop mode</e> when battery power is used.
306# BEGIN configuration 350If that is the case, then the settings starting with <c>LM_</c>,
307RUNLEVEL_AC="default" 351<c>LM_BATT_</c>, <c>BATT_LM_</c> and <c>BATT_</c> will be used.
308RUNLEVEL_BATTERY="battery"
309
310if [ -x /usr/bin/logger ]; then
311 LOGGER="/usr/bin/logger -s -p daemon.info -t /etc/acpi/actions/pmg_switch_runlevel.sh"
312else
313 LOGGER="/bin/echo"
314fi
315
316ON_AC_POWER=/usr/bin/on_ac_power
317# END configuration
318
319
320if [ ! -d "/etc/runlevels/${RUNLEVEL_AC}" ]
321then
322 ${LOGGER} "${0}: Runlevel ${RUNLEVEL_AC} does not exist. Aborting."
323 exit 1
324fi
325
326if [ ! -d "/etc/runlevels/${RUNLEVEL_BATTERY}" ]
327then
328 ${LOGGER} "${0}: Runlevel ${RUNLEVEL_BATTERY} does not exist. Aborting."
329 exit 1
330fi
331
332if ${on_ac_power}
333then
334 if [[ "$(rc-status --runlevel)" != "${RUNLEVEL_AC}" ]]
335 then
336 ${LOGGER} "Switching to ${RUNLEVEL_AC} runlevel"
337 /sbin/rc ${RUNLEVEL_AC}
338 fi
339elif [[ "$(rc-status --runlevel)" != "${RUNLEVEL_BATTERY}" ]]
340then
341 ${LOGGER} "Switching to ${RUNLEVEL_BATTERY} runlevel"
342 /sbin/rc ${RUNLEVEL_BATTERY}
343fi
344</pre>
345
346<p> 352</p>
347Dont forget to run <c>chmod +x /etc/acpi/actions/pmg_switch_runlevel.sh</c> to 353
348make the script executable. The last thing that needs to be done is calling the
349script whenever the power source changes. That's done by catching ACPI events
350with the help of <c>acpid</c>. First you need to know which events are
351generated when the power source changes. The events are called
352<c>ac_adapter</c> and <c>battery</c> on most laptops, but it might be different
353on yours.
354</p> 354<p>
355 355To make sure settings to not collide, it is not allowed to have overlapping
356<pre caption="Determining ACPI events for changing the power source"> 356settigns. In the next example, the first set (for <c>CPU_MAXFREQ</c>) is valid,
357# <i>tail -f /var/log/messages | grep "ACPI event"</i> 357but the second one (for <c>CPU_GOVERNOR</c>) isn't.
358</pre>
359
360<p> 358</p>
361Run the command above and pull the power cable. You should see something like 359
362this: 360<pre caption="Colliding settings">
361<comment>## Valid set</comment>
362BATT_CPU_MAXFREQ=fastest
363LM_AC_CPU_MAXFREQ=fastest
364NOLM_AC_CPU_MAXFREQ=fastest
365
366<comment>## Invalid set</comment>
367BATT_CPU_MINFREQ=fastest
368LM_AC_CPU_MINFREQ=fastest
369<comment># The following includes AC and BATT, but BATT is already defined</comment>
370NOLM_CPU_MINFREQ=fastest
371</pre>
372
373</body>
374</section>
375<section>
376<title>Configuring CPU frequency management</title>
377<body>
378
363</p> 379<p>
364 380The support for CPU frequency management in the laptop mode tools allows
365<pre caption="Sample output for power source changes"> 381switching frequencies. It supports setting the CPU frequency governor, minimum
366[Tue Sep 20 17:39:06 2005] ACPI event "ac_adapter AC 00000080 00000000" 382frequency and maximum frequency. The configuration file used here is
367[Tue Sep 20 17:39:06 2005] ACPI event "battery BAT0 00000080 00000001" 383<path>/etc/laptop-mode/conf.d/cpufreq.conf</path>.
368</pre>
369
370<p> 384</p>
371The interesting part is the quoted string after <c>ACPI event</c>. It will 385
372be matched by the event line in the files you are going to create below. Don't
373worry if your system generates multiple events or always the same. As long as
374any event is generated, runlevel changing will work.
375</p> 386<p>
376 387The <e>CPU frequency governor</e> is a kernel-level policy that defines how the
377<pre caption="/etc/acpi/events/pmg_ac_adapter"> 388kernel will select the CPU frequency. We already selected the governors we want
378<comment># replace "ac_adapter" below with the event generated on your laptop</comment> 389to use in the kernel configuration earlier. Let's recap:
379<comment># For example, ac_adapter.* will match ac_adapter AC 00000080 00000000</comment>
380event=ac_adapter.*
381action=/etc/acpi/actions/pmg_switch_runlevel.sh %e
382</pre>
383
384<pre caption="/etc/acpi/events/pmg_battery">
385<comment># replace "battery" below with the event generated on your laptop</comment>
386<comment># For example, battery.* will match battery BAT0 00000080 00000001</comment>
387event=battery.*
388action=/etc/acpi/actions/pmg_switch_runlevel.sh %e
389</pre>
390
391<p> 390</p>
392Finally acpid has to be restarted to recognize the changes. 391
392<ul>
393 <li>
394 <c>performance</c> always picks the highest frequency
395 </li>
396 <li>
397 <c>powersave</c> always picks the lowest frequency
398 </li>
399 <li>
400 <c>userspace</c> does not pick anything, but let the user decide (or any
401 process that the user is running that will decide for the user)
402 </li>
403 <li>
404 <c>ondemand</c> will scale the CPU frequency up to the highest frequency
405 when load is available
406 </li>
407 <li>
408 <c>conservative</c> will scale the CPU frequency up gradually when load is
409 available
410 </li>
411</ul>
412
393</p> 413<p>
394 414When switching between AC or battery, or (no) laptop mode, the appropriate
395<pre caption="Finishing runlevel switching with acpid"> 415governor (as well as its minimum and maximum frequency) is selected.
396# <i>/etc/init.d/acpid restart</i>
397</pre>
398
399<p> 416</p>
400Give it a try: Plug AC in and out and watch syslog for the "Switching to AC 417
401mode" or "Switching to battery mode" messages. See the <uri 418</body>
402link="#doc_chap8">Troubleshooting section</uri> if the script is not able to 419</section>
403detect the power source correctly. 420<section>
421<title>Configuring display brightness</title>
422<body>
423
404</p> 424<p>
405 425With <path>/etc/laptop-mode/conf.d/lcd-brightness.conf</path>, you can have the
426laptop mode tools govern the brightness of your LCD screen.
406<p> 427</p>
407Due to the nature of the event mechanism, your laptop will boot into runlevel 428
408<c>default</c> regardless of the AC/battery state. This is fine when running
409from AC, but we'd like to boot into the battery runlevel otherwise. One
410solution would be to add another entry to the boot loader with the parameter
411<c>softlevel=battery</c>, but it's likely to forget choosing it. A better way
412is faking an ACPI event in the end of the boot process and letting
413<path>pmg_switch_runlevel.sh</path> script decide whether a runlevel change is
414necessary. Create a <path>/etc/local.d/battery.start</path> file with the
415following contents:
416</p> 429<p>
417 430The file currently uses the <path>/proc/acpi/video/VID/LCD/brightness</path>
418<pre caption="Runlevel adjustment at boot time through local.d/battery.start"> 431file to set brightness values. Recent kernels do not provide this anymore -
419#!/bin/sh 432you will need to adjust this to <path>/sys/class/backlight/acpi_video0/brightness</path>
420<comment># Fake acpi event to switch runlevel if running on batteries</comment> 433instead.
421/etc/acpi/actions/pmg_switch_runlevel.sh "battery/battery"
422</pre>
423
424<p> 434</p>
425Don't forget to mark the file as executable (<c>chmod +x 435
426/etc/local.d/battery.start</c>). Prepared like this you can activate Power 436<p>
427Management policies for individual devices. 437The values you can use are between 0 and 15, with 0 being the lowest brightness
438value.
439</p>
440
441</body>
442</section>
443<section>
444<title>Configuring other services</title>
445<body>
446
447<p>
448An interesting feature of <c>laptop-mode-tools</c> is to support reloading
449particular services (like the system logger) after switching its configuration
450file. This is handled through
451<path>/etc/laptop-mode/conf.d/configuration-file-control.conf</path>.
452</p>
453
454<p>
455If enabled, the <c>laptop_mode</c> application will switch the configuration
456file(s) of the mentioned services with the same file, but suffixed with
457<path>-nolm-ac</path>, <path>-lm-ac</path> or <path>-batt</path>. It willl then
458signal or reload the appropriate services so they can use the new configuration
459file.
428</p> 460</p>
429 461
430</body> 462</body>
431</section> 463</section>
432</chapter> 464</chapter>
433 465
434<chapter> 466<chapter>
435<title>CPU Power Management</title> 467<title>Using cpufreqd</title>
436<section>
437<body>
438
439<p>
440Mobile processors can operate at different frequencies. Some allow changing
441voltage as well. Most of the time your CPU doesn't need to run at full speed
442and scaling it down will save much energy - often without any performance
443decrease.
444</p>
445
446</body>
447</section> 468<section>
448<section> 469<title>Installation</title>
449<title>Some Technical Terms</title>
450<body>
451
452<p>
453CPU frequency scaling brings up some technical terms that might be unknown to
454you. Here's a quick introduction.
455</p>
456
457<p>
458First of all, the kernel has to be able to change the processor's frequency.
459The <b>CPUfreq processor driver</b> knows the commands to do it on your CPU.
460Thus it's important to choose the right one in your kernel. You should already
461have done it above. Once the kernel knows how to change frequencies, it has to
462know which frequency it should set. This is done according to the <b>policy</b>
463which consists of a <b>CPUfreq policy</b> and a <b>governor</b>. A CPUfreq
464policy are just two numbers which define a range the frequency has to stay
465between - minimal and maximal frequency. The governor now decides which of the
466available frequencies in between minimal and maximal frequency to choose. For
467example, the <b>powersave governor</b> always chooses the lowest frequency
468available, the <b>performance governor</b> the highest one. The <b>userspace
469governor</b> makes no decision but chooses whatever the user (or a program in
470userspace) wants - which means it reads the frequency from
471<path>/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed</path>.
472</p>
473
474<p>
475This doesn't sound like dynamic frequency changes yet and in fact it isn't.
476Dynamics however can be accomplished with various approaches. For example, the
477<b>ondemand governor</b> makes its decisions depending on the current CPU load.
478The same is done by various userland tools like <c>cpudyn</c>, <c>cpufreqd</c>,
479<c>powernowd</c> and many more. ACPI events can be used to enable or disable
480dynamic frequency changes depending on power source.
481</p>
482
483</body> 470<body>
484</section>
485<section>
486<title>Setting The Frequency</title>
487<body>
488 471
489<p>
490Decreasing CPU speed and voltage has two advantages: On the one hand less
491energy is consumed, on the other hand there is thermal improvement as your
492system doesn't get as hot as running on full speed. The main disadvantage is
493obviously the loss of performance. Decreasing processor speed is a trade off
494between performance loss and energy saving.
495</p> 472<p>
496 473The <c>cpufreqd</c> application allows you to manage CPU frequencies in a more
497<note> 474granular approach then what <c>laptop-mode-tools</c> supports. But before we
498Not every laptop supports frequency scaling. If unsure, have a look at the list 475dive into the installation of <c>cpufreqd</c>, let's first look at the USE flags
499of supported processors in the <uri link="#doc_chap8">Troubleshooting</uri> 476it supports.
500section to verify yours is supported.
501</note>
502
503<p>
504It's time to test whether CPU frequency changing works. Let's install another
505tool: <c>sys-power/cpufrequtils</c>.
506</p>
507
508<pre caption="Checking CPU frequency">
509# <i>emerge cpufrequtils</i>
510# <i>cpufreq-info</i>
511</pre>
512
513<p>
514Here is an example output:
515</p>
516
517<pre caption="Sample output from cpufreq-info">
518cpufrequtils 0.3: cpufreq-info (C) Dominik Brodowski 2004
519Report errors and bugs to linux@brodo.de, please.
520analyzing CPU 0:
521 driver: centrino
522 CPUs which need to switch frequency at the same time: 0
523 hardware limits: 600 MHz - 1.40 GHz
524 available frequency steps: 600 MHz, 800 MHz, 1000 MHz, 1.20 GHz, 1.40 GHz
525 available cpufreq governors: conservative, ondemand, powersave, userspace, performance
526 current policy: frequency should be within 924 MHz and 1.40 GHz.
527 The governor "performance" may decide which speed to use
528 within this range.
529 current CPU frequency is 1.40 GHz.
530</pre>
531
532<p>
533Now play around with <c>cpufreq-set</c> to make sure frequency switching works.
534Run <c>cpufreq-set -g ondemand</c> for example to activate the ondemand
535governor and verify the change with <c>cpufreq-info</c>. If it doesn't work as
536expected, you might find help in the <uri link="#doc_chap8">Troubleshooting
537section</uri> in the end of this guide.
538</p>
539
540<p>
541<c>cpufrequtils</c> can operate in an automatic mode (when you use the
542<b>ondemand</b> governor), you can also switch to the <b>userspace</b> governor
543if you want to manually set a specific speed. You can also statically set your
544CPU to its highest or lowest frequency by using the <b>performance</b>
545and <b>powersave</b> governors, respectively.
546</p>
547
548<pre caption="Changing CPU speeds">
549<comment>(Set the highest available frequency)</comment>
550# <i>cpufreq-set -g performance</i>
551<comment>(Set the lowest available frequency)</comment>
552# <i>cpufreq-set -g powersave</i>
553<comment>(Set a specific frequency)</comment>
554# <i>cpufreq-set -g userspace</i>
555# <i>cpufreq-set -f 2.00ghz</i>
556</pre>
557
558</body>
559</section>
560<section>
561<title>Other CPU Speed Utilities</title>
562<body>
563
564<p>
565While <c>cpufrequtils</c> may be the best all-around program, there are some
566other choices available in Portage. The following table gives a quick overview
567of available CPU speed utilities. It's roughly separated in three categories
568<b>kernel</b> for approaches that only need kernel support, <b>daemon</b> for
569programs that run in the background and <b>graphical</b> for programs that
570provide a GUI for easy configuration and changes.
571</p> 477</p>
572 478
573<table> 479<table>
574<tr> 480<tr>
575 <th>Name</th> 481 <th>USE flag</th>
576 <th>Category</th> 482 <th>Description</th>
577 <th>Switch decision</th> 483 <th>Suggested when...</th>
578 <th>Kernel governors</th>
579 <th>Further governors</th>
580 <th>Comments</th>
581</tr>
582<tr> 484</tr>
583 <ti>'ondemand' governor</ti> 485<tr>
584 <ti>Kernel</ti> 486 <ti>acpi</ti>
585 <ti>CPU load</ti>
586 <ti>N.A.</ti>
587 <ti>N.A.</ti>
588 <ti>
589 Chooses maximal frequency on CPU load and slowly steps down when the CPU is
590 idle. Further tuning through files in
591 <path>/sys/devices/system/cpu/cpu0/cpufreq/ondemand/</path>. Still requires
592 userland tools (programs, scripts) if governor switching or similar is
593 desired.
594 </ti> 487 <ti>
595</tr> 488 Enable support for ACPI, allowing <c>cpufreqd</c> to be notified about
596<tr> 489 specific events as well as govern power through the ACPI interface
597 <ti>'conservative' governor</ti>
598 <ti>Kernel</ti>
599 <ti>CPU load</ti>
600 <ti>N.A.</ti>
601 <ti>N.A.</ti>
602 <ti> 490 </ti>
603 Unlike the ondemand governor, conversative doesn't jump to maximum 491 <ti>your laptop is not too old (~ year 2003 and later)</ti>
604 frequency when CPU load is high, but increases the frequency step by step. 492</tr>
605 Further tuning through files in 493<tr>
606 <path>/sys/devices/system/cpu/cpu0/cpufreq/ondemand/</path>. Still requires 494 <ti>apm</ti>
607 userland tools (programs, scripts) if governor switching or similar is
608 desired.
609 </ti> 495 <ti>
610</tr> 496 Enable support for APM, allowing <c>cpufreqd</c> to be notified about
611<tr> 497 specific events as wel as govern power through the APM interface
612 <ti><uri link="http://mnm.uib.es/~gallir/cpudyn/">cpudyn</uri></ti>
613 <ti>Daemon</ti>
614 <ti>CPU load</ti>
615 <ti>Performance, powersave</ti>
616 <ti>Dynamic</ti>
617 <ti> 498 </ti>
618 Also supports disk standby - notice however that <e>laptop mode</e> in most 499 <ti>your laptop is very old</ti>
619 cases will do a better job. 500</tr>
501<tr>
502 <ti>lm_sensors</ti>
620 </ti> 503 <ti>
621</tr> 504 Enable support for the Linux hardware sensors (through
622<tr> 505 <c>sys-apps/lm_sensors</c>), allowing to switch profiles based on hardware
623 <ti><uri link="http://sourceforge.net/projects/cpufreqd/">cpufreqd</uri></ti> 506 sensor results
624 <ti>Daemon</ti>
625 <ti>Battery state, CPU load, temperature, running programs and more</ti>
626 <ti>All available</ti>
627 <ti>None</ti>
628 <ti> 507 </ti>
629 Sophisticated (but somewhat complicated) setup. Extendible through plugins
630 like sensor monitoring (lm_sensors) or coordinating some NVidia based
631 graphics card memory and core. Cpufreqd is SMP aware and can optionally be
632 controlled manually at runtime.
633 </ti> 508 <ti>
634</tr> 509 you want to use advanced events through lm_sensors
635<tr>
636 <ti> 510 </ti>
637 <uri link="http://www.deater.net/john/powernowd.html">powernowd</uri> 511</tr>
512<tr>
513 <ti>nforce2</ti>
638 </ti> 514 <ti>
639 <ti>Daemon</ti> 515 Enable support for NForce, allowing <c>cpufreqd</c> to change the NForce FSB
640 <ti>CPU load</ti> 516 clock and video card frequency
641 <ti>None</ti>
642 <ti>Passive, sine, aggressive</ti>
643 <ti> 517 </ti>
644 Supports SMP.
645 </ti> 518 <ti>
646</tr> 519 you have an NVidia graphical card based on the NForce chipset
647<tr>
648 <ti> 520 </ti>
649 <uri 521</tr>
650 link="http://projects.simpledesigns.com.pl/project/ncpufreqd/">ncpufreqd</uri> 522<tr>
523 <ti>nvidia</ti>
651 </ti> 524 <ti>
652 <ti>Daemon</ti> 525 Enable support for NVidia graphical card configuration (through the NVidia
653 <ti>Temperature</ti> 526 <e>nvclock</e> interface), allowing <c>cpufreqd</c> to change the video card
654 <ti>None</ti> 527 frequency of NVidia graphical cards
655 <ti>Powersave, performance</ti>
656 <ti> 528 </ti>
657 Toggles the used governor between performance and powersave depending on
658 system temperature. Very useful on laptops with notorious heat problems.
659 </ti> 529 <ti>
660</tr> 530 you have an NVidia graphical card
661<tr>
662 <ti><uri link="http://www.goop.org/~jeremy/speedfreq/">speedfreq</uri></ti>
663 <ti>Daemon</ti>
664 <ti>CPU load</ti>
665 <ti>None</ti>
666 <ti>Dynamic, powersave, performance, fixed speed</ti>
667 <ti> 531 </ti>
668 Easy to configure with a nice client/server interface. Requires a 2.6 532</tr>
669 kernel. Unmaintained, broken and thus removed from Portage. Please switch 533<tr>
670 to cpufreqd if you're still using it. 534 <ti>pmu</ti>
671 </ti> 535 <ti>
672</tr> 536 Enable the Power Management Unit plug-in of <c>cpufreqd</c>. This allows the
673<tr> 537 software to poll the Linux kernel Power Supply interface, getting more
674 <ti><uri link="http://cpuspeedy.sourceforge.net/">gtk-cpuspeedy</uri></ti> 538 detailed information on battery charge.
675 <ti>Graphical</ti>
676 <ti>None</ti>
677 <ti>None</ti>
678 <ti>None</ti>
679 <ti> 539 </ti>
680 Gnome application, a graphical tool to set CPU frequency manually. It does
681 not offer any automation.
682 </ti> 540 <ti>
683</tr> 541 your laptop does not support ACPI or APM
684<tr>
685 <ti>klaptopdaemon</ti>
686 <ti>Graphical</ti>
687 <ti>Battery state</ti>
688 <ti>All available</ti>
689 <ti>None</ti>
690 <ti>
691 KDE only, 'ondemand' governor required for dynamic frequency scaling.
692 </ti> 542 </ti>
693</tr> 543</tr>
694</table> 544</table>
695 545
696<p> 546<p>
697While adjusting the frequency to the current load looks simple at a first 547The USE flags <c>acpi</c>, <c>apm</c> and <c>pmu</c> overlap, so you should only
698glance, it's not such a trivial task. A bad algorithm can cause switching 548have one active. If your laptop is sufficiently recent, <c>acpi</c> is your best
699between two frequencies all the time or wasting energy when setting frequency 549bet. If not, <c>apm</c> offers all that is needed. When even APM isn't
700to an unnecessary high level. 550supported, you can try <c>pmu</c>.
701</p>
702
703<p> 551</p>
704Which one to choose? If you have no idea about it, try <c>cpufreqd</c>: 552
553<p>
554With the USE flags configured, it is time to install <c>cpufreqd</c>.
705</p> 555</p>
706 556
707<pre caption="Installing cpufreqd"> 557<pre caption="Installing cpufreqd">
708# <i>emerge cpufreqd</i> 558# <i>emerge cpufreqd</i>
709</pre> 559</pre>
710 560
561</body>
562</section>
563<section>
564<title>Configuration</title>
565<body>
566
567<p>
568The <c>cpufreqd</c> application monitors the status of the system through
569several plugins. Based on the feedback it receives from those plugins, it will
570adjust the policy used to govern the CPU frequency.
711<p> 571</p>
572
573<p>
712<c>cpufreqd</c> can be configured by editing <path>/etc/cpufreqd.conf</path>. 574<c>cpufreqd</c> can be configured by editing <path>/etc/cpufreqd.conf</path>. It
713The default one that ships with cpufreqd may look a bit confusing. I recommend 575contains three different sections:
714replacing it with the one from former Gentoo developer Henrik Brix Andersen 576</p>
715(see below). Please notice that you need cpufreqd-2.0.0 or later. Earlier 577
716versions have a different syntax for the config file. 578<ol>
579 <li>
580 The <c>[General]...[/General]</c> section contains general configuration
581 information
582 </li>
583 <li>
584 The <c>[Profile]...[/Profile]</c> section defines the policies that the
585 <c>cpufreqd</c> daemon can switch to. The section is very similar to the
586 information you use when manually setting the CPU frequency policy using
587 <c>cpufreq-set</c>.
588 </li>
589 <li>
590 The <c>[Rule]...[/Rule]</c> section is the work-horse of the <c>cpufreqd</c>
591 daemon, defining when the daemon decides to switch to a different profile.
592 </li>
593</ol>
594
717</p> 595<p>
596Let's take a quick look at an example rule.
597</p>
718 598
719<pre caption="/etc/cpufreqd.conf (cpufreqd-2.0.0 and later)"> 599<pre caption="Sample cpufreqd rule">
720[General]
721pidfile=/var/run/cpufreqd.pid
722poll_interval=3
723enable_plugins=acpi_ac, acpi_battery
724enable_remote=1
725remote_group=wheel
726verbosity=5
727[/General]
728
729[Profile] 600[Profile]
730name=ondemand 601name=On Demand High
731minfreq=0% 602minfreq=40%
732maxfreq=100% 603maxfreq=100%
733policy=ondemand 604policy=ondemand
734[/Profile] 605[/Profile]
735 606
736[Profile]
737name=conservative
738minfreq=0%
739maxfreq=100%
740policy=conservative
741[/Profile]
742
743[Profile]
744name=powersave
745minfreq=0%
746maxfreq=100%
747policy=powersave
748[/Profile]
749
750[Profile]
751name=performance
752minfreq=0%
753maxfreq=100%
754policy=performance
755[/Profile]
756
757[Rule] 607[Rule]
758name=battery 608name=AC Off - High Power
759ac=off 609ac=off
760profile=conservative 610battery_interval=70-100
611profile=On Demand High
761[/Rule] 612[/Rule]
762
763[Rule]
764name=battery_low
765ac=off
766battery_interval=0-10
767profile=powersave
768[/Rule]
769
770[Rule]
771name=ac
772ac=on
773profile=ondemand
774[/Rule]
775</pre> 613</pre>
776 614
615<p>
616In the above example, <c>cpufreqd</c> will switch the system to the <e>On Demand
617High</e> profile (also shown in the above excerpt). This profile by itself uses
618the <c>ondemand</c> governor with a minimum frequency of 40% (iow, a CPU of 2Ghz
619will have by this policy a minimum frequency of 800Mhz).
777<p> 620</p>
778Now you can start the cpufreqd daemon. Add it to the <c>default</c> and 621
779<c>battery</c> runlevel as well. 622<p>
623As you can see, the <c>cpufreqd</c> application can offer a more granular
624approach on CPU frequency scaling. But not only that, you can tweak the CPU
625frequency scaling based on various other metrics available. The default
626configuration offers a sample rule for when you watch a movie, where you want
627maximum performance, unless the CPU temperature is getting too high.
628</p>
629
630<p>
631When you have configured <c>cpufreqd</c>, it is time to start it (and make sure
632the service is loaded automatically). Make sure that CPU frequency handling by
633other tools (like <c>laptop-mode-tools</c>) is disabled!
780</p> 634</p>
781 635
782<pre caption="Starting cpufreqd"> 636<pre caption="Starting cpufreqd">
783# <i>rc-update add cpufreqd default battery</i> 637# <i>rc-service add cpufreqd default</i>
784# <i>/etc/init.d/cpufreqd start</i> 638# <i>/etc/init.d/cpufreqd start</i>
785</pre> 639</pre>
786 640
787<p>
788Sometimes it can be desirable to select another policy than the daemon chooses,
789for example when battery power is low, but you know that AC will be available
790soon. In that case you can turn on cpufreqd's manual mode with <c>cpufreqd-set
791manual</c> and select one of your configured policies (as listed by
792<c>cpufreqd-get</c>). You can leave manual mode by executing <c>cpufreqd-set
793dynamic</c>.
794</p>
795
796<warn>
797Do not run more than one of the above programs at the same time. It may cause
798confusion like switching between two frequencies all the time.
799</warn>
800
801</body>
802</section>
803<section>
804<title>Verifying the result</title>
805<body>
806
807<p>
808The last thing to check is that your new policies do a good job. An easy way to
809do so is monitoring CPU speed while working with your laptop:
810</p>
811
812<pre caption="Monitoring CPU speed">
813# <i>watch grep \"cpu MHz\" /proc/cpuinfo</i>
814</pre>
815
816<p>
817If <path>/proc/cpuinfo</path> doesn't get updated (see <uri
818link="#doc_chap8">Troubleshooting</uri>), monitor the CPU frequency with
819<c>sys-apps/x86info</c>:
820</p>
821
822<pre caption="Alternative CPU speed monitoring">
823# <i>watch x86info -mhz</i>
824</pre>
825
826<p>
827Depending on your setup, CPU speed should increase on heavy load, decrease on
828no activity or just stay at the same level. When using <c>cpufreqd</c> and
829verbosity set to 5 or higher in <path>cpufreqd.conf</path> you'll get
830additional information about what's happening reported to <c>syslog</c>.
831</p>
832
833</body> 641</body>
834</section> 642</section>
835</chapter> 643</chapter>
836 644
837<chapter> 645<chapter>
838<title>LCD Power Management</title> 646<title>Resources</title>
839<section>
840<body>
841
842<p>
843As you can see in <uri link="#doc_chap1_fig1">figure 1.1</uri>, the LCD
844display consumes the biggest part of energy (might not be the case for
845non-mobile CPU's). Thus it's quite important not only to shut the display off
846when not needed, but also to reduce it's backlight if possible. Most laptops
847offer the possibility to control the backlight dimming.
848</p>
849
850</body>
851</section> 647<section>
852<section> 648<title>Tools</title>
853<title>Standby settings</title>
854<body>
855
856<p>
857The first thing to check is the standby/suspend/off timings of the display. As
858this depends heavily on your windowmanager, I'll let you figure it out
859yourself. Just two common places: Blanking the terminal can be done with
860<c>setterm -blank &lt;number-of-minutesM&gt;</c>, <c>setterm -powersave on</c>
861and <c>setterm -powerdown &lt;number-of-minutesM&gt;</c>. For X.org, modify
862<path>/etc/X11/xorg.conf</path> similar to this:
863</p>
864
865<pre caption="LCD suspend settings in X.org">
866Section "ServerFlags"
867 Option "blank time" "5" <comment># Blank the screen after 5 minutes (Fake)</comment>
868 Option "standby time" "10" <comment># Turn off screen after 10 minutes (DPMS)</comment>
869 Option "suspend time" "20" <comment># Full suspend after 20 minutes</comment>
870 Option "off time" "30" <comment># Turn off after half an hour</comment>
871 [...]
872EndSection
873
874[...]
875
876Section "Monitor"
877 Identifier [...]
878 Option "DPMS"
879 [...]
880EndSection
881</pre>
882
883</body> 649<body>
884</section>
885<section>
886<title>Backlight dimming</title>
887<body>
888
889<p>
890Probably more important is the backlight dimming. If you have access to the
891dimming settings via a tool, write a small script that dims the backlight in
892battery mode and place it in your <c>battery</c> runlevel. The following script
893should work on most IBM Thinkpads and Toshiba laptops. You've got to enable the
894appropriate option in your kernel (IBM Thinkpads only). For Toshiba laptops,
895install <c>sys-power/acpitool</c> and skip configuration of <c>thinkpad_acpi</c>
896(formerly called <c>ibm_acpi</c>) as described below.
897</p>
898
899<warn>
900Support for setting brightness is marked experimental in thinkpad_acpi. It
901accesses hardware directly and may cause severe harm to your system. Please
902read the <uri link="http://ibm-acpi.sourceforge.net/">thinkpad_acpi
903website</uri>
904</warn>
905
906<p>
907To be able to set the brightness level, the thinkpad_acpi module has to be
908loaded with the experimental parameter.
909</p>
910
911<pre caption="Automatically loading the thinkpad_acpi module">
912<comment>(Please read the warnings above before doing this!)</comment>
913
914# <i>echo "options thinkpad_acpi experimental=1" >> /etc/modprobe.d/thinkpad_acpi</i>
915# <i>update-modules</i>
916# <i>nano /etc/conf.d/modules</i>
917<comment># Autoload the thinkpad_acpi module</comment>
918modules_2_6="thinkpad_acpi"
919<comment># Parameters for the thinkpad_acpi module</comment>
920modules_thinkpad_acpi_args_2_6="experimental=1"
921
922# <i>modprobe thinkpad_acpi</i>
923</pre>
924
925<p>
926This should work without error messages and a file
927<path>/proc/acpi/ibm/brightness</path> should be created after loading the
928module. An init script will take care of choosing the brightness according to
929the power source.
930</p>
931
932<pre caption="/etc/conf.d/lcd-brightness">
933<comment># See /proc/acpi/ibm/brightness for available values</comment>
934<comment># Please read /usr/src/linux/Documentation/thinkpad-acpi.txt</comment>
935
936<comment># brightness level in ac mode. Default is 7.</comment>
937BRIGHTNESS_AC=7
938
939<comment># brightness level in battery mode. Default is 4.</comment>
940BRIGHTNESS_BATTERY=4
941</pre>
942
943<pre caption="/etc/init.d/lcd-brightness">
944#!/sbin/runscript
945
946set_brightness() {
947 if on_ac_power
948 then
949 LEVEL=${BRIGHTNESS_AC:-7}
950 else
951 LEVEL=${BRIGHTNESS_BATTERY:-4}
952 fi
953
954 if [ -f /proc/acpi/ibm/brightness ]
955 then
956 ebegin "Setting LCD brightness"
957 echo "level ${LEVEL}" > /proc/acpi/ibm/brightness
958 eend $?
959 elif [[ -e /usr/bin/acpitool &amp;&amp; -n $(acpitool -T | grep "LCD brightness") ]]
960 then
961 ebegin "Setting LCD brightness"
962 acpitool -l $LEVEL >/dev/null || ewarn "Unable to set lcd brightness"
963 eend $?
964 else
965 ewarn "Setting LCD brightness is not supported."
966 ewarn "For IBM Thinkpads, check that thinkpad_acpi is loaded into the kernel"
967 ewarn "For Toshiba laptops, you've got to install sys-power/acpitool"
968 fi
969}
970
971start() {
972 set_brightness
973}
974
975stop () {
976 set_brightness
977}
978</pre>
979
980<p>
981When done, make sure brightness is adjusted automatically by adding it to the
982battery runlevel.
983</p>
984
985<pre caption="Enabling automatic brightness adjustment">
986# <i>chmod +x /etc/init.d/lcd-brightness</i>
987# <i>rc-update add lcd-brightness battery</i>
988# <i>rc</i>
989</pre>
990
991</body>
992</section>
993</chapter>
994
995<chapter>
996<title>Disk Power Management</title>
997<section>
998<body>
999
1000<p>
1001Hard disks consume less energy in sleep mode. Therefore it makes sense to
1002activate power saving features whenever the hard disk is not used for a certain
1003amount of time. I'll show you two alternative possibilities to do it. First,
1004laptop-mode will save most energy due to several measures which prevent or at
1005least delay write accesses. The drawback is that due to the delayed write
1006accesses a power outage or kernel crash will be more dangerous for data loss.
1007If you don't like this, you have to make sure that there are no processes which
1008write to your hard disk frequently. Afterwards you can enable power saving
1009features of your hard disk with <c>hdparm</c> as the second alternative.
1010</p>
1011
1012</body>
1013</section>
1014<section>
1015<title>Increasing idle time - laptop-mode</title>
1016<body>
1017
1018<p>
1019Recent 2.6 kernels include the so-called <c>laptop-mode</c>. When activated,
1020dirty buffers are written to disk on read calls or after 10 minutes (instead of
102130 seconds). This minimizes the time the hard disk needs to be spun up.
1022</p>
1023
1024<pre caption="Automated start of laptop-mode">
1025# <i>emerge laptop-mode-tools</i>
1026</pre>
1027
1028<p>
1029<c>laptop-mode-tools</c> has its configuration file in
1030<path>/etc/laptop-mode/laptop-mode.conf</path>. Adjust it the way you like it,
1031it's well commented. Run <c>rc-update add laptop_mode battery</c> to start it
1032automatically.
1033</p>
1034
1035<p>
1036Recent versions (1.11 and later) of laptop-mode-tools include a new tool
1037<c>lm-profiler</c>. It will monitor your system's disk usage and running
1038network services and suggests to disable unneeded ones. You can either disable
1039them through laptop-mode-tools builtin runlevel support (which will be reverted
1040by Gentoo's <c>/sbin/rc</c>) or use your <c>default</c>/<c>battery</c>
1041runlevels (recommended).
1042</p>
1043
1044<pre caption="Sample output from running lm-profiler">
1045# <i>lm-profiler</i>
1046Profiling session started.
1047Time remaining: 600 seconds
1048[4296896.602000] amarokapp
1049Time remaining: 599 seconds
1050[4296897.714000] sort
1051[4296897.970000] mv
1052Time remaining: 598 seconds
1053Time remaining: 597 seconds
1054[4296900.482000] reiserfs/0
1055</pre>
1056
1057<p>
1058After profiling your system for ten minutes, lm-profiler will present a list of
1059services which might have caused disk accesses during that time.
1060</p>
1061
1062<pre caption="lm-profiler suggests to disable some services">
1063Program: "atd"
1064Reason: standard recommendation (program may not be running)
1065Init script: /etc/init.d/atd (GUESSED)
1066
1067Do you want to disable this service in battery mode? [y/N]: <i>n</i>
1068</pre>
1069
1070<p>
1071To disable atd as suggested in the example above, you would run <c>rc-update
1072del atd battery</c>. Be careful not to disable services that are needed for
1073your system to run properly - <c>lm-profiler</c> is likely to generate some
1074false positives. Do not disable a service if you are unsure whether it's
1075needed.
1076</p>
1077
1078</body>
1079</section>
1080<section>
1081<title>Limiting Write Accesses</title>
1082<body>
1083
1084<p>
1085If you don't want to use laptop-mode, you must take special care to disable
1086services that write to your disk frequently - <c>syslogd</c> is a good
1087candidate, for example. You probably don't want to shut it down completely, but
1088it's possible to modify the config file so that "unnecessary" things don't get
1089logged and thus don't create disk traffic. <c>Cups</c> writes to disk
1090periodically, so consider shutting it down and only enable it manually when
1091needed.
1092</p>
1093
1094<pre caption="Disabling cups in battery mode">
1095# <i>rc-update del cupsd battery</i>
1096</pre>
1097
1098<p>
1099You can also use <c>lm-profiler</c> from laptop-mode-tools (see above) to find
1100services to disable. Once you eliminated all of them, go on with configuring
1101hdparm.
1102</p>
1103
1104</body>
1105</section>
1106<section>
1107<title>hdparm</title>
1108<body>
1109
1110<p>
1111The second possibility is using <c>hdparm</c>. Skip this if
1112you are using laptop-mode. Otherwise, edit <path>/etc/conf.d/hdparm</path> and
1113add the following values to your drive entries. This example assumes your hard
1114drive is called <b>hda</b>:
1115</p>
1116
1117<pre caption="Using /etc/conf.d/hdparm for disk standby">
1118hda_args="-q -S12"
1119</pre>
1120
1121<p>
1122This will activate power management for your hard drive. If you ever want to
1123deactivate power management, you can edit <path>/etc/conf.d/hdparm</path> and
1124change the values to <c>-q -S0</c>, or just run <c>hdparm -q -S0 /dev/hda</c>.
1125</p>
1126
1127<p>
1128See <c>man hdparm</c> for the options. Though you can always start <c>hdparm</c>
1129manually when you are on battery power by running <c>/etc/init.d/hdparm
1130start</c>, it's much easier to automate its startup and shutdown. To do so, add
1131<c>hdparm</c> to the battery runlevel so that it will automatically enable power
1132management.
1133</p>
1134
1135<pre caption="Automate disk standby settings">
1136# <i>rc-update add hdparm battery</i>
1137</pre>
1138
1139<impo>
1140Be careful with sleep/spin down settings of your hard drive. Setting it to
1141small values might wear out your drive and lose warranty.
1142</impo>
1143
1144</body>
1145</section>
1146<section>
1147<title>Other tricks</title>
1148<body>
1149
1150<p>
1151Another possibility is to deactivate swap in battery mode. Before writing a
1152swapon/swapoff switcher, make sure there is enough RAM and swap isn't used
1153heavily, otherwise you'll be in big problems.
1154</p>
1155
1156<p>
1157If you don't want to use laptop-mode, it's still possible to minimize disk
1158access by mounting certain directories as <c>tmpfs</c> - write accesses are not
1159stored on a disk, but in main memory and get lost with unmounting. Often it's
1160useful to mount <path>/tmp</path> like this - you don't have to pay special
1161attention as it gets cleared on every reboot regardless whether it was mounted
1162on disk or in RAM. Just make sure you have enough RAM and no program (like a
1163download client or compress utility) needs extraordinary much space in
1164<path>/tmp</path>. To activate this, enable tmpfs support in your kernel and
1165add a line to <path>/etc/fstab</path> like this:
1166</p>
1167
1168<pre caption="Editing /etc/fstab to make /tmp even more volatile">
1169none /tmp tmpfs size=32m 0 0
1170</pre>
1171
1172<warn>
1173Pay attention to the size parameter and modify it for your system. If you're
1174unsure, don't try this at all, it can become a performance bottleneck easily. In
1175case you want to mount <path>/var/log</path> like this, make sure to merge the
1176log files to disk before unmounting. They are essential. Don't attempt to mount
1177<path>/var/tmp</path> like this. Portage uses it for compiling...
1178</warn>
1179
1180</body>
1181</section>
1182</chapter>
1183
1184<chapter>
1185<title>Power Management For Other Devices</title>
1186<section>
1187<title>Graphics Cards</title>
1188<body>
1189
1190<p>
1191In case you own an ATI graphics card supporting PowerPlay (dynamic clock
1192scaling for the graphics processing unit GPU), you can activate this
1193feature in X.org. Open <path>/etc/X11/xorg.conf</path> and add (or enable) the
1194<c>DynamicClocks</c> option in the Device section. Please notice that this
1195feature will lead to crashes on some systems.
1196</p>
1197
1198<pre caption="Enabling ATI PowerPlay support in X.org">
1199Section "Device"
1200[...]
1201Option "DynamicClocks" "on"
1202EndSection
1203</pre>
1204
1205</body>
1206</section>
1207<section>
1208<title>Wireless Power Management</title>
1209<body>
1210
1211<p>
1212Wireless LAN cards consume quite a bit of energy. Put them in Power Management
1213mode just like your hard drives.
1214</p>
1215
1216<note>
1217This script assumes your wireless interface is called <c>wlan0</c>; replace
1218this with the actual name of your interface.
1219</note>
1220
1221<p>
1222Add the following option to <path>/etc/conf.d/net</path> to automatically enable
1223power management for your wireless card:
1224</p>
1225
1226<pre caption="Automated WLAN Power Management">
1227iwconfig_wlan0="power on"
1228</pre>
1229
1230<p>
1231See <c>man iwconfig</c> for details and more options like the period between
1232wakeups or timeout settings. If your driver and access point support changing
1233the beacon time, this is a good starting point to save even more energy.
1234</p>
1235
1236</body>
1237</section>
1238<section>
1239<title>USB Power Management</title>
1240<body>
1241
1242<p>
1243There are two problems with USB devices regarding energy consumption: First,
1244devices like USB mice, digital cameras or USB sticks consume energy while
1245plugged in. You cannot avoid this (nevertheless remove them in case they're not
1246needed). Second, when there are USB devices plugged in, the USB host controller
1247periodically accesses the bus which in turn prevents the CPU from going into
1248sleep mode. The kernel offers an experimental option to enable suspension of
1249USB devices through driver calls or one of the <path>power/state</path> files
1250in <path>/sys</path>.
1251</p>
1252
1253<pre caption="Enabling USB suspend support in the kernel">
1254Device Drivers
1255 USB support
1256 [*] Support for Host-side USB
1257 [*] USB suspend/resume (EXPERIMENTAL)
1258</pre>
1259
1260</body>
1261</section>
1262</chapter>
1263
1264<chapter>
1265<title>Sleep States: sleep, standby, and suspend to disk</title>
1266<section>
1267<body>
1268
1269<p>
1270ACPI defines different sleep states. The more important ones are
1271</p>
1272 650
1273<ul> 651<ul>
1274 <li>S1 aka Standby</li> 652 <li>
1275 <li>S3 aka Suspend to RAM aka Sleep</li> 653 <uri link="http://samwel.tk/laptop_mode/">Laptop Mode Tools Homepage</uri>,
1276 <li>S4 aka Suspend to Disk aka Hibernate</li> 654 includes <uri link="http://samwel.tk/laptop_mode/laptop_mode">About laptop
655 mode</uri>.
656 </li>
657 <li>
658 <uri link="http://www.lesswatts.org/projects/powertop/">PowerTOP</uri>, an
659 interactive application helping users to find out which processes are
660 forcing wakeups on the CPU most often.
661 </li>
1277</ul> 662</ul>
1278 663
1279<p>
1280They can be called whenever the system is not in use, but a shutdown is not
1281wanted due to the long boot time.
1282</p>
1283
1284</body> 664</body>
1285</section>
1286<section> 665</section>
1287<title>Sleep (S3)</title>
1288<body>
1289
1290<p>
1291The ACPI support for these sleep states is marked experimental for good reason.
1292APM sleep states seem to be more stable, however you can't use APM and ACPI
1293together.
1294</p>
1295
1296<pre caption="Kernel configuration for the various suspend types">
1297 Power Management Options ---&gt;
1298 [*] Power Management support
1299 [*] Suspend to RAM and standby
1300</pre>
1301
1302<p>
1303Once your kernel is properly configured, you can use the
1304<c>hibernate-script</c> to activate suspend or sleep mode. Let's install that
1305first.
1306</p>
1307
1308<pre caption="Installing the hibernate-script">
1309# <i>emerge hibernate-script</i>
1310</pre>
1311
1312<p>
1313Some configuration has to be done in <path>/etc/hibernate</path>. The default
1314package introduces a few configuration files for each sleep state. Options that
1315are common to all suspend methods are placed in <path>common.conf</path>; make
1316sure this file is properly set up for your system.
1317</p>
1318
1319<p>
1320To configure sleep, edit <path>sysfs-ram.conf</path> in
1321<path>/etc/hibernate</path>. <c>UseSysfsPowerState mem</c> is already setup
1322correctly, but if you need to make further changes to this particular sleep
1323state (or any other sleep state) you should add them to
1324<path>/etc/hibernate/hibernate.conf</path>. The comments and option names will
1325guide you. If you use nfs or samba shares over the network, make sure to
1326shutdown the appropriate init scripts to avoid timeouts.
1327</p>
1328
1329<note>
1330For more information on setting up sleep states, read <c>man
1331hibernate.conf</c>.
1332</note>
1333
1334<p>
1335Ready? Now is the last chance to backup any data you want to keep after
1336executing the next command. Notice that you probably have to hit a special key
1337like <c>Fn</c> to resume from sleep.
1338</p>
1339
1340<pre caption="Calling sleep">
1341# <i>hibernate-ram</i>
1342</pre>
1343
1344<p>
1345If you're still reading, it seems to work. You can also setup standby (S1) in a
1346similar way by editing <path>sysfs-ram.conf</path> and changing
1347"UseSysfsPowerState mem" to "UseSysfsPowerState standby". S3 and S4 are the more
1348interesting sleep states due to greater energy savings however.
1349</p>
1350
1351</body>
1352</section> 666<section>
1353<section> 667<title>Articles and Guides</title>
1354<title>Hibernate (S4)</title>
1355<body>
1356
1357<p>
1358This section introduces hibernation, where a snapshot of the running system is
1359written to disk before powering off. On resume, the snapshot is loaded and you
1360can go on working at exactly the point you called hibernate before.
1361</p>
1362
1363<warn>
1364Don't exchange non hot-pluggable hardware when suspended. Don't attempt to load
1365a snapshot with a different kernel image than the one it was created with.
1366Shutdown any NFS or samba server/client before hibernating.
1367</warn>
1368
1369<p>
1370There are two different implementations for S4. The original one is swsusp,
1371then there is the newer tuxonice (formerly suspend2) with a nicer interface
1372(including fbsplash support). A <uri
1373link="http://tuxonice.net/features.html#compare">feature comparison</uri> is
1374available at the <uri link="http://www.tuxonice.net">tuxonice homepage</uri>.
1375There used to be Suspend-to-Disk (pmdisk), a fork of swsusp, but it has been
1376merged back.
1377</p>
1378
1379<p>
1380TuxOnIce is not included in the mainline kernel yet, therefore you either have
1381to patch your kernel sources with the patches provided by <uri
1382link="http://www.tuxonice.net">tuxonice.net</uri> or use
1383<c>sys-kernel/tuxonice-sources</c>.
1384</p>
1385
1386<p>
1387The kernel part for both swusp and TuxOnIce is as follows:
1388</p>
1389
1390<pre caption="Kernel configuration for the various suspend types">
1391Power Management support ---&gt;
1392 <comment>(hibernate with swsusp)</comment>
1393 [*] Hibernation (aka 'suspend to disk')
1394 <comment>(replace /dev/SWAP with your swap partition)</comment>
1395 (/dev/SWAP) Default resume partition
1396
1397 <comment>(hibernate with TuxOnIce)</comment>
1398 Enhanced Hibernation (TuxOnIce)
1399 --- Image Storage (you need at least one allocator)
1400 [*] File Allocator
1401 [*] Swap Allocator
1402 --- General Options
1403 [*] Compression support
1404 [ ] Allow Keep Image Mode
1405 [*] Replace swsusp by default
1406</pre>
1407
1408<p>
1409The configuration for swsusp is rather easy. If you didn't store the location
1410of your swap partition in the kernel config, you can also pass it as a
1411parameter with the <c>resume=/dev/SWAP</c> directive. If booting is not
1412possible due to a broken image, use the <c>noresume</c> kernel parameter. The
1413<c>hibernate-cleanup</c> init script invalidates swsusp images during the boot
1414process.
1415</p>
1416
1417<pre caption="Invalidating swsusp images during the boot process">
1418# <i>rc-update add hibernate-cleanup boot</i>
1419</pre>
1420
1421<p>
1422To activate hibernate with swsusp, use the hibernate script and set
1423<c>UseSysfsPowerState disk</c> in <path>/etc/hibernate/sysfs-disk</path>.
1424</p>
1425
1426<warn>
1427Backup your data before doing this. Run <c>sync</c> before executing one of the
1428commands to have cached data written to disk. First try it outside of X, then
1429with X running, but not logged in.
1430</warn>
1431
1432<p>
1433If you experience kernel panics due to uhci or similar, try to compile USB
1434support as module and unload the modules before sending your laptop to sleep
1435mode. There are configuration options for this in <path>common.conf</path>
1436</p>
1437
1438<pre caption="Hibernating with swsusp">
1439# <i>nano -w /etc/hibernate/common.conf</i>
1440<comment>(Make sure you have a backup of your data)</comment>
1441# <i>hibernate</i>
1442</pre>
1443
1444<p>
1445The following section discusses the setup of TuxOnIce including fbsplash support
1446for a nice graphical progress bar during suspend and resume.
1447</p>
1448
1449<p>
1450The first part of the configuration is similar to the configuration of swsusp.
1451In case you didn't store the location of your swap partition in the kernel
1452config, you have to pass it as a kernel parameter with the
1453<c>resume=swap:/dev/SWAP</c> directive. If booting is not possible due to a
1454broken image, append the <c>noresume</c> parameter. Additionally, the
1455<c>hibernate-cleanup</c> init script invalidates TuxOnIce images during the boot
1456process.
1457</p>
1458
1459<pre caption="Invalidating TuxOnIce images during the boot process">
1460# <i>rc-update add hibernate-cleanup boot</i>
1461</pre>
1462
1463<p>
1464Now edit <path>/etc/hibernate/tuxonice.conf</path>, enable the <c>TuxOnIce</c>
1465options you need. Do not enable the <c>fbsplash</c> options in
1466<c>common.conf</c> just yet.
1467</p>
1468
1469<pre caption="Hibernating with TuxOnIce">
1470# <i>nano -w /etc/hibernate/tuxonice.conf</i>
1471<comment>(Make sure you have a backup of your data)</comment>
1472# <i>hibernate</i>
1473</pre>
1474
1475<p>
1476Please configure <c>fbsplash</c> now if you didn't do already. To enable
1477fbsplash support during hibernation, the <c>sys-apps/tuxonice-userui</c> package
1478is needed. Additionally, you've got to enable the <c>fbsplash</c> USE flag.
1479</p>
1480
1481<pre caption="Installing tuxonice-userui">
1482# <i>echo "sys-apps/tuxonice-userui fbsplash" >> /etc/portage/package.use</i>
1483# <i>emerge tuxonice-userui</i>
1484</pre>
1485
1486<p>
1487The ebuild tells you to make a symlink to the theme you want to use. For
1488example, to use the <c>livecd-2005.1</c> theme, run the following command:
1489</p>
1490
1491<pre caption="Using the livecd-2005.1 theme during hibernation">
1492# <i>ln -sfn /etc/splash/livecd-2005.1 /etc/splash/tuxonice</i>
1493</pre>
1494
1495<p>
1496If you don't want a black screen in the first part of the resume process, you
1497have to add the <c>tuxoniceui_fbsplash</c> tool to your initrd image. Assuming
1498you created the initrd image with <c>splash_geninitramfs</c> and saved it as
1499<path>/boot/fbsplash-emergence-1024x768</path>, here's how to do that.
1500</p>
1501
1502<pre caption="Adding tuxoniceui_fbsplash to an initrd image">
1503# <i>mount /boot</i>
1504# <i>mkdir ~/initrd.d</i>
1505# <i>cp /boot/fbsplash-emergence-1024x768 ~/initrd.d/</i>
1506# <i>cd ~/initrd.d</i>
1507# <i>gunzip -c fbsplash-emergence-1024x768 | cpio -idm --quiet -H newc</i>
1508# <i>rm fbsplash-emergence-1024x768</i>
1509# <i>cp /usr/sbin/tuxoniceui_fbsplash sbin/</i>
1510# <i>find . | cpio --quiet --dereference -o -H newc | gzip -9 > /boot/fbsplash-tuxonice-emergence-1024x768</i>
1511</pre>
1512
1513<p>
1514Afterwards adjust <path>grub.conf</path> (or <path>lilo.conf</path>) so that
1515your TuxOnIce kernel uses
1516<path>/boot/fbsplash-tuxonice-emergence-1024x768</path> as initrd image. You can
1517now test a dry run to see if everything is setup correctly.
1518</p>
1519
1520<pre caption="Test run for fbsplash hibernation">
1521# <i>tuxoniceui_fbsplash -t</i>
1522</pre>
1523
1524<p>
1525Afterwards open <path>/etc/hibernate/common.conf</path> and activate the
1526fbsplash options. Execute <c>hibernate</c> and enjoy.
1527</p>
1528
1529</body> 668<body>
1530</section>
1531</chapter>
1532 669
1533<chapter> 670<ul>
1534<title>Troubleshooting</title> 671 <li>
1535<section> 672 A ThinkWiki article on <uri
1536<body> 673 link="http://www.thinkwiki.org/wiki/How_to_reduce_power_consumption">How to
1537 674 reduce power consumption</uri> (on Linux). This article offers an exhaustive
1538<p> 675 list of measures one can take. However, it should be noted that the laptop
1539<e>Q:</e> I'm trying to change the CPU frequency, but 676 mode tools implements the majority of these (if properly configured).
1540<path>/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor</path> does not 677 </li>
1541exist. 678</ul>
1542</p>
1543
1544<p>
1545<e>A:</e> Make sure your processor supports CPU frequency scaling and you chose
1546the right CPUFreq driver for your processor. Here is a list of processors that
1547are supported by cpufreq (kernel 2.6.7): ARM Integrator, ARM-SA1100, ARM-SA1110,
1548AMD Elan - SC400, SC410, AMD mobile K6-2+, AMD mobile K6-3+, AMD mobile Duron,
1549AMD mobile Athlon, AMD Opteron, AMD Athlon 64, Cyrix Media GXm, Intel mobile
1550PIII and Intel mobile PIII-M on certain chipsets, Intel Pentium 4, Intel Xeon,
1551Intel Pentium M (Centrino), National Semiconductors Geode GX, Transmeta Crusoe,
1552VIA Cyrix 3 / C3, UltraSPARC-III, SuperH SH-3, SH-4, several "PowerBook" and
1553"iBook2" and various processors on some ACPI 2.0-compatible systems (only if
1554"ACPI Processor Performance States" are available to the ACPI/BIOS interface).
1555</p>
1556
1557<p>
1558<e>Q:</e> My laptop supports frequency scaling, but
1559<path>/sys/devices/system/cpu/cpu0/cpufreq/</path> is empty.
1560</p>
1561
1562<p>
1563<e>A:</e> Look for ACPI related error messages with <c>dmesg | grep ACPI</c>.
1564Try to update the BIOS, especially if a broken DSDT is reported. You can also
1565try to fix it yourself (which is beyond the scope of this guide).
1566</p>
1567
1568<p>
1569<e>Q:</e> My laptop supports frequency scaling, but according to
1570<path>/proc/cpuinfo</path> the speed never changes.
1571</p>
1572
1573<p>
1574<e>A:</e> Probably you have activated symmetric multiprocessing support
1575(CONFIG_SMP) in your kernel. Deactivate it and it should work. Some older
1576kernels had a bug causing this. In that case, run <c>emerge x86info</c>, update
1577your kernel as asked and check the current frequency with <c>x86info -mhz</c>.
1578</p>
1579
1580<p>
1581<e>Q:</e> I can change the CPU frequency, but the range is not as wide as in
1582another OS.
1583</p>
1584
1585<p>
1586<e>A:</e> You can combine frequency scaling with ACPI throttling to get a lower
1587minimum frequency. Notice that throttling doesn't save much energy and is mainly
1588used for thermal management (keeping your laptop cool and quiet). You can read
1589the current throttling state with <c>cat /proc/acpi/processor/CPU/throttling</c>
1590and change it with <c>echo -n "0:x" > /proc/acpi/processor/CPU/limit</c>, where
1591x is one of the Tx states listed in
1592<path>/proc/acpi/processor/CPU/throttling</path>.
1593</p>
1594
1595<p>
1596<e>Q:</e> When configuring the kernel, powersave, performance and userspace
1597governors show up, but that ondemand thing is missing. Where do I get it?
1598</p>
1599
1600<p>
1601<e>A:</e> The ondemand governor is only included in recent kernel sources. Try
1602updating them.
1603</p>
1604
1605<p>
1606<e>Q:</e> Battery life time seems to be worse than before.
1607</p>
1608
1609<p>
1610<e>A:</e> Check your BIOS settings. Maybe you forgot to re-enable some of the
1611settings.
1612</p>
1613
1614<p>
1615<e>Q:</e> My battery is charged, but KDE reports there would be 0% left and
1616immediately shuts down.
1617</p>
1618
1619<p>
1620<e>A:</e> Check that battery support is compiled into your kernel. If you use
1621it as a module, make sure the module is loaded.
1622</p>
1623
1624<p>
1625<e>Q:</e> My system logger reports things like "logger: ACPI group battery /
1626action battery is not defined".
1627</p>
1628
1629<p>
1630<e>A:</e> This message is generated by the <path>/etc/acpi/default.sh</path>
1631script that is shipped with acpid. You can safely ignore it. If you like to get
1632rid of it, you can comment the appropriate line in
1633<path>/etc/acpi/default.sh</path> as shown below:
1634</p>
1635
1636<pre caption="Disabling warnings about unknown acpi events">
1637 *) # logger "ACPI action $action is not defined"
1638</pre>
1639
1640<p>
1641<e>Q:</e> I have a Dell Inspiron 51XX and I don't get any ACPI events.
1642</p>
1643
1644<p>
1645<e>A:</e> This seems to be a kernel bug. Read on <uri
1646link="http://bugme.osdl.org/show_bug.cgi?id=1752">here</uri>.
1647</p>
1648
1649<p>
1650<e>Q:</e> I activated the <c>DynamicClocks</c> option in <path>xorg.conf</path>
1651and now X.org crashes / the screen stays black / my laptop doesn't shutdown
1652properly.
1653</p>
1654
1655<p>
1656<e>A:</e> This happens on some systems. You have to disable
1657<c>DynamicClocks</c>.
1658</p>
1659
1660<p>
1661<e>Q:</e> I want to use TuxOnIce, but it tells me my swap partition is too
1662small. Resizing is not an option.
1663</p>
1664
1665<p>
1666<e>A:</e> If there is enough free space on your system, you can use the
1667filewriter instead of the swapwriter. The <c>hibernate-script</c> supports it as
1668well. More information can be found in
1669<path>/usr/src/linux/Documentation/power/tuxonice.txt</path>.
1670</p>
1671
1672<p>
1673<e>Q:</e> I just bought a brand new battery, but it only lasts for some
1674minutes! What am I doing wrong?
1675</p>
1676
1677<p>
1678<e>A:</e> First follow your manufacturer's advice on how to charge the battery
1679correctly.
1680</p>
1681
1682<p>
1683<e>Q:</e> The above didn't help. What should I do then?
1684</p>
1685
1686<p>
1687<e>A:</e> Some batteries sold as "new" are in fact old ones. Try the following:
1688</p>
1689
1690<pre caption="Querying battery state">
1691$ <i>grep capacity /proc/acpi/battery/BAT0/info</i>
1692design capacity: 47520 mWh
1693last full capacity: 41830 mWh
1694</pre>
1695
1696<p>
1697If the "last full capacity" differs significantly from the design capacity,
1698your battery is probably broken. Try to claim your warranty.
1699</p>
1700
1701<p>
1702<e>Q:</e> My problem is not listed above. Where should I go next?
1703</p>
1704
1705<p>
1706<e>A:</e> Don't fear to contact me, <mail link="earthwings@gentoo.org">Dennis
1707Nienhüser</mail>, directly. The <uri link="http://forums.gentoo.org">Gentoo
1708Forums</uri> are a good place to get help as well. If you prefer IRC, try the
1709<c>#gentoo-laptop</c> <uri link="irc://irc.gentoo.org">channel</uri>.
1710</p>
1711 679
1712</body> 680</body>
1713</section> 681</section>
1714</chapter> 682</chapter>
1715</guide> 683</guide>

Legend:
Removed from v.1.48  
changed lines
  Added in v.1.49

  ViewVC Help
Powered by ViewVC 1.1.20