/[gentoo]/xml/htdocs/doc/en/power-management-guide.xml
Gentoo

Diff of /xml/htdocs/doc/en/power-management-guide.xml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.47

  ViewVC Help
Powered by ViewVC 1.1.20