/[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.19 - (show annotations) (download) (as text)
Thu Jul 27 08:13:32 2006 UTC (8 years ago) by rane
Branch: MAIN
Changes since 1.18: +133 -132 lines
File MIME type: application/xml
#123776, fixed the coding style a lot

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

  ViewVC Help
Powered by ViewVC 1.1.20