/[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.48 - (show annotations) (download) (as text)
Wed Aug 17 07:19:29 2011 UTC (2 years, 11 months ago) by swift
Branch: MAIN
Changes since 1.47: +32 -12 lines
File MIME type: application/xml
Bug #367145 - Update pmg_switch_runlevel.sh script and add a note in the beginning of the document that this script has been updated

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

  ViewVC Help
Powered by ViewVC 1.1.20