/[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.15 Revision 1.48
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.15 2005/10/28 14:48:06 so Exp $ --> 3<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/power-management-guide.xml,v 1.48 2011/08/17 07:19:29 swift Exp $ -->
4<guide link="/doc/en/power-management-guide.xml"> 4
5<guide>
5<title>Power Management Guide</title> 6<title>Power Management Guide</title>
6 7
7<author title="Author"> 8<author title="Author">
8 <mail link="fragfred@gmx.de">Dennis Nienhüser</mail> 9 <mail link="earthwings@gentoo.org">Dennis Nienhüser</mail>
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"/>
9</author> 16</author>
10 17
11<abstract> 18<abstract>
12Power Management is the key to extend battery run time on mobile systems like 19Power Management is the key to extend battery run time on mobile systems like
13laptops. This guide assists you setting it up on your laptop. 20laptops. This guide assists you setting it up on your laptop.
15 22
16<!-- The content of this document is licensed under the CC-BY-SA license --> 23<!-- The content of this document is licensed under the CC-BY-SA license -->
17<!-- See http://creativecommons.org/licenses/by-sa/2.5 --> 24<!-- See http://creativecommons.org/licenses/by-sa/2.5 -->
18<license/> 25<license/>
19 26
20<version>1.25</version> 27<version>4</version>
21<date>2005-10-02</date> 28<date>2011-08-17</date>
22 29
23<chapter> 30<chapter>
24<title>Introduction</title> 31<title>Introduction</title>
25<section> 32<section>
26<title>Why Power Management?</title>
27<body> 33<body>
34
35<!--
36 Remove this note after 6 months - ETA 01/02/2012
37 By then, we can assume that OpenRC migrations are not that frequent
38 anymore and this note can be dropped.
39 ~ Sven Vermeulen
40-->
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>
28 46
29<p> 47<p>
30Capacity and lifetime of laptop batteries have improved much in the last years. 48Capacity and lifetime of laptop batteries have improved much in the last years.
31Nevertheless modern processors consume much more energy than older ones and 49Nevertheless modern processors consume much more energy than older ones and
32each laptop generation introduces more devices hungry for energy. That's why 50each laptop generation introduces more devices hungry for energy. That's why
35intelligent Power Management policies. 53intelligent Power Management policies.
36</p> 54</p>
37 55
38</body> 56</body>
39</section> 57</section>
40
41<section> 58<section>
42<title>A quick overview</title> 59<title>A Quick Overview</title>
43<body> 60<body>
44 61
45<p> 62<p>
46Please notice that this guide describes Power Management for <e>laptops</e>. 63Please notice that this guide describes Power Management for <e>laptops</e>.
47While some sections might also suite for <e>servers</e>, others do not and may 64While some sections might also suite for <e>servers</e>, others do not and may
53As this guide has become rather long, here's a short overview helping you to 70As this guide has become rather long, here's a short overview helping you to
54find your way through it. 71find your way through it.
55</p> 72</p>
56 73
57<p> 74<p>
58The <e>Prerequisites</e> chapter talks about some requirements that should be 75The <uri link="#doc_chap2">Prerequisites</uri> chapter talks about some
59met before any of the following device individual sections will work. This 76requirements that should be met before any of the following device individual
60includes BIOS settings, kernel configuration and some simplifications in user 77sections will work. This includes BIOS settings, kernel configuration and some
61land. The following three chapters focus on devices that typically consume 78simplifications in user land. The following three chapters focus on devices
62most energy - processor, display and hard drive. Each can be configured 79that typically consume most energy - processor, display and hard drive. Each
63seperately. <e>CPU Power Management</e> shows how to adjust the processor's 80can be configured separately. <uri link="#doc_chap3">CPU Power Management</uri>
64frequency to save a maximum of energy whithout losing too much performance. A 81shows how to adjust the processor's frequency to save a maximum of energy
65few different tricks prevent your hard drive from working unnecessarily often 82without losing too much performance. A few different tricks prevent your hard
66in <e>Disk Power Management</e> (decreasing noise level as a nice side 83drive from working unnecessarily often in <uri link="#doc_chap5">Disk Power
67effect). Some notes on graphics cards, Wireless LAN and USB finish the device 84Management</uri> (decreasing noise level as a nice side effect). Some notes on
68section in <e>Power Management for other devices</e> while another chapter is 85graphics cards, Wireless LAN and USB finish the device section in <uri
69dedicated to the (rather experimental) <e>sleep states</e>. Last not least 86link="#doc_chap6">Power Management For Other Devices</uri> while another
70<e>Troubleshooting</e> lists common pitfalls. 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.
71</p> 90</p>
72 91
73</body> 92</body>
74</section>
75
76<section> 93</section>
94<section>
77<title>Power Budget for each component</title> 95<title>Power Budget For Each Component</title>
78<body> 96<body>
79 97
80<figure link="/images/energy-budget.png" short="Which component consumes how 98<figure link="/images/energy-budget.png" short="Which component consumes how
81much energy?" caption="Power budget for each component"/> 99much energy?" caption="Power budget for each component"/>
82 100
93</chapter> 111</chapter>
94 112
95<chapter> 113<chapter>
96<title>Prerequisites</title> 114<title>Prerequisites</title>
97<section> 115<section>
98<title>What has to be done first</title>
99<body>
100
101<p>
102Before going into the details on making individual devices Power Management
103aware, make sure certain requirements are met. After controlling the BIOS
104settings, some kernel options want to be enabled - these are in short ACPI,
105sleep states and CPU frequency scaling. As power saving most of the time comes
106along with performance loss or increased latency, it should only be enabled
107when running on batteries. That's where a new runlevel <e>battery</e> comes in
108handy.
109</p>
110
111</body> 116<body>
112</section> 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>
113<section> 128</section>
129<section>
114<title>The BIOS part</title> 130<title>The BIOS Part</title>
115<body> 131<body>
116 132
117<p> 133<p>
118First have a look into your BIOS Power Management settings. The best way is to 134First have a look into your BIOS Power Management settings. The best way is to
119combine BIOS and operating system policies, but for the moment it's better to 135combine BIOS and operating system policies, but for the moment it's better to
123</p> 139</p>
124 140
125</body> 141</body>
126</section> 142</section>
127<section> 143<section>
144<title>Setting USE Flags</title>
145<body>
146
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>
155
156</body>
157</section>
158<section>
128<title>Configuring the kernel</title> 159<title>Configuring The Kernel</title>
129<body> 160<body>
130 161
131<p> 162<p>
132ACPI (Advanced Configuration and Power Interface) support in the kernel is 163ACPI (Advanced Configuration and Power Interface) support in the kernel is
133still work in progress. Using a recent kernel will make sure you'll get the 164still work in progress. Using a recent kernel will make sure you'll get the
134most out of it. 165most out of it.
135</p> 166</p>
136 167
137<p> 168<p>
138There are different kernel sources in Portage. I'd recommend using 169There are different kernel sources in Portage. I'd recommend using
139<c>gentoo-sources</c> or <c>suspend2-sources</c>. The latter contains patches 170<c>gentoo-sources</c> or <c>tuxonice-sources</c>. The latter contains patches
140for Software Suspend 2, see the chapter about sleep states for details. When 171for TuxOnIce, see the chapter about <uri link="#doc_chap7">sleep states</uri>
141configuring the kernel, activate at least these options: 172for more details. When configuring the kernel, activate at least these options:
142</p> 173</p>
143 174
144<pre caption="Minimum kernel setup for Power Management (Kernel 2.6)"> 175<pre caption="Minimum kernel setup for Power Management (Kernel 2.6)">
145Power Management Options ---&gt; 176Power management and ACPI options ---&gt;
146 [*] Power Management Support 177[*] Power Management support
147 [ ] Software Suspend 178 [ ] Software Suspend
148 179
149 ACPI( Advanced Configuration and Power Interface ) Support ---&gt; 180 ACPI( Advanced Configuration and Power Interface ) Support ---&gt;
150 [*] ACPI Support 181 [ ] Deprecated /proc/acpi/ files
151 [ ] Sleep States
152 [ ] /proc/acpi/sleep (deprecated)
153 [*] AC Adapter 182 [*] AC Adapter
154 [*] Battery 183 [*] Battery
155 &lt;M&gt; Button 184 &lt;M&gt; Button
156 &lt;M&gt; Video 185 &lt;M&gt; Video
157 [ ] Generic Hotkey 186 [ ] Generic Hotkey
163 &lt; &gt; Toshiba Laptop Extras 192 &lt; &gt; Toshiba Laptop Extras
164 (0) Disable ACPI for systems before Jan 1st this year 193 (0) Disable ACPI for systems before Jan 1st this year
165 [ ] Debug Statements 194 [ ] Debug Statements
166 [*] Power Management Timer Support 195 [*] Power Management Timer Support
167 &lt; &gt; ACPI0004,PNP0A05 and PNP0A06 Container Driver (EXPERIMENTAL) 196 &lt; &gt; ACPI0004,PNP0A05 and PNP0A06 Container Driver (EXPERIMENTAL)
168 197
169 CPU Frequency Scaling ---&gt; 198 CPU Frequency Scaling ---&gt;
170 [*] CPU Frequency scaling 199 [*] CPU Frequency scaling
171 [ ] Enable CPUfreq debugging 200 [ ] Enable CPUfreq debugging
172 &lt; &gt; CPU frequency translation statistics 201 &lt; &gt; CPU frequency translation statistics
173 [ ] CPU frequency translation statistics details 202 [ ] CPU frequency translation statistics details
186(see below). If you own an ASUS, Medion, IBM Thinkpad or Toshiba laptop, enable 215(see below). If you own an ASUS, Medion, IBM Thinkpad or Toshiba laptop, enable
187the appropriate section. 216the appropriate section.
188</p> 217</p>
189 218
190<p> 219<p>
191The kernel has to know how to enable CPU frequency scaling on your processor. As 220The kernel has to know how to enable CPU frequency scaling on your processor.
192each type of CPU has a different interface, you've got to choose the right 221As each type of CPU has a different interface, you've got to choose the right
193driver for your processor. Be careful here - enabling <e>Intel Pentium 4 clock 222driver for your processor. Be careful here - enabling <c>Intel Pentium 4 clock
194modulation</e> on a Pentium M system will lead to strange results for example. 223modulation</c> on a Pentium M system will lead to strange results for example.
195Consult the kernel documentation if you're unsure which one to take. 224Consult the kernel documentation if you're unsure which one to take.
196</p> 225</p>
197 226
198<p> 227<p>
199Compile your kernel, make sure the right modules get loaded at startup and boot 228Compile your kernel, make sure the right modules get loaded at startup and boot
200into your new ACPI-enabled kernel. Next run <c>emerge sys-power/acpid</c> to get 229into your new ACPI-enabled kernel. Next run <c>emerge sys-power/acpid</c> to
201the acpi daemon. This one informs you about events like switching from AC to 230get the acpi daemon. This one informs you about events like switching from AC
202battery or closing the lid. Make sure the modules are loaded if you didn't 231to battery or closing the lid. Make sure the modules are loaded if you didn't
203compile them into the kernel and start acpid by executing 232compile them into the kernel and start acpid by executing <c>/etc/init.d/acpid
204<c>/etc/init.d/acpid start</c>. Run <c>rc-update add acpid default</c> to load 233start</c>. Run <c>rc-update add acpid default</c> to load it on startup. You'll
205it on startup. You'll soon see how to use it. 234soon see how to use it.
206</p> 235</p>
207 236
208<pre caption="Installing acpid"> 237<pre caption="Installing acpid">
209# <i>emerge sys-power/acpid</i> 238# <i>emerge sys-power/acpid</i>
210# <i>/etc/init.d/acpid start</i> 239# <i>/etc/init.d/acpid start</i>
212</pre> 241</pre>
213 242
214</body> 243</body>
215</section> 244</section>
216<section> 245<section>
217<title>Creating a "battery" runlevel</title> 246<title>Creating A "battery" Runlevel</title>
218<body> 247<body>
219 248
220<p> 249<p>
221The default policy will be to enable Power Management only when needed - 250The default policy will be to enable Power Management only when needed -
222running on batteries. To make the switch between AC and battery convenient, 251running on batteries. To make the switch between AC and battery convenient,
223create a runlevel <e>battery</e> that holds all the scripts starting and 252create a runlevel <c>battery</c> that holds all the scripts starting and
224stopping Power Management. 253stopping Power Management.
225</p> 254</p>
226 255
227<note> 256<note>
228You can safely skip this section if you don't like the idea of having another 257You can safely skip this section if you don't like the idea of having another
229runlevel. However, skipping this step will make the rest a bit trickier to set 258runlevel. However, skipping this step will make the rest a bit trickier to set
230up. The next sections assume a runlevel <e>battery</e> exists. 259up. The next sections assume a runlevel <c>battery</c> exists.
231</note> 260</note>
232 261
233<pre caption="Creating a battery runlevel"> 262<pre caption="Creating a battery runlevel">
234# <i>cd /etc/runlevels</i> 263# <i>cd /etc/runlevels</i>
235# <i>cp -a default battery</i> 264# <i>cp -a default battery</i>
236</pre> 265</pre>
237 266
238<p> 267<p>
239Finished. Your new runlevel <e>battery</e> contains everything like 268Finished. Your new runlevel <c>battery</c> contains everything like
240<e>default</e>, but there is no automatic switch between both yet. Time to 269<c>default</c>, but there is no automatic switch between both yet. Time to
241change it. 270change it.
242</p> 271</p>
243 272
244</body> 273</body>
245</section> 274</section>
246<section> 275<section>
247<title>Reacting on ACPI events</title> 276<title>Reacting On ACPI Events</title>
248<body> 277<body>
249 278
250<p> 279<p>
251Typical ACPI events are closing the lid, changing the power source or pressing 280Typical ACPI events are closing the lid, changing the power source or pressing
252the sleep button. An important event is changing the power source, which should 281the sleep button. An important event is changing the power source, which should
254</p> 283</p>
255 284
256<p> 285<p>
257First you need a script which changes the runlevel to <c>default</c> 286First you need a script which changes the runlevel to <c>default</c>
258respectively <c>battery</c> depending on the power source. The script uses the 287respectively <c>battery</c> depending on the power source. The script uses the
259<c>on_ac_power</c> command from <c>sys-power/powermgmt-base</c> - make sure the 288<c>on_ac_power</c> command from <c>sys-power/pm-utils</c> - make sure the
260package is installed on your system. 289package is installed on your system.
261</p> 290</p>
262 291
263<pre caption="Installing powermgt-base"> 292<pre caption="Installing pm-utils">
264<i># emerge powermgmt-base</i> 293# <i>emerge pm-utils</i>
265</pre> 294</pre>
266 295
267<p> 296<p>
268You are now able to determine the power source by executing 297You are now able to determine the power source by executing <c>on_ac_power
269<c>on_ac_power &amp;&amp; echo AC available || echo Running on batteries</c> in 298&amp;&amp; echo AC available || echo Running on batteries</c> in a shell. The
270a shell. The script below is responsible for changing runlevels. Save it as 299script below is responsible for changing runlevels. Save it as
271<path>/etc/acpi/actions/pmg_switch_runlevel.sh</path>. 300<path>/etc/acpi/actions/pmg_switch_runlevel.sh</path>.
272</p> 301</p>
273 302
274<pre caption="/etc/acpi/actions/pmg_switch_runlevel.sh"> 303<pre caption="/etc/acpi/actions/pmg_switch_runlevel.sh">
275#!/bin/bash 304#!/bin/bash
276 305
277<comment># BEGIN configuration</comment> 306# BEGIN configuration
278RUNLEVEL_AC="default" 307RUNLEVEL_AC="default"
279RUNLEVEL_BATTERY="battery" 308RUNLEVEL_BATTERY="battery"
280<comment># END configuration</comment> 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
281 318
282 319
283if [ ! -d "/etc/runlevels/${RUNLEVEL_AC}" ] 320if [ ! -d "/etc/runlevels/${RUNLEVEL_AC}" ]
284then 321then
285 logger "${0}: Runlevel ${RUNLEVEL_AC} does not exist. Aborting." 322 ${LOGGER} "${0}: Runlevel ${RUNLEVEL_AC} does not exist. Aborting."
286 exit 1 323 exit 1
287fi 324fi
288 325
289if [ ! -d "/etc/runlevels/${RUNLEVEL_BATTERY}" ] 326if [ ! -d "/etc/runlevels/${RUNLEVEL_BATTERY}" ]
290then 327then
291 logger "${0}: Runlevel ${RUNLEVEL_BATTERY} does not exist. Aborting." 328 ${LOGGER} "${0}: Runlevel ${RUNLEVEL_BATTERY} does not exist. Aborting."
292 exit 1 329 exit 1
293fi 330fi
294 331
295if on_ac_power 332if ${on_ac_power}
296then 333then
297 if [[ "$(cat /var/lib/init.d/softlevel)" != "${RUNLEVEL_AC}" ]] 334 if [[ "$(rc-status --runlevel)" != "${RUNLEVEL_AC}" ]]
298 then 335 then
299 logger "Switching to ${RUNLEVEL_AC} runlevel" 336 ${LOGGER} "Switching to ${RUNLEVEL_AC} runlevel"
300 /sbin/rc ${RUNLEVEL_AC} 337 /sbin/rc ${RUNLEVEL_AC}
301 fi 338 fi
302elif [[ "$(cat /var/lib/init.d/softlevel)" != "${RUNLEVEL_BATTERY}" ]] 339elif [[ "$(rc-status --runlevel)" != "${RUNLEVEL_BATTERY}" ]]
303then 340then
304 logger "Switching to ${RUNLEVEL_BATTERY} runlevel" 341 ${LOGGER} "Switching to ${RUNLEVEL_BATTERY} runlevel"
305 /sbin/rc ${RUNLEVEL_BATTERY} 342 /sbin/rc ${RUNLEVEL_BATTERY}
306fi 343fi
307</pre> 344</pre>
308 345
309<p> 346<p>
310Dont forget to run <c>chmod +x /etc/acpi/actions/pmg_switch_runlevel.sh</c> to 347Dont forget to run <c>chmod +x /etc/acpi/actions/pmg_switch_runlevel.sh</c> to
311make the script executable. The last thing that needs to be done is calling the 348make the script executable. The last thing that needs to be done is calling the
312script whenever the power source changes. That's done by catching ACPI events 349script whenever the power source changes. That's done by catching ACPI events
313with the help of <c>acpid</c>. First you need to know which events are 350with the help of <c>acpid</c>. First you need to know which events are
314generated when the power source changes. The events are called 351generated when the power source changes. The events are called
315<e>ac_adapter</e> and <e>battery</e> on most laptops, but it might be different 352<c>ac_adapter</c> and <c>battery</c> on most laptops, but it might be different
316on yours. 353on yours.
317</p> 354</p>
318 355
319<pre caption="Determining ACPI events for changing the power source"> 356<pre caption="Determining ACPI events for changing the power source">
320<i># tail -f /var/log/acpid | grep "received event"</i> 357# <i>tail -f /var/log/messages | grep "ACPI event"</i>
321</pre> 358</pre>
322 359
323<p> 360<p>
324Run the command above and pull the power cable. You should see something 361Run the command above and pull the power cable. You should see something like
325like this: 362this:
326</p> 363</p>
327 364
328<pre caption="Sample output for power source changes"> 365<pre caption="Sample output for power source changes">
329[Tue Sep 20 17:39:06 2005] received event "ac_adapter AC 00000080 00000000" 366[Tue Sep 20 17:39:06 2005] ACPI event "ac_adapter AC 00000080 00000000"
330[Tue Sep 20 17:39:06 2005] received event "battery BAT0 00000080 00000001" 367[Tue Sep 20 17:39:06 2005] ACPI event "battery BAT0 00000080 00000001"
331</pre> 368</pre>
332 369
333<p> 370<p>
334The interesting part is the quoted string after <e>received event</e>. It will 371The interesting part is the quoted string after <c>ACPI event</c>. It will
335be matched by the event line in the files you are going to create below. Don't 372be matched by the event line in the files you are going to create below. Don't
336worry if your system generates multiple events or always the same. As long as 373worry if your system generates multiple events or always the same. As long as
337any event is generated, runlevel changing will work. 374any event is generated, runlevel changing will work.
338</p> 375</p>
339 376
354<p> 391<p>
355Finally acpid has to be restarted to recognize the changes. 392Finally acpid has to be restarted to recognize the changes.
356</p> 393</p>
357 394
358<pre caption="Finishing runlevel switching with acpid"> 395<pre caption="Finishing runlevel switching with acpid">
359<i># /etc/init.d/acpid restart</i> 396# <i>/etc/init.d/acpid restart</i>
360</pre> 397</pre>
361 398
362<p> 399<p>
363Give it a try: Plug AC in and out and watch syslog for the "Switching to AC 400Give it a try: Plug AC in and out and watch syslog for the "Switching to AC
364mode" or "Switching to battery mode" messages. See the Troubleshooting 401mode" or "Switching to battery mode" messages. See the <uri
365section if the script is not able to detect the power source correctly. 402link="#doc_chap8">Troubleshooting section</uri> if the script is not able to
403detect the power source correctly.
366</p> 404</p>
367 405
368<p> 406<p>
369Due to the nature of the event mechanism, your laptop will boot into runlevel 407Due to the nature of the event mechanism, your laptop will boot into runlevel
370<e>default</e> regardless of the AC/battery state. This is fine when running 408<c>default</c> regardless of the AC/battery state. This is fine when running
371from AC, but we'd like to boot into the battery runlevel otherwise. One 409from AC, but we'd like to boot into the battery runlevel otherwise. One
372solution would be to add another entry to the boot loader with the parameter 410solution would be to add another entry to the boot loader with the parameter
373<c>softlevel=battery</c>, but it's likely to forget choosing it. A better way 411<c>softlevel=battery</c>, but it's likely to forget choosing it. A better way
374is faking an ACPI event in the end of the boot process and letting 412is faking an ACPI event in the end of the boot process and letting
375<path>pmg_switch_runlevel.sh</path> script decide whether a 413<path>pmg_switch_runlevel.sh</path> script decide whether a runlevel change is
376runlevel change is necessary. Open <path>/etc/conf.d/local.start</path> in your 414necessary. Create a <path>/etc/local.d/battery.start</path> file with the
377favourite editor and add these lines: 415following contents:
378</p> 416</p>
379 417
380<pre caption="Runlevel adjustment at boot time by editing local.start"> 418<pre caption="Runlevel adjustment at boot time through local.d/battery.start">
419#!/bin/sh
381<comment># Fake acpi event to switch runlevel if running on batteries</comment> 420<comment># Fake acpi event to switch runlevel if running on batteries</comment>
382/etc/acpi/actions/pmg_switch_runlevel.sh "battery/battery" 421/etc/acpi/actions/pmg_switch_runlevel.sh "battery/battery"
383</pre> 422</pre>
384 423
385<p> 424<p>
386Prepared like this you can activate Power Management policies for individual 425Don't forget to mark the file as executable (<c>chmod +x
387devices. 426/etc/local.d/battery.start</c>). Prepared like this you can activate Power
427Management policies for individual devices.
388</p> 428</p>
389 429
390</body> 430</body>
391</section> 431</section>
392</chapter> 432</chapter>
393 433
394<chapter> 434<chapter>
395<title>CPU Power Management</title> 435<title>CPU Power Management</title>
396<section> 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>
448<section>
397<title>Some technical terms</title> 449<title>Some Technical Terms</title>
398<body> 450<body>
399 451
400<p> 452<p>
401CPU frequency scaling brings up some technical terms that might be unknown to 453CPU frequency scaling brings up some technical terms that might be unknown to
402you. Here's a quick introduction. 454you. Here's a quick introduction.
403</p> 455</p>
404 456
405<p> 457<p>
406First of all, the kernel has to be able to change the processor's frequency. 458First of all, the kernel has to be able to change the processor's frequency.
407The <e>CPUfreq processor driver</e> knows the commands to do it on your CPU. 459The <b>CPUfreq processor driver</b> knows the commands to do it on your CPU.
408Thus it's important to choose the right one in your kernel. You should 460Thus it's important to choose the right one in your kernel. You should already
409already have done it above. Once the kernel knows how to change frequencies, 461have done it above. Once the kernel knows how to change frequencies, it has to
410it has to know which frequency it should set. This is done according to the 462know which frequency it should set. This is done according to the <b>policy</b>
411<e>policy</e> which consists of a <e>CPUfreq policy</e> and a 463which consists of a <b>CPUfreq policy</b> and a <b>governor</b>. A CPUfreq
412<e>governor</e>. A CPUfreq policy are just two numbers which define a range 464policy are just two numbers which define a range the frequency has to stay
413the frequency has to stay between - minimal and maximal frequency. The 465between - minimal and maximal frequency. The governor now decides which of the
414governor now decides which of the available frequencies in between minimal 466available frequencies in between minimal and maximal frequency to choose. For
415and maximal frequency to choose. For example, the <e>powersave governor</e> 467example, the <b>powersave governor</b> always chooses the lowest frequency
416always chooses the lowest frequency available, the <e>performance 468available, the <b>performance governor</b> the highest one. The <b>userspace
417governor</e> the highest one. The <e>userspace governor</e> makes no decision 469governor</b> makes no decision but chooses whatever the user (or a program in
418but chooses whatever the user (or a program in userspace) wants - which means 470userspace) wants - which means it reads the frequency from
419it reads the frequency from
420<path>/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed</path>. 471<path>/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed</path>.
421</p> 472</p>
422 473
423<p> 474<p>
424This doesn't sound like dynamic frequency changes yet and in fact it isn't. 475This doesn't sound like dynamic frequency changes yet and in fact it isn't.
425Dynamics however can be accomplished with various approaches. For example, 476Dynamics however can be accomplished with various approaches. For example, the
426the <e>ondemand governor</e> makes its decisions depending on the current CPU 477<b>ondemand governor</b> makes its decisions depending on the current CPU load.
427load. The same is done by various userland tools like <c>cpudyn</c>, 478The same is done by various userland tools like <c>cpudyn</c>, <c>cpufreqd</c>,
428<c>cpufreqd</c>, <c>powernowd</c> and many more. ACPI events can be used to 479<c>powernowd</c> and many more. ACPI events can be used to enable or disable
429enable or disable dynamic frequency changes depending on power source. 480dynamic frequency changes depending on power source.
430</p> 481</p>
431 482
432</body> 483</body>
433</section>
434<section> 484</section>
485<section>
435<title>Setting the frequency manually</title> 486<title>Setting The Frequency</title>
436<body> 487<body>
437 488
438<p> 489<p>
439Decreasing CPU speed and voltage has two advantages: On the one hand less 490Decreasing CPU speed and voltage has two advantages: On the one hand less
440energy is consumed, on the other hand there is thermal improvement as your 491energy is consumed, on the other hand there is thermal improvement as your
443between performance loss and energy saving. 494between performance loss and energy saving.
444</p> 495</p>
445 496
446<note> 497<note>
447Not every laptop supports frequency scaling. If unsure, have a look at the list 498Not every laptop supports frequency scaling. If unsure, have a look at the list
448of supported processors in the <e>Troubleshooting</e> section to verify your's 499of supported processors in the <uri link="#doc_chap8">Troubleshooting</uri>
449is supported. 500section to verify yours is supported.
450</note> 501</note>
451 502
452<p> 503<p>
453It's time to test whether CPU frequency changing works. Let's install another 504It's time to test whether CPU frequency changing works. Let's install another
454tool which is very handy for debugging purposes: <c>sys-power/cpufrequtils</c> 505tool: <c>sys-power/cpufrequtils</c>.
455</p> 506</p>
456 507
457<pre caption="Checking CPU frequency"> 508<pre caption="Checking CPU frequency">
458# <i>emerge cpufrequtils</i> 509# <i>emerge cpufrequtils</i>
459# <i>cpufreq-info</i> 510# <i>cpufreq-info</i>
480 531
481<p> 532<p>
482Now play around with <c>cpufreq-set</c> to make sure frequency switching works. 533Now play around with <c>cpufreq-set</c> to make sure frequency switching works.
483Run <c>cpufreq-set -g ondemand</c> for example to activate the ondemand 534Run <c>cpufreq-set -g ondemand</c> for example to activate the ondemand
484governor and verify the change with <c>cpufreq-info</c>. If it doesn't work as 535governor and verify the change with <c>cpufreq-info</c>. If it doesn't work as
485expected, you might find help in the Troubleshooting section in the end of this 536expected, you might find help in the <uri link="#doc_chap8">Troubleshooting
486guide. 537section</uri> in the end of this guide.
538</p>
539
487</p> 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>
488 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
489</body> 558</body>
490</section>
491<section> 559</section>
492<title>Automated frequency adaption</title> 560<section>
561<title>Other CPU Speed Utilities</title>
493<body> 562<body>
494 563
495<p> 564<p>
496The above is quite nice, but not doable in daily life. Better let your system 565While <c>cpufrequtils</c> may be the best all-around program, there are some
497set the appropriate frequency automatically. There are many different 566other choices available in Portage. The following table gives a quick overview
498approaches to do this. The following table gives a quick overview to help you 567of available CPU speed utilities. It's roughly separated in three categories
499decide on one of them. It's roughly seperated in three categories
500<e>kernel</e> for approaches that only need kernel support, <e>daemon</e> for 568<b>kernel</b> for approaches that only need kernel support, <b>daemon</b> for
501programs that run in the background and <e>graphical</e> for programs that 569programs that run in the background and <b>graphical</b> for programs that
502provide a GUI for easy configuration and changes. 570provide a GUI for easy configuration and changes.
503</p> 571</p>
504 572
505<table> 573<table>
506<tr> 574<tr>
530 <ti>Kernel</ti> 598 <ti>Kernel</ti>
531 <ti>CPU load</ti> 599 <ti>CPU load</ti>
532 <ti>N.A.</ti> 600 <ti>N.A.</ti>
533 <ti>N.A.</ti> 601 <ti>N.A.</ti>
534 <ti> 602 <ti>
535 Unlike the ondemand governor, conversative doesn't jump to maximum 603 Unlike the ondemand governor, conversative doesn't jump to maximum
536 frequency when CPU load is high, but increases the frequency step by 604 frequency when CPU load is high, but increases the frequency step by step.
537 step. Further tuning through files in 605 Further tuning through files in
538 <path>/sys/devices/system/cpu/cpu0/cpufreq/ondemand/</path>. Still 606 <path>/sys/devices/system/cpu/cpu0/cpufreq/ondemand/</path>. Still requires
539 requires userland tools (programs, scripts) if governor switching or 607 userland tools (programs, scripts) if governor switching or similar is
540 similar is desired. 608 desired.
541 </ti> 609 </ti>
542</tr> 610</tr>
543<tr> 611<tr>
544 <ti><uri link="http://mnm.uib.es/~gallir/cpudyn/">cpudyn</uri></ti> 612 <ti><uri link="http://mnm.uib.es/~gallir/cpudyn/">cpudyn</uri></ti>
545 <ti>Daemon</ti> 613 <ti>Daemon</ti>
552 </ti> 620 </ti>
553</tr> 621</tr>
554<tr> 622<tr>
555 <ti><uri link="http://sourceforge.net/projects/cpufreqd/">cpufreqd</uri></ti> 623 <ti><uri link="http://sourceforge.net/projects/cpufreqd/">cpufreqd</uri></ti>
556 <ti>Daemon</ti> 624 <ti>Daemon</ti>
557 <ti>Battery state, CPU load, temperature, running programs</ti> 625 <ti>Battery state, CPU load, temperature, running programs and more</ti>
558 <ti>All available</ti> 626 <ti>All available</ti>
559 <ti>None</ti> 627 <ti>None</ti>
560 <ti> 628 <ti>
561 Sophisticated (but also complicated) setup. 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.
562 </ti> 633 </ti>
563</tr> 634</tr>
564<tr> 635<tr>
565 <ti> 636 <ti>
566 <uri link="http://www.deater.net/john/powernowd.html">powernowd</uri> 637 <uri link="http://www.deater.net/john/powernowd.html">powernowd</uri>
573 Supports SMP. 644 Supports SMP.
574 </ti> 645 </ti>
575</tr> 646</tr>
576<tr> 647<tr>
577 <ti> 648 <ti>
578 <uri link="http://fatcat.ftj.agh.edu.pl/~nelchael/index.php?cat=projs&amp;subcat=ncpufreqd&amp;language=en">ncpufreqd</uri> 649 <uri
650 link="http://projects.simpledesigns.com.pl/project/ncpufreqd/">ncpufreqd</uri>
579 </ti> 651 </ti>
580 <ti>Daemon</ti> 652 <ti>Daemon</ti>
581 <ti>Temperature</ti> 653 <ti>Temperature</ti>
582 <ti>None</ti> 654 <ti>None</ti>
583 <ti>Powersave, performance</ti> 655 <ti>Powersave, performance</ti>
623 695
624<p> 696<p>
625While adjusting the frequency to the current load looks simple at a first 697While adjusting the frequency to the current load looks simple at a first
626glance, it's not such a trivial task. A bad algorithm can cause switching 698glance, it's not such a trivial task. A bad algorithm can cause switching
627between two frequencies all the time or wasting energy when setting frequency 699between two frequencies all the time or wasting energy when setting frequency
628to an unnecessary high level. 700to an unnecessary high level.
629</p> 701</p>
630 702
631<p> 703<p>
632Which one to choose? If you have no idea about it, try <c>cpufreqd</c>: 704Which one to choose? If you have no idea about it, try <c>cpufreqd</c>:
633</p> 705</p>
637</pre> 709</pre>
638 710
639<p> 711<p>
640<c>cpufreqd</c> can be configured by editing <path>/etc/cpufreqd.conf</path>. 712<c>cpufreqd</c> can be configured by editing <path>/etc/cpufreqd.conf</path>.
641The default one that ships with cpufreqd may look a bit confusing. I recommend 713The default one that ships with cpufreqd may look a bit confusing. I recommend
642replacing it with the one from Gentoo developer Henrik Brix Andersen (see 714replacing it with the one from former Gentoo developer Henrik Brix Andersen
643below). 715(see below). Please notice that you need cpufreqd-2.0.0 or later. Earlier
716versions have a different syntax for the config file.
644</p> 717</p>
645 718
646<pre caption="/etc/cpufreqd.conf"> 719<pre caption="/etc/cpufreqd.conf (cpufreqd-2.0.0 and later)">
647[General] 720[General]
648pidfile=/var/run/cpufreqd.pid 721pidfile=/var/run/cpufreqd.pid
649poll_interval=2 722poll_interval=3
650pm_type=acpi 723enable_plugins=acpi_ac, acpi_battery
724enable_remote=1
725remote_group=wheel
651verbosity=5 726verbosity=5
727[/General]
652 728
653[Profile] 729[Profile]
654name=ondemand 730name=ondemand
655minfreq=0% 731minfreq=0%
656maxfreq=100% 732maxfreq=100%
657policy=ondemand 733policy=ondemand
734[/Profile]
658 735
659[Profile] 736[Profile]
660name=conservative 737name=conservative
661minfreq=0% 738minfreq=0%
662maxfreq=100% 739maxfreq=100%
663policy=conservative 740policy=conservative
741[/Profile]
664 742
665[Profile] 743[Profile]
666name=powersave 744name=powersave
667minfreq=0% 745minfreq=0%
668maxfreq=100% 746maxfreq=100%
669policy=powersave 747policy=powersave
748[/Profile]
670 749
671[Profile] 750[Profile]
672name=performance 751name=performance
673minfreq=0% 752minfreq=0%
674maxfreq=100% 753maxfreq=100%
675policy=performance 754policy=performance
755[/Profile]
676 756
677[Rule] 757[Rule]
678name=battery 758name=battery
679ac=off 759ac=off
680profile=conservative 760profile=conservative
761[/Rule]
681 762
682[Rule] 763[Rule]
683name=battery_low 764name=battery_low
684ac=off 765ac=off
685battery_interval=0-10 766battery_interval=0-10
686profile=powersave 767profile=powersave
768[/Rule]
687 769
688[Rule] 770[Rule]
689name=ac 771name=ac
690ac=on 772ac=on
691profile=ondemand 773profile=ondemand
774[/Rule]
692</pre> 775</pre>
693 776
694<p> 777<p>
695Now you can start the cpufreqd daemon. Add it to the <e>default</e> and 778Now you can start the cpufreqd daemon. Add it to the <c>default</c> and
696<e>battery</e> runlevel as well. 779<c>battery</c> runlevel as well.
697</p> 780</p>
698 781
699<pre caption="Starting cpufreqd"> 782<pre caption="Starting cpufreqd">
700# <i>rc-update add cpufreqd default battery</i> 783# <i>rc-update add cpufreqd default battery</i>
701# <i>rc</i> 784# <i>/etc/init.d/cpufreqd start</i>
785</pre>
786
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>.
702</pre> 794</p>
703 795
704<warn> 796<warn>
705Do not run more than one of the above programs at the same time. It may cause 797Do not run more than one of the above programs at the same time. It may cause
706confusion like switching between two frequencies all the time. 798confusion like switching between two frequencies all the time.
707</warn> 799</warn>
708 800
709</body> 801</body>
710</section> 802</section>
711
712<section> 803<section>
713<title>Verifying the result</title> 804<title>Verifying the result</title>
714
715<body> 805<body>
716 806
717<p> 807<p>
718The last thing to check is that your new policies do a good job. An easy way to 808The last thing to check is that your new policies do a good job. An easy way to
719do so is monitoring CPU speed while working with your laptop: 809do so is monitoring CPU speed while working with your laptop:
722<pre caption="Monitoring CPU speed"> 812<pre caption="Monitoring CPU speed">
723# <i>watch grep \"cpu MHz\" /proc/cpuinfo</i> 813# <i>watch grep \"cpu MHz\" /proc/cpuinfo</i>
724</pre> 814</pre>
725 815
726<p> 816<p>
727If <path>/proc/cpuinfo</path> doesn't get updated (see Troubleshooting), 817If <path>/proc/cpuinfo</path> doesn't get updated (see <uri
728monitor the CPU frequency with: 818link="#doc_chap8">Troubleshooting</uri>), monitor the CPU frequency with
819<c>sys-apps/x86info</c>:
729</p> 820</p>
730 821
731<pre caption="Alternative CPU speed monitoring"> 822<pre caption="Alternative CPU speed monitoring">
732# <i>watch x86info -mhz</i> 823# <i>watch x86info -mhz</i>
733</pre> 824</pre>
734 825
735<p> 826<p>
736Depending on your setup, CPU speed should increase on heavy load, decrease on 827Depending on your setup, CPU speed should increase on heavy load, decrease on
737no activity or just stay at the same level. When using cpufreqd and verbosity 828no activity or just stay at the same level. When using <c>cpufreqd</c> and
738set to 5 or higher in <path>cpufreqd.conf</path> you'll get additional 829verbosity set to 5 or higher in <path>cpufreqd.conf</path> you'll get
739information about what's happening reported to syslog. 830additional information about what's happening reported to <c>syslog</c>.
740</p> 831</p>
741 832
742</body> 833</body>
743</section> 834</section>
744</chapter> 835</chapter>
745 836
746<chapter> 837<chapter>
747<title>LCD Power Management</title> 838<title>LCD Power Management</title>
748<section> 839<section>
749<title>Energy consumer no. 1</title>
750<body> 840<body>
751 841
752<p> 842<p>
753As you can see in <uri link="#doc_chap1_fig1">figure 1.1</uri>, the LCD display 843As you can see in <uri link="#doc_chap1_fig1">figure 1.1</uri>, the LCD
754consumes the biggest part of energy (might not be the case for non-mobile 844display consumes the biggest part of energy (might not be the case for
755CPU's). Thus it's quite important not only to shut the display off when not 845non-mobile CPU's). Thus it's quite important not only to shut the display off
756needed, but also to reduce it's backlight if possible. Most laptops offer the 846when not needed, but also to reduce it's backlight if possible. Most laptops
757possibility to control the backlight dimming. 847offer the possibility to control the backlight dimming.
758</p>
759
760<p> 848</p>
849
850</body>
851</section>
852<section>
853<title>Standby settings</title>
854<body>
855
856<p>
761First thing to check is the standby/suspend/off timings of the display. As this 857The first thing to check is the standby/suspend/off timings of the display. As
762depends heavily on your windowmanager, I'll let you figure it out yourself. 858this depends heavily on your windowmanager, I'll let you figure it out
763Just two common places: Blanking the terminal can be done with <c>setterm 859yourself. Just two common places: Blanking the terminal can be done with
764-blank &lt;number-of-minutesM&gt;</c>, <c>setterm -powersave on</c> and 860<c>setterm -blank &lt;number-of-minutesM&gt;</c>, <c>setterm -powersave on</c>
765<c>setterm -powerdown &lt;number-of-minutesM&gt;</c>. 861and <c>setterm -powerdown &lt;number-of-minutesM&gt;</c>. For X.org, modify
766For X.org, modify <path>/etc/X11/xorg.conf</path> similar to this: 862<path>/etc/X11/xorg.conf</path> similar to this:
767</p> 863</p>
768 864
769<pre caption="LCD suspend settings in X.org and XFree86"> 865<pre caption="LCD suspend settings in X.org">
770Section "ServerLayout" 866Section "ServerFlags"
771 Identifier [...]
772 [...]
773 Option "BlankTime" "5" <comment># Blank the screen after 5 minutes (Fake)</comment> 867 Option "blank time" "5" <comment># Blank the screen after 5 minutes (Fake)</comment>
774 Option "StandbyTime" "10" <comment># Turn off screen after 10 minutes (DPMS)</comment> 868 Option "standby time" "10" <comment># Turn off screen after 10 minutes (DPMS)</comment>
775 Option "SuspendTime" "20" <comment># Full suspend after 20 minutes</comment> 869 Option "suspend time" "20" <comment># Full suspend after 20 minutes</comment>
776 Option "OffTime" "30" <comment># Turn off after half an hour</comment> 870 Option "off time" "30" <comment># Turn off after half an hour</comment>
777 [...] 871 [...]
778EndSection 872EndSection
779 873
780[...] 874[...]
781 875
782Section "Monitor" 876Section "Monitor"
783 Identifier [...] 877 Identifier [...]
784 Option "DPMS" "true" 878 Option "DPMS"
785 [...] 879 [...]
786EndSection 880EndSection
787</pre> 881</pre>
788 882
789<p> 883</body>
790This is the same for XFree86 and <path>/etc/X11/XF86Config</path>. 884</section>
791</p> 885<section>
886<title>Backlight dimming</title>
887<body>
792 888
793<p> 889<p>
794Probably more important is the backlight dimming. If you have access to the 890Probably more important is the backlight dimming. If you have access to the
795dimming settings via a tool, write a small script that dims the backlight in 891dimming settings via a tool, write a small script that dims the backlight in
796battery mode and place it in your <e>battery</e> runlevel. The following script 892battery mode and place it in your <c>battery</c> runlevel. The following script
797should work on most IBM Thinkpads. It needs the <c>app-laptop/ibm-acpi</c> 893should work on most IBM Thinkpads and Toshiba laptops. You've got to enable the
798package or the appropriate option in your kernel has to be enabled. 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.
799</p> 897</p>
800 898
801<warn> 899<warn>
802Support for setting brightness is marked experimental in ibm-acpi. It accesses 900Support for setting brightness is marked experimental in thinkpad_acpi. It
803hardware directly and may cause severe harm to your system. Please read the 901accesses hardware directly and may cause severe harm to your system. Please
804<uri link="http://ibm-acpi.sourceforge.net/">ibm-acpi website</uri> 902read the <uri link="http://ibm-acpi.sourceforge.net/">thinkpad_acpi
903website</uri>
805</warn> 904</warn>
806 905
807<p> 906<p>
808To be able to set the brightness level, the ibm_acpi module has to be loaded 907To be able to set the brightness level, the thinkpad_acpi module has to be
809with the experimental parameter. 908loaded with the experimental parameter.
810</p> 909</p>
811 910
812<pre caption="automatically loading the ibm_acpi module"> 911<pre caption="Automatically loading the thinkpad_acpi module">
813<comment>(Please read the warnings above before doing this!)</comment> 912<comment>(Please read the warnings above before doing this!)</comment>
814<i># emerge ibm-acpi</i> 913
815<i># echo "options ibm_acpi experimental=1" >> /etc/modules.d/ibm_acpi</i> 914# <i>echo "options thinkpad_acpi experimental=1" >> /etc/modprobe.d/thinkpad_acpi</i>
816<i># /sbin/modules-update</i> 915# <i>update-modules</i>
817<i># echo ibm_acpi >> /etc/modules.autoload.d/kernel-2.6</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
818<i># modprobe ibm_acpi</i> 922# <i>modprobe thinkpad_acpi</i>
819</pre> 923</pre>
820 924
821<p> 925<p>
822This should work without error messages and a file 926This should work without error messages and a file
823<path>/proc/acpi/ibm/brightness</path> should be created after loading the 927<path>/proc/acpi/ibm/brightness</path> should be created after loading the
824module. An init script will take care of choosing the brightness according 928module. An init script will take care of choosing the brightness according to
825to the power source. 929the power source.
826</p> 930</p>
827 931
828<pre caption="/etc/conf.d/lcd-brightness"> 932<pre caption="/etc/conf.d/lcd-brightness">
829<comment># See /proc/acpi/ibm/brightness for available values</comment> 933<comment># See /proc/acpi/ibm/brightness for available values</comment>
830<comment># Please read /usr/share/doc/ibm-acpi-*/README.gz</comment> 934<comment># Please read /usr/src/linux/Documentation/thinkpad-acpi.txt</comment>
831 935
832<comment># brigthness level in ac mode. Default is 7.</comment> 936<comment># brightness level in ac mode. Default is 7.</comment>
833BRIGHTNESS_AC=7 937BRIGHTNESS_AC=7
834 938
835<comment># brightness level in battery mode. Default is 4.</comment> 939<comment># brightness level in battery mode. Default is 4.</comment>
836BRIGHTNESS_BATTERY=4 940BRIGHTNESS_BATTERY=4
837</pre> 941</pre>
850 if [ -f /proc/acpi/ibm/brightness ] 954 if [ -f /proc/acpi/ibm/brightness ]
851 then 955 then
852 ebegin "Setting LCD brightness" 956 ebegin "Setting LCD brightness"
853 echo "level ${LEVEL}" > /proc/acpi/ibm/brightness 957 echo "level ${LEVEL}" > /proc/acpi/ibm/brightness
854 eend $? 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 $?
855 else 964 else
856 ewarn "Setting LCD brightness is not supported." 965 ewarn "Setting LCD brightness is not supported."
857 ewarn "Check that ibm_acpi is loaded into the kernel" 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"
858 fi 968 fi
859} 969}
860 970
861start() { 971start() {
862 set_brightness 972 set_brightness
871When done, make sure brightness is adjusted automatically by adding it to the 981When done, make sure brightness is adjusted automatically by adding it to the
872battery runlevel. 982battery runlevel.
873</p> 983</p>
874 984
875<pre caption="Enabling automatic brightness adjustment"> 985<pre caption="Enabling automatic brightness adjustment">
876<i># chmod +x /etc/init.d/lcd-brightness</i> 986# <i>chmod +x /etc/init.d/lcd-brightness</i>
877<i># rc-update add lcd-brightness battery</i> 987# <i>rc-update add lcd-brightness battery</i>
878<i># rc</i> 988# <i>rc</i>
879</pre> 989</pre>
880 990
881</body> 991</body>
882</section> 992</section>
883</chapter> 993</chapter>
884 994
885<chapter> 995<chapter>
886<title>Disk Power Management</title> 996<title>Disk Power Management</title>
887<section> 997<section>
888<title>Sleep when idle</title> 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
889<body> 1012</body>
1013</section>
1014<section>
1015<title>Increasing idle time - laptop-mode</title>
1016<body>
890 1017
891<p>
892Let's bring the hard disk to sleep as early as possible whenever it is not
893needed. I'll show you two possibilities to do it. First <c>cpudyn</c> supports
894Disk Power Management. Uncomment the lines in the "Disk Options" section in
895<path>/etc/conf.d/cpudyn</path>. To put your first disk to sleep after 60
896seconds of no activity, you would modify it like this:
897</p> 1018<p>
898 1019Recent 2.6 kernels include the so-called <c>laptop-mode</c>. When activated,
899<pre caption="Using cpudyn for disk standby"> 1020dirty buffers are written to disk on read calls or after 10 minutes (instead of
900<comment>################################################ 102130 seconds). This minimizes the time the hard disk needs to be spun up.
901# DISK OPTIONS
902# (disabled by default)
903################################################
904
905#
906# Timeout to put the disk in standby mode if there was no
907# io during that period (in seconds)
908#
909</comment>
910TIMEOUT=60
911<comment>
912#
913# Specified disks to spindown (comma separated devices)
914#
915</comment>
916DISKS=/dev/hda
917</pre>
918
919<p> 1022</p>
920The second possibility is using a small script and hdparm. Create 1023
921<path>/etc/init.d/pm.hda</path> like this: 1024<pre caption="Automated start of laptop-mode">
1025# <i>emerge laptop-mode-tools</i>
1026</pre>
1027
922</p> 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>
923 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
924<pre caption="Using hdparm for disk standby"> 1117<pre caption="Using /etc/conf.d/hdparm for disk standby">
925#!/sbin/runscript 1118hda_args="-q -S12"
926
927depend() {
928 after hdparm
929}
930
931start() {
932 ebegin "Activating Power Management for Hard Drives"
933 hdparm -q -S12 /dev/hda
934 eend $?
935}
936
937stop () {
938 ebegin "Deactivating Power Management for Hard Drives"
939 hdparm -q -S253 /dev/hda
940 eend $?
941}
942</pre> 1119</pre>
943 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>.
944<p> 1125</p>
945See <c>man hdparm</c> for the options. If your script is ready, add it to the 1126
946battery runlevel. 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.
947</p> 1133</p>
948 1134
949<pre caption="Automate disk standby settings"> 1135<pre caption="Automate disk standby settings">
950# <i>chmod +x /etc/init.d/pm.hda</i>
951# <i>/sbin/depscan.sh</i>
952# <i>rc-update add pm.hda battery</i> 1136# <i>rc-update add hdparm battery</i>
953</pre> 1137</pre>
954 1138
955<impo> 1139<impo>
956Be careful with sleep/spin down settings of your hard drive. Setting it to 1140Be careful with sleep/spin down settings of your hard drive. Setting it to
957small values might wear out your drive and lose warranty. 1141small values might wear out your drive and lose warranty.
958</impo> 1142</impo>
959 1143
960</body> 1144</body>
961</section> 1145</section>
962<section> 1146<section>
963<title>Increasing idle time - laptop-mode</title>
964<body>
965
966<p>
967Recent kernels (2.6.6 and greater, recent 2.4 ones and others with patches)
968include the so-called <e>laptop-mode</e>. When activated, dirty buffers are
969written to disk on read calls or after 10 minutes (instead of 30 seconds). This
970minimizes the time the hard disk needs to be spun up.
971</p>
972
973<pre caption="Automated start of laptop-mode">
974# <i>emerge laptop-mode-tools</i>
975</pre>
976
977<p>
978<c>laptop-mode-tools</c> has it's configuration file in
979<path>/etc/laptop-mode/laptop-mode.conf</path>. Adjust it the way you like it,
980it's well commented. Run <c>rc-update add laptop_mode battery</c> to start it
981automatically.
982</p>
983
984</body>
985</section>
986<section>
987<title>Other tricks</title> 1147<title>Other tricks</title>
988<body> 1148<body>
989
990<p>
991Besides putting your disk to sleep state as early as possible, it is a good
992idea to minimize disk accesses. Have a look at processes that write to your
993disk frequently - the syslogd is a good candidate. You probably don't want to
994shut it down completely, but it's possible to modify the config file so that
995"unnecessary" things don't get logged and thus don't create disk traffic. Cups
996writes to disk periodically, so consider shutting it down and only enable it
997manually when needed.
998</p>
999
1000<pre caption="Disabling cups in battery mode">
1001# <i>rc-update del cupsd battery</i>
1002</pre>
1003 1149
1004<p> 1150<p>
1005Another possibility is to deactivate swap in battery mode. Before writing a 1151Another possibility is to deactivate swap in battery mode. Before writing a
1006swapon/swapoff switcher, make sure there is enough RAM and swap isn't used 1152swapon/swapoff switcher, make sure there is enough RAM and swap isn't used
1007heavily, otherwise you'll be in big problems. 1153heavily, otherwise you'll be in big problems.
1008</p> 1154</p>
1009 1155
1010<p> 1156<p>
1011If you don't want to use laptop-mode, it's still possible to minimize disk 1157If you don't want to use laptop-mode, it's still possible to minimize disk
1012access by mounting certain directories as <e>tmpfs</e> - write accesses are not 1158access by mounting certain directories as <c>tmpfs</c> - write accesses are not
1013stored on a disk, but in main memory and get lost with unmounting. Often it's 1159stored on a disk, but in main memory and get lost with unmounting. Often it's
1014useful to mount <path>/tmp</path> like this - you don't have to pay special 1160useful to mount <path>/tmp</path> like this - you don't have to pay special
1015attention as it gets cleared on every reboot regardless whether it was mounted 1161attention as it gets cleared on every reboot regardless whether it was mounted
1016on disk or in RAM. Just make sure you have enough RAM and no program (like a 1162on disk or in RAM. Just make sure you have enough RAM and no program (like a
1017download client or compress utility) needs extraordinary much space in 1163download client or compress utility) needs extraordinary much space in
1023none /tmp tmpfs size=32m 0 0 1169none /tmp tmpfs size=32m 0 0
1024</pre> 1170</pre>
1025 1171
1026<warn> 1172<warn>
1027Pay attention to the size parameter and modify it for your system. If you're 1173Pay attention to the size parameter and modify it for your system. If you're
1028unsure, don't try this at all, it can become a perfomance bottleneck easily. In 1174unsure, don't try this at all, it can become a performance bottleneck easily. In
1029case you want to mount <path>/var/log</path> like this, make sure to merge the 1175case you want to mount <path>/var/log</path> like this, make sure to merge the
1030log files to disk before unmounting. They are essential. Don't attempt to mount 1176log files to disk before unmounting. They are essential. Don't attempt to mount
1031/var/tmp like this. Portage uses it for compiling... 1177<path>/var/tmp</path> like this. Portage uses it for compiling...
1032</warn> 1178</warn>
1033 1179
1034</body> 1180</body>
1035</section> 1181</section>
1036</chapter> 1182</chapter>
1037 1183
1038<chapter> 1184<chapter>
1039<title>Power Management for other devices</title> 1185<title>Power Management For Other Devices</title>
1040<section> 1186<section>
1041<title>Graphics cards</title> 1187<title>Graphics Cards</title>
1042<body> 1188<body>
1043 1189
1044<p> 1190<p>
1045In case you own an ATI graphics card supporting PowerPlay (dynamic clock 1191In case you own an ATI graphics card supporting PowerPlay (dynamic clock
1046scaling for the the graphics processing unit GPU), you can activate this 1192scaling for the graphics processing unit GPU), you can activate this
1047feature in X.org. Open <path>/etc/X11/xorg.conf</path> and add (or enable) 1193feature in X.org. Open <path>/etc/X11/xorg.conf</path> and add (or enable) the
1048the <c>DynamicClocks</c> option in the Device section. Please notice that 1194<c>DynamicClocks</c> option in the Device section. Please notice that this
1049this feature will lead to crashes on some systems. 1195feature will lead to crashes on some systems.
1050</p> 1196</p>
1051 1197
1052<pre caption="Enabling ATI PowerPlay support in X.org"> 1198<pre caption="Enabling ATI PowerPlay support in X.org">
1053Section "Device" 1199Section "Device"
1054[...] 1200[...]
1061<section> 1207<section>
1062<title>Wireless Power Management</title> 1208<title>Wireless Power Management</title>
1063<body> 1209<body>
1064 1210
1065<p> 1211<p>
1066Wireless LAN cards consume quite a few energy. Put them in Power Management 1212Wireless LAN cards consume quite a bit of energy. Put them in Power Management
1067mode in analogy to the pm.hda script. 1213mode just like your hard drives.
1068</p>
1069
1070<pre caption="WLAN Power Management automated">
1071#!/sbin/runscript
1072start() {
1073 ebegin "Activating Power Management for Wireless LAN"
1074 iwconfig wlan0 power on power max period 3
1075 eend $?
1076}
1077
1078stop () {
1079 ebegin "Deactivating Power Management for Wireless LAN"
1080 iwconfig wlan0 power off
1081 eend $?
1082}
1083</pre>
1084
1085<p> 1214</p>
1086Starting this script will put wlan0 in Power Management mode, going to sleep at 1215
1087the latest three seconds after no traffic. 1216<note>
1088Save it as <path>/etc/init.d/pm.wlan0</path> and add it to the battery runlevel 1217This script assumes your wireless interface is called <c>wlan0</c>; replace
1089like the disk script above. See <c>man iwconfig</c> for details and more 1218this with the actual name of your interface.
1090options. If your driver and access point support changing the beacon time, this 1219</note>
1091is a good starting point to save even more energy. 1220
1092</p> 1221<p>
1093 1222Add the following option to <path>/etc/conf.d/net</path> to automatically enable
1094<pre caption="Power Management for WLAN"> 1223power management for your wireless card:
1095# <i>chmod +x /etc/init.d/pm.wlan0</i>
1096# <i>/sbin/depscan.sh</i>
1097# <i>rc-update add pm.wlan0 battery</i>
1098</pre> 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>
1099 1235
1100</body> 1236</body>
1101</section> 1237</section>
1102<section> 1238<section>
1103<title>USB Power Management</title> 1239<title>USB Power Management</title>
1107There are two problems with USB devices regarding energy consumption: First, 1243There are two problems with USB devices regarding energy consumption: First,
1108devices like USB mice, digital cameras or USB sticks consume energy while 1244devices like USB mice, digital cameras or USB sticks consume energy while
1109plugged in. You cannot avoid this (nevertheless remove them in case they're not 1245plugged in. You cannot avoid this (nevertheless remove them in case they're not
1110needed). Second, when there are USB devices plugged in, the USB host controller 1246needed). Second, when there are USB devices plugged in, the USB host controller
1111periodically accesses the bus which in turn prevents the CPU from going into 1247periodically accesses the bus which in turn prevents the CPU from going into
1112sleep mode. The kernel offers an experimental option to enable suspension of 1248sleep mode. The kernel offers an experimental option to enable suspension of
1113USB devices through driver calls or one of the <path>power/state</path> files 1249USB devices through driver calls or one of the <path>power/state</path> files
1114in <path>/sys</path>. 1250in <path>/sys</path>.
1115</p> 1251</p>
1116 1252
1117<pre caption="Enabling USB suspend support in the kernel"> 1253<pre caption="Enabling USB suspend support in the kernel">
1124</body> 1260</body>
1125</section> 1261</section>
1126</chapter> 1262</chapter>
1127 1263
1128<chapter> 1264<chapter>
1129<title>Sleep states: sleep, standby, suspend to disk</title> 1265<title>Sleep States: sleep, standby, and suspend to disk</title>
1130<section> 1266<section>
1131<title>Overview</title>
1132<body> 1267<body>
1133 1268
1134<p> 1269<p>
1135ACPI defines different sleep states. The more important ones are 1270ACPI defines different sleep states. The more important ones are
1136</p> 1271</p>
1137 1272
1138<ul> 1273<ul>
1139 <li>S1 aka Standby</li> 1274 <li>S1 aka Standby</li>
1140 <li>S3 aka Suspend to RAM aka Sleep</li> 1275 <li>S3 aka Suspend to RAM aka Sleep</li>
1141 <li>S4 aka Suspend to Disk aka Hibernate</li> 1276 <li>S4 aka Suspend to Disk aka Hibernate</li>
1142</ul> 1277</ul>
1143 1278
1159</p> 1294</p>
1160 1295
1161<pre caption="Kernel configuration for the various suspend types"> 1296<pre caption="Kernel configuration for the various suspend types">
1162 Power Management Options ---&gt; 1297 Power Management Options ---&gt;
1163 [*] Power Management support 1298 [*] Power Management support
1164 ACPI (Advanced Configuration and Power Interface) Support ---&gt; 1299 [*] Suspend to RAM and standby
1165 [*] ACPI Support
1166 [*] Sleep States
1167</pre> 1300</pre>
1168 1301
1169<p> 1302<p>
1170Once your kernel is prepared like above, you can use the 1303Once your kernel is properly configured, you can use the
1171<c>hibernate-script</c> to activate suspend or sleep mode. Let's install that 1304<c>hibernate-script</c> to activate suspend or sleep mode. Let's install that
1172first. 1305first.
1173</p> 1306</p>
1174 1307
1175<pre caption="Installing the hibernate-script"> 1308<pre caption="Installing the hibernate-script">
1176<i># emerge hibernate-script</i> 1309# <i>emerge hibernate-script</i>
1177</pre> 1310</pre>
1178 1311
1179<p> 1312<p>
1180Some configuration has to be done in <path>/etc/hibernate</path> The default 1313Some configuration has to be done in <path>/etc/hibernate</path>. The default
1181package introduces two configuration files <path>hibernate.conf</path> and 1314package introduces a few configuration files for each sleep state. Options that
1182<path>ram.conf</path>. 1315are common to all suspend methods are placed in <path>common.conf</path>; make
1183</p> 1316sure this file is properly set up for your system.
1184
1185<p> 1317</p>
1186To configure sleep, edit <path>ram.conf</path> in <path>/etc/hibernate</path>. 1318
1187<c>UseSysfsPowerState mem</c> is already setup correctly, but you have to go
1188through the rest of the configuration file and set it up for your system. The
1189comments and option names will guide you. If you use nfs or samba shares over
1190the network, make sure to shutdown the appropriate init scripts to avoid
1191timeouts.
1192</p> 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>
1193 1333
1194<p> 1334<p>
1195Ready? Now is the last chance to backup any data you want to keep after 1335Ready? Now is the last chance to backup any data you want to keep after
1196executing the next command. Notice that you probably have to hit a special key 1336executing the next command. Notice that you probably have to hit a special key
1197like <e>Fn</e> to resume from sleep. 1337like <c>Fn</c> to resume from sleep.
1198</p> 1338</p>
1199 1339
1200<pre caption="Calling sleep"> 1340<pre caption="Calling sleep">
1201<i># hibernate-ram</i> 1341# <i>hibernate-ram</i>
1202</pre> 1342</pre>
1203 1343
1204<p> 1344<p>
1205If you're still reading, it seems to work. You can also setup standby (S1) in 1345If you're still reading, it seems to work. You can also setup standby (S1) in a
1206a similar way by copying <path>ram.conf</path> to <path>standby.conf</path> 1346similar way by editing <path>sysfs-ram.conf</path> and changing
1207and creating a symlink <path>/usr/sbin/hibernate-standby</path> pointing to 1347"UseSysfsPowerState mem" to "UseSysfsPowerState standby". S3 and S4 are the more
1208<path>/usr/sbin/hibernate</path>. S3 and S4 are the more interesting sleep
1209states due to greater energy savings however. 1348interesting sleep states due to greater energy savings however.
1210</p> 1349</p>
1211 1350
1212</body> 1351</body>
1213</section> 1352</section>
1214<section> 1353<section>
1227Shutdown any NFS or samba server/client before hibernating. 1366Shutdown any NFS or samba server/client before hibernating.
1228</warn> 1367</warn>
1229 1368
1230<p> 1369<p>
1231There are two different implementations for S4. The original one is swsusp, 1370There are two different implementations for S4. The original one is swsusp,
1232then there is the newer suspend2 with a nicer interface (including 1371then there is the newer tuxonice (formerly suspend2) with a nicer interface
1233fbsplash support). A <uri link="http://suspend2.net/features.html#compare"> 1372(including fbsplash support). A <uri
1234feature comparison</uri> is available at the <uri link="http://suspend2.net"> 1373link="http://tuxonice.net/features.html#compare">feature comparison</uri> is
1235suspend2 Homepage</uri>. There used to be Suspend-to-Disk (pmdisk), a fork of 1374available at the <uri link="http://www.tuxonice.net">tuxonice homepage</uri>.
1236swsusp, but it has been merged back. 1375There used to be Suspend-to-Disk (pmdisk), a fork of swsusp, but it has been
1237</p> 1376merged back.
1238
1239<p> 1377</p>
1378
1379<p>
1240Suspend2 is not included in the mainline kernel yet, therefore you either have 1380TuxOnIce is not included in the mainline kernel yet, therefore you either have
1241to patch your kernel sources with the patches provided by 1381to patch your kernel sources with the patches provided by <uri
1242<uri link="http://suspend2.net">suspend2.net</uri> or use 1382link="http://www.tuxonice.net">tuxonice.net</uri> or use
1243<c>sys-kernel/suspend2-sources</c>. 1383<c>sys-kernel/tuxonice-sources</c>.
1244</p>
1245
1246<p> 1384</p>
1385
1386<p>
1247The kernel part for both swusp and suspend2 is as follows: 1387The kernel part for both swusp and TuxOnIce is as follows:
1248</p> 1388</p>
1249 1389
1250<pre caption="Kernel configuration for the various suspend types"> 1390<pre caption="Kernel configuration for the various suspend types">
1251Power Management Options ---&gt; 1391Power Management support ---&gt;
1252 <comment>(hibernate with swsusp)</comment> 1392 <comment>(hibernate with swsusp)</comment>
1253 [*] Software Suspend 1393 [*] Hibernation (aka 'suspend to disk')
1254 <comment>(replace /dev/SWAP with your swap partition)</comment> 1394 <comment>(replace /dev/SWAP with your swap partition)</comment>
1255 (/dev/SWAP) Default resume partition 1395 (/dev/SWAP) Default resume partition
1256 1396
1257 <comment>(hibernate with suspend2)</comment> 1397 <comment>(hibernate with TuxOnIce)</comment>
1258 Software Suspend 2 1398 Enhanced Hibernation (TuxOnIce)
1259 --- Image Storage (you need at least one writer) 1399 --- Image Storage (you need at least one allocator)
1260 [*] File Writer 1400 [*] File Allocator
1261 [*] Swap Writer 1401 [*] Swap Allocator
1262 --- General Options 1402 --- General Options
1263 [*] LZF image compression 1403 [*] Compression support
1264 <comment>(replace /dev/SWAP with your swap partition)</comment>
1265 (swap:/dev/SWAP) Default resume device name
1266 [ ] Allow Keep Image Mode 1404 [ ] Allow Keep Image Mode
1405 [*] Replace swsusp by default
1267</pre> 1406</pre>
1268 1407
1269<p> 1408<p>
1270The configuration for swsusp is rather easy. If you didn't store the location 1409The configuration for swsusp is rather easy. If you didn't store the location
1271of your swap partition in the kernel config, you can also pass it as a 1410of your swap partition in the kernel config, you can also pass it as a
1272parameter with the <c>resume=/dev/SWAP</c> directive. If booting is not 1411parameter with the <c>resume=/dev/SWAP</c> directive. If booting is not
1273possible due to a broken image, use the <c>noresume</c> kernel parameter. The 1412possible due to a broken image, use the <c>noresume</c> kernel parameter. The
1274<c>hibernate-cleanup</c> init script invalidates swsusp images during the 1413<c>hibernate-cleanup</c> init script invalidates swsusp images during the boot
1275boot process. 1414process.
1276</p> 1415</p>
1277 1416
1278<pre caption="Invalidating swsusp images during the boot process"> 1417<pre caption="Invalidating swsusp images during the boot process">
1279<i># rc-update add hibernate-cleanup boot</i> 1418# <i>rc-update add hibernate-cleanup boot</i>
1280</pre> 1419</pre>
1281 1420
1282<p> 1421<p>
1283To activate hibernate with swsusp, use the hibernate script and set 1422To activate hibernate with swsusp, use the hibernate script and set
1284<c>UseSysfsPowerState disk</c> in <path>/etc/hibernate/hibernate.conf</path>. 1423<c>UseSysfsPowerState disk</c> in <path>/etc/hibernate/sysfs-disk</path>.
1285</p> 1424</p>
1286 1425
1287<warn> 1426<warn>
1288Backup your data before doing this. Run <c>sync</c> before executing one of the 1427Backup your data before doing this. Run <c>sync</c> before executing one of the
1289commands to have cached data written to disk. First try it outside of X, then 1428commands to have cached data written to disk. First try it outside of X, then
1290with X running, but not logged in. 1429with X running, but not logged in.
1291</warn> 1430</warn>
1292 1431
1293<p> 1432<p>
1294If you experience kernel panics due to uhci or similar, try to compile USB 1433If you experience kernel panics due to uhci or similar, try to compile USB
1295support as module and unload the modules before sending your laptop to sleep 1434support as module and unload the modules before sending your laptop to sleep
1296mode. There are configuration options for this in <path>hibernate.conf</path> 1435mode. There are configuration options for this in <path>common.conf</path>
1297</p> 1436</p>
1298 1437
1299<pre caption="Hibernating with swsusp"> 1438<pre caption="Hibernating with swsusp">
1300<i># nano -w /etc/hibernate.conf</i> 1439# <i>nano -w /etc/hibernate/common.conf</i>
1301<comment>(Make sure you have a backup of your data)</comment> 1440<comment>(Make sure you have a backup of your data)</comment>
1302<i># hibernate</i> 1441# <i>hibernate</i>
1303</pre> 1442</pre>
1304 1443
1305<p> 1444<p>
1306The following section discusses the setup of suspend2 including fbsplash 1445The following section discusses the setup of TuxOnIce including fbsplash support
1307support for a nice graphical progress bar during suspend and resume. 1446for a nice graphical progress bar during suspend and resume.
1308</p>
1309
1310<p> 1447</p>
1448
1449<p>
1311The first part of the configuration is similar to the configuration of 1450The first part of the configuration is similar to the configuration of swsusp.
1312swsusp. In case you didn't store the location of your swap partition in the 1451In case you didn't store the location of your swap partition in the kernel
1313kernel config, you have to pass it as a kernel parameter with the 1452config, you have to pass it as a kernel parameter with the
1314<c>resume2=swap:/dev/SWAP</c> directive. If booting is not possible due to a 1453<c>resume=swap:/dev/SWAP</c> directive. If booting is not possible due to a
1315broken image, append the <c>noresume2</c> parameter. Additionally, the 1454broken image, append the <c>noresume</c> parameter. Additionally, the
1316<c>hibernate-cleanup</c> init script invalidates suspend2 images during the 1455<c>hibernate-cleanup</c> init script invalidates TuxOnIce images during the boot
1317boot process. 1456process.
1318</p> 1457</p>
1319 1458
1320<pre caption="Invalidating suspend2 images during the boot process"> 1459<pre caption="Invalidating TuxOnIce images during the boot process">
1321<i># rc-update add hibernate-cleanup boot</i> 1460# <i>rc-update add hibernate-cleanup boot</i>
1322</pre> 1461</pre>
1323 1462
1324<p>Now edit <path>/etc/hibernate/hibernate.conf</path>, enable the
1325<e>suspend2</e> section and comment everything in the <e>sysfs_power_state</e>
1326and <e>acpi_sleep</e> sections. Do not enable the fbsplash part in global
1327options yet.
1328</p> 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>
1329 1468
1330<pre caption="Hibernating with suspend2"> 1469<pre caption="Hibernating with TuxOnIce">
1331<i># nano -w /etc/hibernate.conf</i> 1470# <i>nano -w /etc/hibernate/tuxonice.conf</i>
1332<comment>(Make sure you have a backup of your data)</comment> 1471<comment>(Make sure you have a backup of your data)</comment>
1333<i># hibernate</i> 1472# <i>hibernate</i>
1334</pre> 1473</pre>
1335 1474
1336<p> 1475<p>
1337Please configure fbsplash now if you didn't do already. To enable fbsplash 1476Please configure <c>fbsplash</c> now if you didn't do already. To enable
1338support during hibernation, the <c>sys-apps/suspend2-userui</c> package is 1477fbsplash support during hibernation, the <c>sys-apps/tuxonice-userui</c> package
1339needed. Additionally, you've got to enable the <e>fbsplash</e> USE flag. 1478is needed. Additionally, you've got to enable the <c>fbsplash</c> USE flag.
1340</p> 1479</p>
1341 1480
1342<pre caption="Installing suspend2-userui"> 1481<pre caption="Installing tuxonice-userui">
1343<i># mkdir -p /etc/portage</i>
1344<i># echo sys-apps/suspend2-userui fbsplash >> /etc/portage/package.use</i> 1482# <i>echo "sys-apps/tuxonice-userui fbsplash" >> /etc/portage/package.use</i>
1345<i># emerge suspend2-userui</i> 1483# <i>emerge tuxonice-userui</i>
1346</pre> 1484</pre>
1347 1485
1348<p> 1486<p>
1349The ebuild tells you to make a symlink to the theme you want to use. For 1487The ebuild tells you to make a symlink to the theme you want to use. For
1350example, to use the <c>livecd-2005.1</c> theme, run the following command: 1488example, to use the <c>livecd-2005.1</c> theme, run the following command:
1351</p> 1489</p>
1352 1490
1353<pre caption="Using the livecd-2005.1 theme during hibernation"> 1491<pre caption="Using the livecd-2005.1 theme during hibernation">
1354<i># ln -sfn /etc/splash/livecd-2005.1 /etc/splash/suspend2</i> 1492# <i>ln -sfn /etc/splash/livecd-2005.1 /etc/splash/tuxonice</i>
1355</pre> 1493</pre>
1356 1494
1357<p> 1495<p>
1358If you don't want a black screen in the first part of the resume process, you 1496If you don't want a black screen in the first part of the resume process, you
1359have to add the <c>suspend2ui_fbsplash</c> tool to your initrd image. Assuming 1497have to add the <c>tuxoniceui_fbsplash</c> tool to your initrd image. Assuming
1360you created the initrd image with <c>splash_geninitramfs</c> and saved it as 1498you created the initrd image with <c>splash_geninitramfs</c> and saved it as
1361<path>/boot/fbsplash-emergence-1024x768</path>, here's how to do 1499<path>/boot/fbsplash-emergence-1024x768</path>, here's how to do that.
1362that.
1363</p> 1500</p>
1364 1501
1365<pre caption="Adding suspend2ui_fbsplash to an initrd image"> 1502<pre caption="Adding tuxoniceui_fbsplash to an initrd image">
1366<i># mount /boot</i> 1503# <i>mount /boot</i>
1367<i># mkdir ~/initrd.d</i> 1504# <i>mkdir ~/initrd.d</i>
1368<i># cp /boot/fbsplash-emergence-1024x768 ~/initrd.d/</i> 1505# <i>cp /boot/fbsplash-emergence-1024x768 ~/initrd.d/</i>
1369<i># cd ~/initrd.d</i> 1506# <i>cd ~/initrd.d</i>
1370<i># gunzip -c fbsplash-emergence-1024x768 | cpio -idm --quiet -H newc</i> 1507# <i>gunzip -c fbsplash-emergence-1024x768 | cpio -idm --quiet -H newc</i>
1371<i># rm fbsplash-emergence-1024x768</i> 1508# <i>rm fbsplash-emergence-1024x768</i>
1372<i># cp /usr/sbin/suspend2ui_fbsplash sbin/</i> 1509# <i>cp /usr/sbin/tuxoniceui_fbsplash sbin/</i>
1373<i># find . | cpio --quiet --dereference -o -H newc | gzip -9 > /boot/fbsplash-suspend2-emergence-1024x768</i> 1510# <i>find . | cpio --quiet --dereference -o -H newc | gzip -9 > /boot/fbsplash-tuxonice-emergence-1024x768</i>
1374</pre> 1511</pre>
1375 1512
1376<p> 1513<p>
1377Afterwards adjust <path>grub.conf</path> respectively <path>lilo.conf</path> 1514Afterwards adjust <path>grub.conf</path> (or <path>lilo.conf</path>) so that
1378so that your suspend2 kernel uses 1515your TuxOnIce kernel uses
1379<path>/boot/fbsplash-suspend2-emergence-1024x768</path> as initrd image. You 1516<path>/boot/fbsplash-tuxonice-emergence-1024x768</path> as initrd image. You can
1380can now test a dry run to see if everything is setup correctly. 1517now test a dry run to see if everything is setup correctly.
1381</p> 1518</p>
1382 1519
1383<pre caption="Test run for fbsplash hibernation"> 1520<pre caption="Test run for fbsplash hibernation">
1384<i># suspend2ui_fbsplash -t</i> 1521# <i>tuxoniceui_fbsplash -t</i>
1385</pre> 1522</pre>
1386 1523
1387<p> 1524<p>
1388Afterwards open <path>/etc/hibernate/hibernate.conf</path> again and activate 1525Afterwards open <path>/etc/hibernate/common.conf</path> and activate the
1389the fbsplash options. Execute <c>hibernate</c> and enjoy. 1526fbsplash options. Execute <c>hibernate</c> and enjoy.
1390</p> 1527</p>
1391 1528
1392</body> 1529</body>
1393</section> 1530</section>
1394</chapter> 1531</chapter>
1395 1532
1396<chapter> 1533<chapter>
1397<title>Troubleshooting</title> 1534<title>Troubleshooting</title>
1398<section> 1535<section>
1399<title>If things go wrong...</title>
1400<body> 1536<body>
1401 1537
1402<p> 1538<p>
1403<e>Q:</e> I'm trying to change the CPU frequency, but 1539<e>Q:</e> I'm trying to change the CPU frequency, but
1404<path>/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor</path> does not 1540<path>/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor</path> does not
1406</p> 1542</p>
1407 1543
1408<p> 1544<p>
1409<e>A:</e> Make sure your processor supports CPU frequency scaling and you chose 1545<e>A:</e> Make sure your processor supports CPU frequency scaling and you chose
1410the right CPUFreq driver for your processor. Here is a list of processors that 1546the right CPUFreq driver for your processor. Here is a list of processors that
1411are supported by cpufreq (kernel 2.6.7): ARM Integrator, ARM-SA1100, 1547are supported by cpufreq (kernel 2.6.7): ARM Integrator, ARM-SA1100, ARM-SA1110,
1412ARM-SA1110, AMD Elan - SC400, SC410, AMD mobile K6-2+, AMD mobile K6-3+, AMD 1548AMD Elan - SC400, SC410, AMD mobile K6-2+, AMD mobile K6-3+, AMD mobile Duron,
1413mobile Duron, AMD mobile Athlon, AMD Opteron, AMD Athlon 64, Cyrix Media GXm, 1549AMD mobile Athlon, AMD Opteron, AMD Athlon 64, Cyrix Media GXm, Intel mobile
1414Intel mobile PIII and Intel mobile PIII-M on certain chipsets, Intel Pentium 4, 1550PIII and Intel mobile PIII-M on certain chipsets, Intel Pentium 4, Intel Xeon,
1415Intel Xeon, Intel Pentium M (Centrino), National Semiconductors Geode GX, 1551Intel Pentium M (Centrino), National Semiconductors Geode GX, Transmeta Crusoe,
1416Transmeta Crusoe, VIA Cyrix 3 / C3, UltraSPARC-III, SuperH SH-3, SH-4, several 1552VIA Cyrix 3 / C3, UltraSPARC-III, SuperH SH-3, SH-4, several "PowerBook" and
1417"PowerBook" and "iBook2" and various processors on some ACPI 2.0-compatible 1553"iBook2" and various processors on some ACPI 2.0-compatible systems (only if
1418systems (only if "ACPI Processor Performance States" are available to the 1554"ACPI Processor Performance States" are available to the ACPI/BIOS interface).
1419ACPI/BIOS interface).
1420</p> 1555</p>
1421 1556
1422<p> 1557<p>
1423<e>Q:</e> My laptop supports frequency scaling, but 1558<e>Q:</e> My laptop supports frequency scaling, but
1424<path>/sys/devices/system/cpu/cpu0/cpufreq/</path> is empty. 1559<path>/sys/devices/system/cpu/cpu0/cpufreq/</path> is empty.
1429Try to update the BIOS, especially if a broken DSDT is reported. You can also 1564Try to update the BIOS, especially if a broken DSDT is reported. You can also
1430try to fix it yourself (which is beyond the scope of this guide). 1565try to fix it yourself (which is beyond the scope of this guide).
1431</p> 1566</p>
1432 1567
1433<p> 1568<p>
1434<e>Q:</e> My laptop supports frequency scaling, but according to /proc/cpuinfo 1569<e>Q:</e> My laptop supports frequency scaling, but according to
1435the speed never changes. 1570<path>/proc/cpuinfo</path> the speed never changes.
1436</p> 1571</p>
1437 1572
1438<p> 1573<p>
1439<e>A:</e> Probably you have activated symmetric multiprocessing support 1574<e>A:</e> Probably you have activated symmetric multiprocessing support
1440(CONFIG_SMP) in your kernel. Deactivate it and it should work. Some older 1575(CONFIG_SMP) in your kernel. Deactivate it and it should work. Some older
1441kernels had a bug causing this. In that case, run <c>emerge x86info</c>, 1576kernels had a bug causing this. In that case, run <c>emerge x86info</c>, update
1442update your kernel as asked and check the current frequency with 1577your kernel as asked and check the current frequency with <c>x86info -mhz</c>.
1443<c>x86info -mhz</c>.
1444</p> 1578</p>
1445 1579
1446<p> 1580<p>
1447<e>Q:</e> I can change the CPU frequency, but the range is not as wide as in 1581<e>Q:</e> I can change the CPU frequency, but the range is not as wide as in
1448another OS. 1582another OS.
1449</p> 1583</p>
1450 1584
1451<p> 1585<p>
1452<e>A:</e> You can combine frequency scaling with ACPI throttling to get a lower 1586<e>A:</e> You can combine frequency scaling with ACPI throttling to get a lower
1453minimum frequency. Notice that throttling doesn't save much energy and is 1587minimum frequency. Notice that throttling doesn't save much energy and is mainly
1454mainly used for thermal management (keeping your laptop cool and quiet). You 1588used for thermal management (keeping your laptop cool and quiet). You can read
1455can read the current throttling state with <c>cat 1589the current throttling state with <c>cat /proc/acpi/processor/CPU/throttling</c>
1456/proc/acpi/processor/CPU/throttling</c> and change it with <c>echo -n "0:x" > 1590and change it with <c>echo -n "0:x" > /proc/acpi/processor/CPU/limit</c>, where
1457/proc/acpi/processor/CPU/limit</c>, where x is one of the Tx states listed in 1591x is one of the Tx states listed in
1458<path>/proc/acpi/processor/CPU/throttling</path>. 1592<path>/proc/acpi/processor/CPU/throttling</path>.
1459</p> 1593</p>
1460 1594
1461<p> 1595<p>
1462<e>Q:</e> When configuring the kernel, powersave, performance and userspace 1596<e>Q:</e> When configuring the kernel, powersave, performance and userspace
1486<e>A:</e> Check that battery support is compiled into your kernel. If you use 1620<e>A:</e> Check that battery support is compiled into your kernel. If you use
1487it as a module, make sure the module is loaded. 1621it as a module, make sure the module is loaded.
1488</p> 1622</p>
1489 1623
1490<p> 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>
1491<e>Q:</e> I have a Dell Inspiron 51XX and I don't get any ACPI events. 1641<e>Q:</e> I have a Dell Inspiron 51XX and I don't get any ACPI events.
1492</p> 1642</p>
1493 1643
1494<p> 1644<p>
1495<e>A:</e> This seems to be a kernel bug. Read on <uri 1645<e>A:</e> This seems to be a kernel bug. Read on <uri
1496link="http://bugme.osdl.org/show_bug.cgi?id=1752">here</uri>. 1646link="http://bugme.osdl.org/show_bug.cgi?id=1752">here</uri>.
1497</p> 1647</p>
1498 1648
1499<p> 1649<p>
1500<e>Q:</e> I activated the DynamicClocks option in <path>xorg.conf</path> and 1650<e>Q:</e> I activated the <c>DynamicClocks</c> option in <path>xorg.conf</path>
1501now X.org crashes / the screen stays black / my laptop doesn't shutdown 1651and now X.org crashes / the screen stays black / my laptop doesn't shutdown
1502properly. 1652properly.
1503</p> 1653</p>
1504 1654
1505<p> 1655<p>
1506<e>A:</e> This happens on some systems. You have to disable DynamicClocks. 1656<e>A:</e> This happens on some systems. You have to disable
1507</p> 1657<c>DynamicClocks</c>.
1508
1509<p> 1658</p>
1659
1660<p>
1510<e>Q:</e> I want to use suspend2, but it tells me my swap partition is too 1661<e>Q:</e> I want to use TuxOnIce, but it tells me my swap partition is too
1511small. Resizing is not an option. 1662small. Resizing is not an option.
1512</p> 1663</p>
1513 1664
1514<p> 1665<p>
1515<e>A:</e> If there is enough free space on your system, you can use the 1666<e>A:</e> If there is enough free space on your system, you can use the
1516filewriter instead of the swapwriter. The <c>hibernate-script</c> supports it 1667filewriter instead of the swapwriter. The <c>hibernate-script</c> supports it as
1517as well. More information can be found in 1668well. More information can be found in
1518<path>/usr/src/linux/Documentation/power/suspend2.txt</path>. 1669<path>/usr/src/linux/Documentation/power/tuxonice.txt</path>.
1519</p> 1670</p>
1520 1671
1521<p> 1672<p>
1522<e>Q:</e> I just bought a brand new battery, but it only lasts for some 1673<e>Q:</e> I just bought a brand new battery, but it only lasts for some
1523minutes! What am I doing wrong? 1674minutes! What am I doing wrong?
1524</p> 1675</p>
1525 1676
1526<p> 1677<p>
1527<e>A:</e> First follow your manufacturer's advice on how to charge the battery 1678<e>A:</e> First follow your manufacturer's advice on how to charge the battery
1528correctly. 1679correctly.
1529</p> 1680</p>
1530 1681
1531<p> 1682<p>
1532<e>Q:</e> The above didn't help. What should I do then? 1683<e>Q:</e> The above didn't help. What should I do then?
1533</p> 1684</p>
1550<p> 1701<p>
1551<e>Q:</e> My problem is not listed above. Where should I go next? 1702<e>Q:</e> My problem is not listed above. Where should I go next?
1552</p> 1703</p>
1553 1704
1554<p> 1705<p>
1555<e>A:</e> Don't fear to contact me, <mail link="fragfred@gmx.de">Dennis 1706<e>A:</e> Don't fear to contact me, <mail link="earthwings@gentoo.org">Dennis
1556Nienhüser</mail>, directly. 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>.
1557</p> 1710</p>
1558 1711
1559</body> 1712</body>
1560</section> 1713</section>
1561</chapter> 1714</chapter>

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

  ViewVC Help
Powered by ViewVC 1.1.20