/[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.39 - (show annotations) (download) (as text)
Thu May 14 15:01:19 2009 UTC (5 years, 7 months ago) by nightmorph
Branch: MAIN
Changes since 1.38: +20 -23 lines
File MIME type: application/xml
Updated kernel info for bug 269808, thanks to fauli@g.o for the patch

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

  ViewVC Help
Powered by ViewVC 1.1.20