/[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.15 - (hide annotations) (download) (as text)
Fri Oct 28 14:48:06 2005 UTC (8 years, 8 months ago) by so
Branch: MAIN
Changes since 1.14: +409 -157 lines
File MIME type: application/xml
#106878 update for this guide

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

  ViewVC Help
Powered by ViewVC 1.1.20