/[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.47 - (show annotations) (download) (as text)
Wed Aug 17 07:10:12 2011 UTC (2 years, 11 months ago) by swift
Branch: MAIN
Changes since 1.46: +18 -10 lines
File MIME type: application/xml
Bug #367145 - Update powermanagement guide to reflect OpenRC changes

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.46 2011/03/28 10:26:10 nightmorph Exp $ -->
4
5 <guide>
6 <title>Power Management Guide</title>
7
8 <author title="Author">
9 <mail link="earthwings@gentoo.org">Dennis Nienhüser</mail>
10 </author>
11 <author title="Editor">
12 <mail link="chriswhite@gentoo.org">Chris White</mail>
13 </author>
14 <author title="Editor">
15 <mail link="nightmorph"/>
16 </author>
17
18 <abstract>
19 Power Management is the key to extend battery run time on mobile systems like
20 laptops. This guide assists you setting it up on your laptop.
21 </abstract>
22
23 <!-- The content of this document is licensed under the CC-BY-SA license -->
24 <!-- See http://creativecommons.org/licenses/by-sa/2.5 -->
25 <license/>
26
27 <version>3</version>
28 <date>2011-08-17</date>
29
30 <chapter>
31 <title>Introduction</title>
32 <section>
33 <body>
34
35 <p>
36 Capacity and lifetime of laptop batteries have improved much in the last years.
37 Nevertheless modern processors consume much more energy than older ones and
38 each laptop generation introduces more devices hungry for energy. That's why
39 Power Management is more important than ever. Increasing battery run time
40 doesn't necessarily mean buying another battery. Much can be achieved applying
41 intelligent Power Management policies.
42 </p>
43
44 </body>
45 </section>
46 <section>
47 <title>A Quick Overview</title>
48 <body>
49
50 <p>
51 Please notice that this guide describes Power Management for <e>laptops</e>.
52 While some sections might also suite for <e>servers</e>, others do not and may
53 even cause harm. Please do not apply anything from this guide to a server
54 unless you really know what you are doing.
55 </p>
56
57 <p>
58 As this guide has become rather long, here's a short overview helping you to
59 find your way through it.
60 </p>
61
62 <p>
63 The <uri link="#doc_chap2">Prerequisites</uri> chapter talks about some
64 requirements that should be met before any of the following device individual
65 sections will work. This includes BIOS settings, kernel configuration and some
66 simplifications in user land. The following three chapters focus on devices
67 that typically consume most energy - processor, display and hard drive. Each
68 can be configured separately. <uri link="#doc_chap3">CPU Power Management</uri>
69 shows how to adjust the processor's frequency to save a maximum of energy
70 without losing too much performance. A few different tricks prevent your hard
71 drive from working unnecessarily often in <uri link="#doc_chap5">Disk Power
72 Management</uri> (decreasing noise level as a nice side effect). Some notes on
73 graphics cards, Wireless LAN and USB finish the device section in <uri
74 link="#doc_chap6">Power Management For Other Devices</uri> while another
75 chapter is dedicated to the (rather experimental) <uri link="#doc_chap7">sleep
76 states</uri>. Last not least <uri link="#doc_chap8">Troubleshooting</uri> lists
77 common pitfalls.
78 </p>
79
80 </body>
81 </section>
82 <section>
83 <title>Power Budget For Each Component</title>
84 <body>
85
86 <figure link="/images/energy-budget.png" short="Which component consumes how
87 much energy?" caption="Power budget for each component"/>
88
89 <p>
90 Nearly every component can operate in different states - off, sleep, idle,
91 active to name a few - consuming a different amount of energy. Major parts are
92 consumed by the LCD display, CPU, chipset and hard drives. Often one is able to
93 activate OS-independent Power Management in the BIOS, but an intelligent setup
94 in the operating system adapting to different situations can achieve much more.
95 </p>
96
97 </body>
98 </section>
99 </chapter>
100
101 <chapter>
102 <title>Prerequisites</title>
103 <section>
104 <body>
105
106 <p>
107 Before discussing the details of making individual devices Power Management
108 aware, make sure certain requirements are met. After controlling BIOS settings,
109 some kernel options want to be enabled - these are in short ACPI, sleep states
110 and CPU frequency scaling. As power saving most of the time comes along with
111 performance loss or increased latency, it should only be enabled when running
112 on batteries. That's where a new runlevel <e>battery</e> comes in handy.
113 </p>
114
115 </body>
116 </section>
117 <section>
118 <title>The BIOS Part</title>
119 <body>
120
121 <p>
122 First have a look into your BIOS Power Management settings. The best way is to
123 combine BIOS and operating system policies, but for the moment it's better to
124 disable most of the BIOS part. This makes sure it doesn't interfere with your
125 policies. Don't forget to re-check BIOS settings after you configured
126 everything else.
127 </p>
128
129 </body>
130 </section>
131 <section>
132 <title>Setting USE Flags</title>
133 <body>
134
135 <p>
136 Please check that the <c>acpi</c> USE flag is set in
137 <path>/etc/make.conf</path>. Other USE flags that might be interesting for your
138 system are <c>apm</c>, <c>lm_sensors</c>, <c>nforce2</c>, <c>nvidia</c>,
139 <c>pmu</c>. See <path>/usr/portage/profiles/use*.desc</path> for details. If
140 you forgot to set one of these flags, you can recompile affected packages using
141 the <c>--newuse</c> flag in <c>emerge</c>, see <c>man emerge</c>.
142 </p>
143
144 </body>
145 </section>
146 <section>
147 <title>Configuring The Kernel</title>
148 <body>
149
150 <p>
151 ACPI (Advanced Configuration and Power Interface) support in the kernel is
152 still work in progress. Using a recent kernel will make sure you'll get the
153 most out of it.
154 </p>
155
156 <p>
157 There are different kernel sources in Portage. I'd recommend using
158 <c>gentoo-sources</c> or <c>tuxonice-sources</c>. The latter contains patches
159 for TuxOnIce, see the chapter about <uri link="#doc_chap7">sleep states</uri>
160 for more details. When configuring the kernel, activate at least these options:
161 </p>
162
163 <pre caption="Minimum kernel setup for Power Management (Kernel 2.6)">
164 Power management and ACPI options ---&gt;
165 [*] Power Management support
166 [ ] Software Suspend
167
168 ACPI( Advanced Configuration and Power Interface ) Support ---&gt;
169 [ ] Deprecated /proc/acpi/ files
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.
209 As 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
218 get the acpi daemon. This one informs you about events like switching from AC
219 to 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 <c>/etc/init.d/acpid
221 start</c>. Run <c>rc-update add acpid default</c> to load it on startup. You'll
222 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/pm-utils</c> - make sure the
277 package is installed on your system.
278 </p>
279
280 <pre caption="Installing pm-utils">
281 # <i>emerge pm-utils</i>
282 </pre>
283
284 <p>
285 You are now able to determine the power source by executing <c>on_ac_power
286 &amp;&amp; echo AC available || echo Running on batteries</c> in a shell. The
287 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/messages | grep "ACPI event"</i>
338 </pre>
339
340 <p>
341 Run the command above and pull the power cable. You should see something like
342 this:
343 </p>
344
345 <pre caption="Sample output for power source changes">
346 [Tue Sep 20 17:39:06 2005] ACPI event "ac_adapter AC 00000080 00000000"
347 [Tue Sep 20 17:39:06 2005] ACPI event "battery BAT0 00000080 00000001"
348 </pre>
349
350 <p>
351 The interesting part is the quoted string after <c>ACPI 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 <uri
382 link="#doc_chap8">Troubleshooting section</uri> if the script is not able to
383 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 runlevel change is
394 necessary. Create a <path>/etc/local.d/battery.start</path> file with the
395 following contents:
396 </p>
397
398 <pre caption="Runlevel adjustment at boot time through local.d/battery.start">
399 #!/bin/sh
400 <comment># Fake acpi event to switch runlevel if running on batteries</comment>
401 /etc/acpi/actions/pmg_switch_runlevel.sh "battery/battery"
402 </pre>
403
404 <p>
405 Don't forget to mark the file as executable (<c>chmod +x
406 /etc/local.d/battery.start</c>). Prepared like this you can activate Power
407 Management policies for individual devices.
408 </p>
409
410 </body>
411 </section>
412 </chapter>
413
414 <chapter>
415 <title>CPU Power Management</title>
416 <section>
417 <body>
418
419 <p>
420 Mobile processors can operate at different frequencies. Some allow changing
421 voltage as well. Most of the time your CPU doesn't need to run at full speed
422 and scaling it down will save much energy - often without any performance
423 decrease.
424 </p>
425
426 </body>
427 </section>
428 <section>
429 <title>Some Technical Terms</title>
430 <body>
431
432 <p>
433 CPU frequency scaling brings up some technical terms that might be unknown to
434 you. Here's a quick introduction.
435 </p>
436
437 <p>
438 First of all, the kernel has to be able to change the processor's frequency.
439 The <b>CPUfreq processor driver</b> knows the commands to do it on your CPU.
440 Thus it's important to choose the right one in your kernel. You should already
441 have done it above. Once the kernel knows how to change frequencies, it has to
442 know which frequency it should set. This is done according to the <b>policy</b>
443 which consists of a <b>CPUfreq policy</b> and a <b>governor</b>. A CPUfreq
444 policy are just two numbers which define a range the frequency has to stay
445 between - minimal and maximal frequency. The governor now decides which of the
446 available frequencies in between minimal and maximal frequency to choose. For
447 example, the <b>powersave governor</b> always chooses the lowest frequency
448 available, the <b>performance governor</b> the highest one. The <b>userspace
449 governor</b> makes no decision but chooses whatever the user (or a program in
450 userspace) wants - which means 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, the
457 <b>ondemand governor</b> makes its decisions depending on the current CPU load.
458 The same is done by various userland tools like <c>cpudyn</c>, <c>cpufreqd</c>,
459 <c>powernowd</c> and many more. ACPI events can be used to enable or disable
460 dynamic frequency changes depending on power source.
461 </p>
462
463 </body>
464 </section>
465 <section>
466 <title>Setting The Frequency</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: <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
517 section</uri> in the end of this guide.
518 </p>
519
520 <p>
521 <c>cpufrequtils</c> can operate in an automatic mode (when you use the
522 <b>ondemand</b> governor), you can also switch to the <b>userspace</b> governor
523 if you want to manually set a specific speed. You can also statically set your
524 CPU to its highest or lowest frequency by using the <b>performance</b>
525 and <b>powersave</b> governors, respectively.
526 </p>
527
528 <pre caption="Changing CPU speeds">
529 <comment>(Set the highest available frequency)</comment>
530 # <i>cpufreq-set -g performance</i>
531 <comment>(Set the lowest available frequency)</comment>
532 # <i>cpufreq-set -g powersave</i>
533 <comment>(Set a specific frequency)</comment>
534 # <i>cpufreq-set -g userspace</i>
535 # <i>cpufreq-set -f 2.00ghz</i>
536 </pre>
537
538 </body>
539 </section>
540 <section>
541 <title>Other CPU Speed Utilities</title>
542 <body>
543
544 <p>
545 While <c>cpufrequtils</c> may be the best all-around program, there are some
546 other choices available in Portage. The following table gives a quick overview
547 of available CPU speed utilities. It's roughly separated in three categories
548 <b>kernel</b> for approaches that only need kernel support, <b>daemon</b> for
549 programs that run in the background and <b>graphical</b> for programs that
550 provide a GUI for easy configuration and changes.
551 </p>
552
553 <table>
554 <tr>
555 <th>Name</th>
556 <th>Category</th>
557 <th>Switch decision</th>
558 <th>Kernel governors</th>
559 <th>Further governors</th>
560 <th>Comments</th>
561 </tr>
562 <tr>
563 <ti>'ondemand' governor</ti>
564 <ti>Kernel</ti>
565 <ti>CPU load</ti>
566 <ti>N.A.</ti>
567 <ti>N.A.</ti>
568 <ti>
569 Chooses maximal frequency on CPU load and slowly steps down when the CPU is
570 idle. Further tuning through files in
571 <path>/sys/devices/system/cpu/cpu0/cpufreq/ondemand/</path>. Still requires
572 userland tools (programs, scripts) if governor switching or similar is
573 desired.
574 </ti>
575 </tr>
576 <tr>
577 <ti>'conservative' governor</ti>
578 <ti>Kernel</ti>
579 <ti>CPU load</ti>
580 <ti>N.A.</ti>
581 <ti>N.A.</ti>
582 <ti>
583 Unlike the ondemand governor, conversative doesn't jump to maximum
584 frequency when CPU load is high, but increases the frequency step by step.
585 Further tuning through files in
586 <path>/sys/devices/system/cpu/cpu0/cpufreq/ondemand/</path>. Still requires
587 userland tools (programs, scripts) if governor switching or similar is
588 desired.
589 </ti>
590 </tr>
591 <tr>
592 <ti><uri link="http://mnm.uib.es/~gallir/cpudyn/">cpudyn</uri></ti>
593 <ti>Daemon</ti>
594 <ti>CPU load</ti>
595 <ti>Performance, powersave</ti>
596 <ti>Dynamic</ti>
597 <ti>
598 Also supports disk standby - notice however that <e>laptop mode</e> in most
599 cases will do a better job.
600 </ti>
601 </tr>
602 <tr>
603 <ti><uri link="http://sourceforge.net/projects/cpufreqd/">cpufreqd</uri></ti>
604 <ti>Daemon</ti>
605 <ti>Battery state, CPU load, temperature, running programs and more</ti>
606 <ti>All available</ti>
607 <ti>None</ti>
608 <ti>
609 Sophisticated (but somewhat complicated) setup. Extendible through plugins
610 like sensor monitoring (lm_sensors) or coordinating some NVidia based
611 graphics card memory and core. Cpufreqd is SMP aware and can optionally be
612 controlled manually at runtime.
613 </ti>
614 </tr>
615 <tr>
616 <ti>
617 <uri link="http://www.deater.net/john/powernowd.html">powernowd</uri>
618 </ti>
619 <ti>Daemon</ti>
620 <ti>CPU load</ti>
621 <ti>None</ti>
622 <ti>Passive, sine, aggressive</ti>
623 <ti>
624 Supports SMP.
625 </ti>
626 </tr>
627 <tr>
628 <ti>
629 <uri
630 link="http://projects.simpledesigns.com.pl/project/ncpufreqd/">ncpufreqd</uri>
631 </ti>
632 <ti>Daemon</ti>
633 <ti>Temperature</ti>
634 <ti>None</ti>
635 <ti>Powersave, performance</ti>
636 <ti>
637 Toggles the used governor between performance and powersave depending on
638 system temperature. Very useful on laptops with notorious heat problems.
639 </ti>
640 </tr>
641 <tr>
642 <ti><uri link="http://www.goop.org/~jeremy/speedfreq/">speedfreq</uri></ti>
643 <ti>Daemon</ti>
644 <ti>CPU load</ti>
645 <ti>None</ti>
646 <ti>Dynamic, powersave, performance, fixed speed</ti>
647 <ti>
648 Easy to configure with a nice client/server interface. Requires a 2.6
649 kernel. Unmaintained, broken and thus removed from Portage. Please switch
650 to cpufreqd if you're still using it.
651 </ti>
652 </tr>
653 <tr>
654 <ti><uri link="http://cpuspeedy.sourceforge.net/">gtk-cpuspeedy</uri></ti>
655 <ti>Graphical</ti>
656 <ti>None</ti>
657 <ti>None</ti>
658 <ti>None</ti>
659 <ti>
660 Gnome application, a graphical tool to set CPU frequency manually. It does
661 not offer any automation.
662 </ti>
663 </tr>
664 <tr>
665 <ti>klaptopdaemon</ti>
666 <ti>Graphical</ti>
667 <ti>Battery state</ti>
668 <ti>All available</ti>
669 <ti>None</ti>
670 <ti>
671 KDE only, 'ondemand' governor required for dynamic frequency scaling.
672 </ti>
673 </tr>
674 </table>
675
676 <p>
677 While adjusting the frequency to the current load looks simple at a first
678 glance, it's not such a trivial task. A bad algorithm can cause switching
679 between two frequencies all the time or wasting energy when setting frequency
680 to an unnecessary high level.
681 </p>
682
683 <p>
684 Which one to choose? If you have no idea about it, try <c>cpufreqd</c>:
685 </p>
686
687 <pre caption="Installing cpufreqd">
688 # <i>emerge cpufreqd</i>
689 </pre>
690
691 <p>
692 <c>cpufreqd</c> can be configured by editing <path>/etc/cpufreqd.conf</path>.
693 The default one that ships with cpufreqd may look a bit confusing. I recommend
694 replacing it with the one from former Gentoo developer Henrik Brix Andersen
695 (see below). Please notice that you need cpufreqd-2.0.0 or later. Earlier
696 versions have a different syntax for the config file.
697 </p>
698
699 <pre caption="/etc/cpufreqd.conf (cpufreqd-2.0.0 and later)">
700 [General]
701 pidfile=/var/run/cpufreqd.pid
702 poll_interval=3
703 enable_plugins=acpi_ac, acpi_battery
704 enable_remote=1
705 remote_group=wheel
706 verbosity=5
707 [/General]
708
709 [Profile]
710 name=ondemand
711 minfreq=0%
712 maxfreq=100%
713 policy=ondemand
714 [/Profile]
715
716 [Profile]
717 name=conservative
718 minfreq=0%
719 maxfreq=100%
720 policy=conservative
721 [/Profile]
722
723 [Profile]
724 name=powersave
725 minfreq=0%
726 maxfreq=100%
727 policy=powersave
728 [/Profile]
729
730 [Profile]
731 name=performance
732 minfreq=0%
733 maxfreq=100%
734 policy=performance
735 [/Profile]
736
737 [Rule]
738 name=battery
739 ac=off
740 profile=conservative
741 [/Rule]
742
743 [Rule]
744 name=battery_low
745 ac=off
746 battery_interval=0-10
747 profile=powersave
748 [/Rule]
749
750 [Rule]
751 name=ac
752 ac=on
753 profile=ondemand
754 [/Rule]
755 </pre>
756
757 <p>
758 Now you can start the cpufreqd daemon. Add it to the <c>default</c> and
759 <c>battery</c> runlevel as well.
760 </p>
761
762 <pre caption="Starting cpufreqd">
763 # <i>rc-update add cpufreqd default battery</i>
764 # <i>/etc/init.d/cpufreqd start</i>
765 </pre>
766
767 <p>
768 Sometimes it can be desirable to select another policy than the daemon chooses,
769 for example when battery power is low, but you know that AC will be available
770 soon. In that case you can turn on cpufreqd's manual mode with <c>cpufreqd-set
771 manual</c> and select one of your configured policies (as listed by
772 <c>cpufreqd-get</c>). You can leave manual mode by executing <c>cpufreqd-set
773 dynamic</c>.
774 </p>
775
776 <warn>
777 Do not run more than one of the above programs at the same time. It may cause
778 confusion like switching between two frequencies all the time.
779 </warn>
780
781 </body>
782 </section>
783 <section>
784 <title>Verifying the result</title>
785 <body>
786
787 <p>
788 The last thing to check is that your new policies do a good job. An easy way to
789 do so is monitoring CPU speed while working with your laptop:
790 </p>
791
792 <pre caption="Monitoring CPU speed">
793 # <i>watch grep \"cpu MHz\" /proc/cpuinfo</i>
794 </pre>
795
796 <p>
797 If <path>/proc/cpuinfo</path> doesn't get updated (see <uri
798 link="#doc_chap8">Troubleshooting</uri>), monitor the CPU frequency with
799 <c>sys-apps/x86info</c>:
800 </p>
801
802 <pre caption="Alternative CPU speed monitoring">
803 # <i>watch x86info -mhz</i>
804 </pre>
805
806 <p>
807 Depending on your setup, CPU speed should increase on heavy load, decrease on
808 no activity or just stay at the same level. When using <c>cpufreqd</c> and
809 verbosity set to 5 or higher in <path>cpufreqd.conf</path> you'll get
810 additional information about what's happening reported to <c>syslog</c>.
811 </p>
812
813 </body>
814 </section>
815 </chapter>
816
817 <chapter>
818 <title>LCD Power Management</title>
819 <section>
820 <body>
821
822 <p>
823 As you can see in <uri link="#doc_chap1_fig1">figure 1.1</uri>, the LCD
824 display consumes the biggest part of energy (might not be the case for
825 non-mobile CPU's). Thus it's quite important not only to shut the display off
826 when not needed, but also to reduce it's backlight if possible. Most laptops
827 offer the possibility to control the backlight dimming.
828 </p>
829
830 </body>
831 </section>
832 <section>
833 <title>Standby settings</title>
834 <body>
835
836 <p>
837 The first thing to check is the standby/suspend/off timings of the display. As
838 this depends heavily on your windowmanager, I'll let you figure it out
839 yourself. Just two common places: Blanking the terminal can be done with
840 <c>setterm -blank &lt;number-of-minutesM&gt;</c>, <c>setterm -powersave on</c>
841 and <c>setterm -powerdown &lt;number-of-minutesM&gt;</c>. For X.org, modify
842 <path>/etc/X11/xorg.conf</path> similar to this:
843 </p>
844
845 <pre caption="LCD suspend settings in X.org">
846 Section "ServerFlags"
847 Option "blank time" "5" <comment># Blank the screen after 5 minutes (Fake)</comment>
848 Option "standby time" "10" <comment># Turn off screen after 10 minutes (DPMS)</comment>
849 Option "suspend time" "20" <comment># Full suspend after 20 minutes</comment>
850 Option "off time" "30" <comment># Turn off after half an hour</comment>
851 [...]
852 EndSection
853
854 [...]
855
856 Section "Monitor"
857 Identifier [...]
858 Option "DPMS"
859 [...]
860 EndSection
861 </pre>
862
863 </body>
864 </section>
865 <section>
866 <title>Backlight dimming</title>
867 <body>
868
869 <p>
870 Probably more important is the backlight dimming. If you have access to the
871 dimming settings via a tool, write a small script that dims the backlight in
872 battery mode and place it in your <c>battery</c> runlevel. The following script
873 should work on most IBM Thinkpads and Toshiba laptops. You've got to enable the
874 appropriate option in your kernel (IBM Thinkpads only). For Toshiba laptops,
875 install <c>sys-power/acpitool</c> and skip configuration of <c>thinkpad_acpi</c>
876 (formerly called <c>ibm_acpi</c>) as described below.
877 </p>
878
879 <warn>
880 Support for setting brightness is marked experimental in thinkpad_acpi. It
881 accesses hardware directly and may cause severe harm to your system. Please
882 read the <uri link="http://ibm-acpi.sourceforge.net/">thinkpad_acpi
883 website</uri>
884 </warn>
885
886 <p>
887 To be able to set the brightness level, the thinkpad_acpi module has to be
888 loaded with the experimental parameter.
889 </p>
890
891 <pre caption="Automatically loading the thinkpad_acpi module">
892 <comment>(Please read the warnings above before doing this!)</comment>
893
894 # <i>echo "options thinkpad_acpi experimental=1" >> /etc/modprobe.d/thinkpad_acpi</i>
895 # <i>update-modules</i>
896 # <i>nano /etc/conf.d/modules</i>
897 <comment># Autoload the thinkpad_acpi module</comment>
898 modules_2_6="thinkpad_acpi"
899 <comment># Parameters for the thinkpad_acpi module</comment>
900 modules_thinkpad_acpi_args_2_6="experimental=1"
901
902 # <i>modprobe thinkpad_acpi</i>
903 </pre>
904
905 <p>
906 This should work without error messages and a file
907 <path>/proc/acpi/ibm/brightness</path> should be created after loading the
908 module. An init script will take care of choosing the brightness according to
909 the power source.
910 </p>
911
912 <pre caption="/etc/conf.d/lcd-brightness">
913 <comment># See /proc/acpi/ibm/brightness for available values</comment>
914 <comment># Please read /usr/src/linux/Documentation/thinkpad-acpi.txt</comment>
915
916 <comment># brightness level in ac mode. Default is 7.</comment>
917 BRIGHTNESS_AC=7
918
919 <comment># brightness level in battery mode. Default is 4.</comment>
920 BRIGHTNESS_BATTERY=4
921 </pre>
922
923 <pre caption="/etc/init.d/lcd-brightness">
924 #!/sbin/runscript
925
926 set_brightness() {
927 if on_ac_power
928 then
929 LEVEL=${BRIGHTNESS_AC:-7}
930 else
931 LEVEL=${BRIGHTNESS_BATTERY:-4}
932 fi
933
934 if [ -f /proc/acpi/ibm/brightness ]
935 then
936 ebegin "Setting LCD brightness"
937 echo "level ${LEVEL}" > /proc/acpi/ibm/brightness
938 eend $?
939 elif [[ -e /usr/bin/acpitool &amp;&amp; -n $(acpitool -T | grep "LCD brightness") ]]
940 then
941 ebegin "Setting LCD brightness"
942 acpitool -l $LEVEL >/dev/null || ewarn "Unable to set lcd brightness"
943 eend $?
944 else
945 ewarn "Setting LCD brightness is not supported."
946 ewarn "For IBM Thinkpads, check that thinkpad_acpi is loaded into the kernel"
947 ewarn "For Toshiba laptops, you've got to install sys-power/acpitool"
948 fi
949 }
950
951 start() {
952 set_brightness
953 }
954
955 stop () {
956 set_brightness
957 }
958 </pre>
959
960 <p>
961 When done, make sure brightness is adjusted automatically by adding it to the
962 battery runlevel.
963 </p>
964
965 <pre caption="Enabling automatic brightness adjustment">
966 # <i>chmod +x /etc/init.d/lcd-brightness</i>
967 # <i>rc-update add lcd-brightness battery</i>
968 # <i>rc</i>
969 </pre>
970
971 </body>
972 </section>
973 </chapter>
974
975 <chapter>
976 <title>Disk Power Management</title>
977 <section>
978 <body>
979
980 <p>
981 Hard disks consume less energy in sleep mode. Therefore it makes sense to
982 activate power saving features whenever the hard disk is not used for a certain
983 amount of time. I'll show you two alternative possibilities to do it. First,
984 laptop-mode will save most energy due to several measures which prevent or at
985 least delay write accesses. The drawback is that due to the delayed write
986 accesses a power outage or kernel crash will be more dangerous for data loss.
987 If you don't like this, you have to make sure that there are no processes which
988 write to your hard disk frequently. Afterwards you can enable power saving
989 features of your hard disk with <c>hdparm</c> as the second alternative.
990 </p>
991
992 </body>
993 </section>
994 <section>
995 <title>Increasing idle time - laptop-mode</title>
996 <body>
997
998 <p>
999 Recent 2.6 kernels include the so-called <c>laptop-mode</c>. When activated,
1000 dirty buffers are written to disk on read calls or after 10 minutes (instead of
1001 30 seconds). This minimizes the time the hard disk needs to be spun up.
1002 </p>
1003
1004 <pre caption="Automated start of laptop-mode">
1005 # <i>emerge laptop-mode-tools</i>
1006 </pre>
1007
1008 <p>
1009 <c>laptop-mode-tools</c> has its configuration file in
1010 <path>/etc/laptop-mode/laptop-mode.conf</path>. Adjust it the way you like it,
1011 it's well commented. Run <c>rc-update add laptop_mode battery</c> to start it
1012 automatically.
1013 </p>
1014
1015 <p>
1016 Recent versions (1.11 and later) of laptop-mode-tools include a new tool
1017 <c>lm-profiler</c>. It will monitor your system's disk usage and running
1018 network services and suggests to disable unneeded ones. You can either disable
1019 them through laptop-mode-tools builtin runlevel support (which will be reverted
1020 by Gentoo's <c>/sbin/rc</c>) or use your <c>default</c>/<c>battery</c>
1021 runlevels (recommended).
1022 </p>
1023
1024 <pre caption="Sample output from running lm-profiler">
1025 # <i>lm-profiler</i>
1026 Profiling session started.
1027 Time remaining: 600 seconds
1028 [4296896.602000] amarokapp
1029 Time remaining: 599 seconds
1030 [4296897.714000] sort
1031 [4296897.970000] mv
1032 Time remaining: 598 seconds
1033 Time remaining: 597 seconds
1034 [4296900.482000] reiserfs/0
1035 </pre>
1036
1037 <p>
1038 After profiling your system for ten minutes, lm-profiler will present a list of
1039 services which might have caused disk accesses during that time.
1040 </p>
1041
1042 <pre caption="lm-profiler suggests to disable some services">
1043 Program: "atd"
1044 Reason: standard recommendation (program may not be running)
1045 Init script: /etc/init.d/atd (GUESSED)
1046
1047 Do you want to disable this service in battery mode? [y/N]: <i>n</i>
1048 </pre>
1049
1050 <p>
1051 To disable atd as suggested in the example above, you would run <c>rc-update
1052 del atd battery</c>. Be careful not to disable services that are needed for
1053 your system to run properly - <c>lm-profiler</c> is likely to generate some
1054 false positives. Do not disable a service if you are unsure whether it's
1055 needed.
1056 </p>
1057
1058 </body>
1059 </section>
1060 <section>
1061 <title>Limiting Write Accesses</title>
1062 <body>
1063
1064 <p>
1065 If you don't want to use laptop-mode, you must take special care to disable
1066 services that write to your disk frequently - <c>syslogd</c> is a good
1067 candidate, for example. You probably don't want to shut it down completely, but
1068 it's possible to modify the config file so that "unnecessary" things don't get
1069 logged and thus don't create disk traffic. <c>Cups</c> writes to disk
1070 periodically, so consider shutting it down and only enable it manually when
1071 needed.
1072 </p>
1073
1074 <pre caption="Disabling cups in battery mode">
1075 # <i>rc-update del cupsd battery</i>
1076 </pre>
1077
1078 <p>
1079 You can also use <c>lm-profiler</c> from laptop-mode-tools (see above) to find
1080 services to disable. Once you eliminated all of them, go on with configuring
1081 hdparm.
1082 </p>
1083
1084 </body>
1085 </section>
1086 <section>
1087 <title>hdparm</title>
1088 <body>
1089
1090 <p>
1091 The second possibility is using <c>hdparm</c>. Skip this if
1092 you are using laptop-mode. Otherwise, edit <path>/etc/conf.d/hdparm</path> and
1093 add the following values to your drive entries. This example assumes your hard
1094 drive is called <b>hda</b>:
1095 </p>
1096
1097 <pre caption="Using /etc/conf.d/hdparm for disk standby">
1098 hda_args="-q -S12"
1099 </pre>
1100
1101 <p>
1102 This will activate power management for your hard drive. If you ever want to
1103 deactivate power management, you can edit <path>/etc/conf.d/hdparm</path> and
1104 change the values to <c>-q -S0</c>, or just run <c>hdparm -q -S0 /dev/hda</c>.
1105 </p>
1106
1107 <p>
1108 See <c>man hdparm</c> for the options. Though you can always start <c>hdparm</c>
1109 manually when you are on battery power by running <c>/etc/init.d/hdparm
1110 start</c>, it's much easier to automate its startup and shutdown. To do so, add
1111 <c>hdparm</c> to the battery runlevel so that it will automatically enable power
1112 management.
1113 </p>
1114
1115 <pre caption="Automate disk standby settings">
1116 # <i>rc-update add hdparm battery</i>
1117 </pre>
1118
1119 <impo>
1120 Be careful with sleep/spin down settings of your hard drive. Setting it to
1121 small values might wear out your drive and lose warranty.
1122 </impo>
1123
1124 </body>
1125 </section>
1126 <section>
1127 <title>Other tricks</title>
1128 <body>
1129
1130 <p>
1131 Another possibility is to deactivate swap in battery mode. Before writing a
1132 swapon/swapoff switcher, make sure there is enough RAM and swap isn't used
1133 heavily, otherwise you'll be in big problems.
1134 </p>
1135
1136 <p>
1137 If you don't want to use laptop-mode, it's still possible to minimize disk
1138 access by mounting certain directories as <c>tmpfs</c> - write accesses are not
1139 stored on a disk, but in main memory and get lost with unmounting. Often it's
1140 useful to mount <path>/tmp</path> like this - you don't have to pay special
1141 attention as it gets cleared on every reboot regardless whether it was mounted
1142 on disk or in RAM. Just make sure you have enough RAM and no program (like a
1143 download client or compress utility) needs extraordinary much space in
1144 <path>/tmp</path>. To activate this, enable tmpfs support in your kernel and
1145 add a line to <path>/etc/fstab</path> like this:
1146 </p>
1147
1148 <pre caption="Editing /etc/fstab to make /tmp even more volatile">
1149 none /tmp tmpfs size=32m 0 0
1150 </pre>
1151
1152 <warn>
1153 Pay attention to the size parameter and modify it for your system. If you're
1154 unsure, don't try this at all, it can become a performance bottleneck easily. In
1155 case you want to mount <path>/var/log</path> like this, make sure to merge the
1156 log files to disk before unmounting. They are essential. Don't attempt to mount
1157 <path>/var/tmp</path> like this. Portage uses it for compiling...
1158 </warn>
1159
1160 </body>
1161 </section>
1162 </chapter>
1163
1164 <chapter>
1165 <title>Power Management For Other Devices</title>
1166 <section>
1167 <title>Graphics Cards</title>
1168 <body>
1169
1170 <p>
1171 In case you own an ATI graphics card supporting PowerPlay (dynamic clock
1172 scaling for the graphics processing unit GPU), you can activate this
1173 feature in X.org. Open <path>/etc/X11/xorg.conf</path> and add (or enable) the
1174 <c>DynamicClocks</c> option in the Device section. Please notice that this
1175 feature will lead to crashes on some systems.
1176 </p>
1177
1178 <pre caption="Enabling ATI PowerPlay support in X.org">
1179 Section "Device"
1180 [...]
1181 Option "DynamicClocks" "on"
1182 EndSection
1183 </pre>
1184
1185 </body>
1186 </section>
1187 <section>
1188 <title>Wireless Power Management</title>
1189 <body>
1190
1191 <p>
1192 Wireless LAN cards consume quite a bit of energy. Put them in Power Management
1193 mode just like your hard drives.
1194 </p>
1195
1196 <note>
1197 This script assumes your wireless interface is called <c>wlan0</c>; replace
1198 this with the actual name of your interface.
1199 </note>
1200
1201 <p>
1202 Add the following option to <path>/etc/conf.d/net</path> to automatically enable
1203 power management for your wireless card:
1204 </p>
1205
1206 <pre caption="Automated WLAN Power Management">
1207 iwconfig_wlan0="power on"
1208 </pre>
1209
1210 <p>
1211 See <c>man iwconfig</c> for details and more options like the period between
1212 wakeups or timeout settings. If your driver and access point support changing
1213 the beacon time, this is a good starting point to save even more energy.
1214 </p>
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 [*] Suspend to RAM and standby
1280 </pre>
1281
1282 <p>
1283 Once your kernel is properly configured, you can use the
1284 <c>hibernate-script</c> to activate suspend or sleep mode. Let's install that
1285 first.
1286 </p>
1287
1288 <pre caption="Installing the hibernate-script">
1289 # <i>emerge hibernate-script</i>
1290 </pre>
1291
1292 <p>
1293 Some configuration has to be done in <path>/etc/hibernate</path>. The default
1294 package introduces a few configuration files for each sleep state. Options that
1295 are common to all suspend methods are placed in <path>common.conf</path>; make
1296 sure this file is properly set up for your system.
1297 </p>
1298
1299 <p>
1300 To configure sleep, edit <path>sysfs-ram.conf</path> in
1301 <path>/etc/hibernate</path>. <c>UseSysfsPowerState mem</c> is already setup
1302 correctly, but if you need to make further changes to this particular sleep
1303 state (or any other sleep state) you should add them to
1304 <path>/etc/hibernate/hibernate.conf</path>. The comments and option names will
1305 guide you. If you use nfs or samba shares over the network, make sure to
1306 shutdown the appropriate init scripts to avoid timeouts.
1307 </p>
1308
1309 <note>
1310 For more information on setting up sleep states, read <c>man
1311 hibernate.conf</c>.
1312 </note>
1313
1314 <p>
1315 Ready? Now is the last chance to backup any data you want to keep after
1316 executing the next command. Notice that you probably have to hit a special key
1317 like <c>Fn</c> to resume from sleep.
1318 </p>
1319
1320 <pre caption="Calling sleep">
1321 # <i>hibernate-ram</i>
1322 </pre>
1323
1324 <p>
1325 If you're still reading, it seems to work. You can also setup standby (S1) in a
1326 similar way by editing <path>sysfs-ram.conf</path> and changing
1327 "UseSysfsPowerState mem" to "UseSysfsPowerState standby". S3 and S4 are the more
1328 interesting sleep states due to greater energy savings however.
1329 </p>
1330
1331 </body>
1332 </section>
1333 <section>
1334 <title>Hibernate (S4)</title>
1335 <body>
1336
1337 <p>
1338 This section introduces hibernation, where a snapshot of the running system is
1339 written to disk before powering off. On resume, the snapshot is loaded and you
1340 can go on working at exactly the point you called hibernate before.
1341 </p>
1342
1343 <warn>
1344 Don't exchange non hot-pluggable hardware when suspended. Don't attempt to load
1345 a snapshot with a different kernel image than the one it was created with.
1346 Shutdown any NFS or samba server/client before hibernating.
1347 </warn>
1348
1349 <p>
1350 There are two different implementations for S4. The original one is swsusp,
1351 then there is the newer tuxonice (formerly suspend2) with a nicer interface
1352 (including fbsplash support). A <uri
1353 link="http://tuxonice.net/features.html#compare">feature comparison</uri> is
1354 available at the <uri link="http://www.tuxonice.net">tuxonice homepage</uri>.
1355 There used to be Suspend-to-Disk (pmdisk), a fork of swsusp, but it has been
1356 merged back.
1357 </p>
1358
1359 <p>
1360 TuxOnIce is not included in the mainline kernel yet, therefore you either have
1361 to patch your kernel sources with the patches provided by <uri
1362 link="http://www.tuxonice.net">tuxonice.net</uri> or use
1363 <c>sys-kernel/tuxonice-sources</c>.
1364 </p>
1365
1366 <p>
1367 The kernel part for both swusp and TuxOnIce is as follows:
1368 </p>
1369
1370 <pre caption="Kernel configuration for the various suspend types">
1371 Power Management support ---&gt;
1372 <comment>(hibernate with swsusp)</comment>
1373 [*] Hibernation (aka 'suspend to disk')
1374 <comment>(replace /dev/SWAP with your swap partition)</comment>
1375 (/dev/SWAP) Default resume partition
1376
1377 <comment>(hibernate with TuxOnIce)</comment>
1378 Enhanced Hibernation (TuxOnIce)
1379 --- Image Storage (you need at least one allocator)
1380 [*] File Allocator
1381 [*] Swap Allocator
1382 --- General Options
1383 [*] Compression support
1384 [ ] Allow Keep Image Mode
1385 [*] Replace swsusp by default
1386 </pre>
1387
1388 <p>
1389 The configuration for swsusp is rather easy. If you didn't store the location
1390 of your swap partition in the kernel config, you can also pass it as a
1391 parameter with the <c>resume=/dev/SWAP</c> directive. If booting is not
1392 possible due to a broken image, use the <c>noresume</c> kernel parameter. The
1393 <c>hibernate-cleanup</c> init script invalidates swsusp images during the boot
1394 process.
1395 </p>
1396
1397 <pre caption="Invalidating swsusp images during the boot process">
1398 # <i>rc-update add hibernate-cleanup boot</i>
1399 </pre>
1400
1401 <p>
1402 To activate hibernate with swsusp, use the hibernate script and set
1403 <c>UseSysfsPowerState disk</c> in <path>/etc/hibernate/sysfs-disk</path>.
1404 </p>
1405
1406 <warn>
1407 Backup your data before doing this. Run <c>sync</c> before executing one of the
1408 commands to have cached data written to disk. First try it outside of X, then
1409 with X running, but not logged in.
1410 </warn>
1411
1412 <p>
1413 If you experience kernel panics due to uhci or similar, try to compile USB
1414 support as module and unload the modules before sending your laptop to sleep
1415 mode. There are configuration options for this in <path>common.conf</path>
1416 </p>
1417
1418 <pre caption="Hibernating with swsusp">
1419 # <i>nano -w /etc/hibernate/common.conf</i>
1420 <comment>(Make sure you have a backup of your data)</comment>
1421 # <i>hibernate</i>
1422 </pre>
1423
1424 <p>
1425 The following section discusses the setup of TuxOnIce including fbsplash support
1426 for a nice graphical progress bar during suspend and resume.
1427 </p>
1428
1429 <p>
1430 The first part of the configuration is similar to the configuration of swsusp.
1431 In case you didn't store the location of your swap partition in the kernel
1432 config, you have to pass it as a kernel parameter with the
1433 <c>resume=swap:/dev/SWAP</c> directive. If booting is not possible due to a
1434 broken image, append the <c>noresume</c> parameter. Additionally, the
1435 <c>hibernate-cleanup</c> init script invalidates TuxOnIce images during the boot
1436 process.
1437 </p>
1438
1439 <pre caption="Invalidating TuxOnIce images during the boot process">
1440 # <i>rc-update add hibernate-cleanup boot</i>
1441 </pre>
1442
1443 <p>
1444 Now edit <path>/etc/hibernate/tuxonice.conf</path>, enable the <c>TuxOnIce</c>
1445 options you need. Do not enable the <c>fbsplash</c> options in
1446 <c>common.conf</c> just yet.
1447 </p>
1448
1449 <pre caption="Hibernating with TuxOnIce">
1450 # <i>nano -w /etc/hibernate/tuxonice.conf</i>
1451 <comment>(Make sure you have a backup of your data)</comment>
1452 # <i>hibernate</i>
1453 </pre>
1454
1455 <p>
1456 Please configure <c>fbsplash</c> now if you didn't do already. To enable
1457 fbsplash support during hibernation, the <c>sys-apps/tuxonice-userui</c> package
1458 is needed. Additionally, you've got to enable the <c>fbsplash</c> USE flag.
1459 </p>
1460
1461 <pre caption="Installing tuxonice-userui">
1462 # <i>echo "sys-apps/tuxonice-userui fbsplash" >> /etc/portage/package.use</i>
1463 # <i>emerge tuxonice-userui</i>
1464 </pre>
1465
1466 <p>
1467 The ebuild tells you to make a symlink to the theme you want to use. For
1468 example, to use the <c>livecd-2005.1</c> theme, run the following command:
1469 </p>
1470
1471 <pre caption="Using the livecd-2005.1 theme during hibernation">
1472 # <i>ln -sfn /etc/splash/livecd-2005.1 /etc/splash/tuxonice</i>
1473 </pre>
1474
1475 <p>
1476 If you don't want a black screen in the first part of the resume process, you
1477 have to add the <c>tuxoniceui_fbsplash</c> tool to your initrd image. Assuming
1478 you created the initrd image with <c>splash_geninitramfs</c> and saved it as
1479 <path>/boot/fbsplash-emergence-1024x768</path>, here's how to do that.
1480 </p>
1481
1482 <pre caption="Adding tuxoniceui_fbsplash to an initrd image">
1483 # <i>mount /boot</i>
1484 # <i>mkdir ~/initrd.d</i>
1485 # <i>cp /boot/fbsplash-emergence-1024x768 ~/initrd.d/</i>
1486 # <i>cd ~/initrd.d</i>
1487 # <i>gunzip -c fbsplash-emergence-1024x768 | cpio -idm --quiet -H newc</i>
1488 # <i>rm fbsplash-emergence-1024x768</i>
1489 # <i>cp /usr/sbin/tuxoniceui_fbsplash sbin/</i>
1490 # <i>find . | cpio --quiet --dereference -o -H newc | gzip -9 > /boot/fbsplash-tuxonice-emergence-1024x768</i>
1491 </pre>
1492
1493 <p>
1494 Afterwards adjust <path>grub.conf</path> (or <path>lilo.conf</path>) so that
1495 your TuxOnIce kernel uses
1496 <path>/boot/fbsplash-tuxonice-emergence-1024x768</path> as initrd image. You can
1497 now test a dry run to see if everything is setup correctly.
1498 </p>
1499
1500 <pre caption="Test run for fbsplash hibernation">
1501 # <i>tuxoniceui_fbsplash -t</i>
1502 </pre>
1503
1504 <p>
1505 Afterwards open <path>/etc/hibernate/common.conf</path> and activate the
1506 fbsplash options. Execute <c>hibernate</c> and enjoy.
1507 </p>
1508
1509 </body>
1510 </section>
1511 </chapter>
1512
1513 <chapter>
1514 <title>Troubleshooting</title>
1515 <section>
1516 <body>
1517
1518 <p>
1519 <e>Q:</e> I'm trying to change the CPU frequency, but
1520 <path>/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor</path> does not
1521 exist.
1522 </p>
1523
1524 <p>
1525 <e>A:</e> Make sure your processor supports CPU frequency scaling and you chose
1526 the right CPUFreq driver for your processor. Here is a list of processors that
1527 are supported by cpufreq (kernel 2.6.7): ARM Integrator, ARM-SA1100, ARM-SA1110,
1528 AMD Elan - SC400, SC410, AMD mobile K6-2+, AMD mobile K6-3+, AMD mobile Duron,
1529 AMD mobile Athlon, AMD Opteron, AMD Athlon 64, Cyrix Media GXm, Intel mobile
1530 PIII and Intel mobile PIII-M on certain chipsets, Intel Pentium 4, Intel Xeon,
1531 Intel Pentium M (Centrino), National Semiconductors Geode GX, Transmeta Crusoe,
1532 VIA Cyrix 3 / C3, UltraSPARC-III, SuperH SH-3, SH-4, several "PowerBook" and
1533 "iBook2" and various processors on some ACPI 2.0-compatible systems (only if
1534 "ACPI Processor Performance States" are available to the ACPI/BIOS interface).
1535 </p>
1536
1537 <p>
1538 <e>Q:</e> My laptop supports frequency scaling, but
1539 <path>/sys/devices/system/cpu/cpu0/cpufreq/</path> is empty.
1540 </p>
1541
1542 <p>
1543 <e>A:</e> Look for ACPI related error messages with <c>dmesg | grep ACPI</c>.
1544 Try to update the BIOS, especially if a broken DSDT is reported. You can also
1545 try to fix it yourself (which is beyond the scope of this guide).
1546 </p>
1547
1548 <p>
1549 <e>Q:</e> My laptop supports frequency scaling, but according to
1550 <path>/proc/cpuinfo</path> the speed never changes.
1551 </p>
1552
1553 <p>
1554 <e>A:</e> Probably you have activated symmetric multiprocessing support
1555 (CONFIG_SMP) in your kernel. Deactivate it and it should work. Some older
1556 kernels had a bug causing this. In that case, run <c>emerge x86info</c>, update
1557 your kernel as asked and check the current frequency with <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 mainly
1568 used for thermal management (keeping your laptop cool and quiet). You can read
1569 the current throttling state with <c>cat /proc/acpi/processor/CPU/throttling</c>
1570 and change it with <c>echo -n "0:x" > /proc/acpi/processor/CPU/limit</c>, where
1571 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 /
1606 action 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>
1611 script that is shipped with acpid. You can safely ignore it. If you like to get
1612 rid of it, you can comment the appropriate line in
1613 <path>/etc/acpi/default.sh</path> as shown 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>
1631 and 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
1637 <c>DynamicClocks</c>.
1638 </p>
1639
1640 <p>
1641 <e>Q:</e> I want to use TuxOnIce, but it tells me my swap partition is too
1642 small. Resizing is not an option.
1643 </p>
1644
1645 <p>
1646 <e>A:</e> If there is enough free space on your system, you can use the
1647 filewriter instead of the swapwriter. The <c>hibernate-script</c> supports it as
1648 well. More information can be found in
1649 <path>/usr/src/linux/Documentation/power/tuxonice.txt</path>.
1650 </p>
1651
1652 <p>
1653 <e>Q:</e> I just bought a brand new battery, but it only lasts for some
1654 minutes! What am I doing wrong?
1655 </p>
1656
1657 <p>
1658 <e>A:</e> First follow your manufacturer's advice on how to charge the battery
1659 correctly.
1660 </p>
1661
1662 <p>
1663 <e>Q:</e> The above didn't help. What should I do then?
1664 </p>
1665
1666 <p>
1667 <e>A:</e> Some batteries sold as "new" are in fact old ones. Try the following:
1668 </p>
1669
1670 <pre caption="Querying battery state">
1671 $ <i>grep capacity /proc/acpi/battery/BAT0/info</i>
1672 design capacity: 47520 mWh
1673 last full capacity: 41830 mWh
1674 </pre>
1675
1676 <p>
1677 If the "last full capacity" differs significantly from the design capacity,
1678 your battery is probably broken. Try to claim your warranty.
1679 </p>
1680
1681 <p>
1682 <e>Q:</e> My problem is not listed above. Where should I go next?
1683 </p>
1684
1685 <p>
1686 <e>A:</e> Don't fear to contact me, <mail link="earthwings@gentoo.org">Dennis
1687 Nienhüser</mail>, directly. The <uri link="http://forums.gentoo.org">Gentoo
1688 Forums</uri> are a good place to get help as well. If you prefer IRC, try the
1689 <c>#gentoo-laptop</c> <uri link="irc://irc.gentoo.org">channel</uri>.
1690 </p>
1691
1692 </body>
1693 </section>
1694 </chapter>
1695 </guide>

  ViewVC Help
Powered by ViewVC 1.1.20