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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.35 - (show annotations) (download) (as text)
Thu Jan 31 23:38:05 2008 UTC (6 years, 7 months ago) by nightmorph
Branch: MAIN
Changes since 1.34: +21 -27 lines
File MIME type: application/xml
bring it a little more up to date. punt outdated Xfree86 references. ibm_acpi is now known as thinkpad_acpi. for xorg.conf, DPMS is no longer a boolean variable, and screen blank settings have been moved to a different section.

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

  ViewVC Help
Powered by ViewVC 1.1.20