old-www/HOWTO/Ecology-HOWTO/ecology-howto-power-managem...

737 lines
17 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML
><HEAD
><TITLE
>Advanced Power Management (APM/ACPI)</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="Linux Ecology-HOWTO"
HREF="index.html"><LINK
REL="UP"
TITLE="Reduction of Power Consumption"
HREF="ecology-howto-power-consumption.html"><LINK
REL="PREVIOUS"
TITLE="Reduction of Power Consumption"
HREF="ecology-howto-power-consumption.html"><LINK
REL="NEXT"
TITLE="Power Management Unit - PMU (Apple PowerBook)"
HREF="ecology-howto-pmu.html"></HEAD
><BODY
CLASS="sect1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Linux Ecology-HOWTO</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="ecology-howto-power-consumption.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 1. Reduction of Power Consumption</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="ecology-howto-pmu.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="sect1"
><H1
CLASS="sect1"
><A
NAME="ecology-howto-power-management"
></A
>1.1. Advanced Power Management (APM/ACPI)</H1
><P
>&#13;Putting your GNU/Linux PC in suspend or hibernate mode.
</P
><DIV
CLASS="sect2"
><H2
CLASS="sect2"
><A
NAME="AEN106"
></A
>1.1.1. ACPI</H2
><P
>&#13;Most modern PCs support the ACPI (Advanced Configuration and Power Interface) standard.
The <A
HREF="http://acpi.sourceforge.net/"
TARGET="_top"
>ACPI4Linux</A
> project works on
implementing full ACPI support in the Linux kernel, including fan control, dock/undock detection.
</P
><P
>&#13;All ACPI related information (such as processor or board temperature) is available through files
in <TT
CLASS="filename"
>/proc/acpi</TT
>. For example, this makes it very easy for desktop environments
(or for your own programs) to display to temperature information somewhere on your screen.
</P
><DIV
CLASS="sect3"
><H3
CLASS="sect3"
><A
NAME="AEN112"
></A
>1.1.1.1. Hibernate to disk</H3
><P
>&#13;Use hibernate to disk and no longer be afraid
of switching off your system. Booting is much faster
than having to wait for services and graphics
to start up. Actually, most of the time is saved by getting back to your work
as you left it before suspending your computer (open files, terminals, browser windows).
There is no need to re-open everything!
</P
><P
>&#13;While hibernating is often considered as a power saving solution
for notebook computers, it should also be used for desktop computers,
to save AC power. Use it when you go for lunch, when you leave the office
in the evening or for holidays...
</P
><P
>&#13;Hibernating also saves a lot of time when you replace a battery of a notebook.
Again, hibernate, install a fresh battery, power up and get back to your
work as you left it off.
</P
><P
>&#13;Technical details
</P
><P
></P
><UL
><LI
><P
>&#13;Hibernation to disk is implemented by the
<A
HREF="http://www.suspend2.net/"
TARGET="_top"
>Suspend 2 for Linux</A
> project.
It consists of a kernel driver and a user-space program to control the driver.
Users just need to run the program (usually called <B
CLASS="command"
>hibernate</B
>).
</P
></LI
><LI
><P
>&#13;It works by copying the whole of used RAM to a swap partition.
As a consequence, it requires the swap partition to be at least as
big as the amount of RAM.
</P
></LI
><LI
><P
>&#13;Both the patched kernel and the user-space program are very
easy to install through packages.
<P
></P
><UL
><LI
><P
>&#13; Here are
<A
HREF="http://mhensler.de/swsusp/"
TARGET="_top"
>Fedora Core packages</A
>
for download.
</P
></LI
><LI
><P
>&#13; At least in the 6.06 release of (K)Ubuntu,
hibernating is directly available as an option from the battery icon.
</P
></LI
><LI
><P
>&#13; Go to your favorite package source for other distributions
</P
></LI
></UL
>
</P
></LI
></UL
></DIV
></DIV
><DIV
CLASS="sect2"
><H2
CLASS="sect2"
><A
NAME="AEN135"
></A
>1.1.2. Older hardware with APM</H2
><DIV
CLASS="sect3"
><H3
CLASS="sect3"
><A
NAME="AEN137"
></A
>1.1.2.1. Linux Compatibility Check</H3
><P
>&#13;From the
<A
HREF="http://tldp.org/HOWTO/Battery-Powered/index.html"
TARGET="_top"
>Battery Powered Linux Mini-HOWTO</A
>
" .. for APM to work on any notebook or energy-conscious desktop, the system BIOS ROM in the machine must support the APM standard. Furthermore, for APM to work with the Linux operating system, the system BIOS ROM must support either the 1.0 or 1.1 version of the APM standard, and it must also support 32-bit protected mode connections. A system that supports APM 1.1 is preferred, as it provides more features that the device driver and supporting utilities can take advantage of."
You may get information about the APM version with the <B
CLASS="command"
>dmesg</B
> command and in the <TT
CLASS="filename"
>/proc/apm</TT
> file.
</P
></DIV
><DIV
CLASS="sect3"
><H3
CLASS="sect3"
><A
NAME="AEN143"
></A
>1.1.2.2. Introduction</H3
><P
>&#13;When you first install Linux, you will probably have to recompile the kernel. The kernel that came with your distribution probably does not have APM enabled.
</P
><P
>&#13;APM support consists of two parts: <B
CLASS="command"
>kernel</B
> support and <B
CLASS="command"
>user-land</B
> support.
</P
><P
>&#13;For <B
CLASS="command"
>kernel</B
> support, enable the parameters in the corresponding kernel section. AFAIK not all features work with laptops. AFAIK the feature <B
CLASS="command"
>CONFIG_APM_POWER_OFF</B
> works with most laptops.
</P
><P
>&#13;The utilities for <B
CLASS="command"
>userland</B
> support may be found at <A
HREF="http://www.worldvisions.ca/~apenwarr/apmd/"
TARGET="_top"
>WorldVisions</A
>. APMD is a set of programs that control the Advanced Power Management system found in most modern laptop computers. If you run a 2.2.x kernel and want to experiment, Gabor Kuti &#60;seasons at falcon.sch.bme.hu&#62; has made a kernel patch that allows you to <B
CLASS="command"
>hibernate</B
> any Linux system to disk, even if your computers APM BIOS doesn't support it directly.
</P
></DIV
><DIV
CLASS="sect3"
><H3
CLASS="sect3"
><A
NAME="AEN156"
></A
>1.1.2.3. Caveats</H3
><P
>&#13;If you have another operating system preinstalled or use another operating system at the same disk, make sure there is no "hibernation" or "suspend" tool installed, which could severely interfere with Linux, e.g. it might use disk space which is occupied by Linux or vice versa.
</P
></DIV
><DIV
CLASS="sect3"
><H3
CLASS="sect3"
><A
NAME="AEN159"
></A
>1.1.2.4. Troubleshooting</H3
><P
>&#13;Sometimes X windows and APM don't work smoothly together, the machine might even hang. A recommendation from Steve Rader: Some Linux systems have their X server hang when doing <B
CLASS="command"
>apm -s</B
>. Folks with this affliction might want switch to the console virtual terminal then suspend <B
CLASS="command"
>chvt 1; apm -s</B
> as root, or, more appropriately, <B
CLASS="command"
>sudo chvt 1; sudo apm -s</B
>. I have these commands in a script, say, <B
CLASS="command"
>my-suspend</B
> and then do <B
CLASS="command"
>xapmload --click-command my-suspend</B
> .
</P
><P
>&#13;On some new machines (for instance HP Omnibook 4150 - 366 MHz model) when accessing <TT
CLASS="filename"
>/proc/apm</TT
>, you may get a kernel fault <B
CLASS="command"
>general protection fault: f000</B
>. <A
HREF="http://www.canb.auug.org.au/~sfr/"
TARGET="_top"
>Stephen Rothwell</A
> explains: "This is your APM BIOS attempting to use a real mode segment while in protected mode, i.e. it is a bug in your BIOS. .. We have seen a few of these recently, except all the others are in the power off code in the BIOS wher we can work around it by returning to real mode before attempting to power off. Here we cannot do this."
</P
></DIV
></DIV
><DIV
CLASS="sect2"
><H2
CLASS="sect2"
><A
NAME="ecology-howto-cpufreq"
></A
>1.1.3. Processor frequency scaling</H2
><P
>&#13;<B
CLASS="command"
>cpufreq</B
> is a Linux kernel driver to control the CPU frequency.
It is included in all recent kernels and enabled by default by recent distributions.
It supports most recent "mobile" processors. Note that only such
processors support frequency scaling.
</P
><P
>&#13;This driver lets user programs control cpu frequency
by writing files in
<TT
CLASS="filename"
>/sys/devices/system/cpu/cpu&#60;n&#62;/cpufreq/</TT
>.
</P
><P
>&#13;Actually, frequency scaling is usually handled by
a <EM
>governor</EM
> program, according
to system or user specific preferences.
</P
><P
>&#13;<A
HREF="http://carlthompson.net/Software/CPUSpeed"
TARGET="_top"
>CPUSpeed
</A
>is the de-facto governor for Linux.
It allows to control the <B
CLASS="command"
>cpufreq</B
> driver
according to user defined criteria: CPU load, board temperature, battery / plugged in...
It is released by default in recent distributions.
</P
><P
>&#13;CPUspeed is usually configured through the <TT
CLASS="filename"
>/etc/cpuspeed.conf</TT
> file
(Fedora Core 4 example):
</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>&#13;VMAJOR=1
VMINOR=1
DRIVER="speedstep-centrino"
OPTS="-i 2
-t /proc/acpi/thermal_zone/THM/temperature 70
-a /proc/acpi/ac_adapter/AC/state
-p 10 25
-m 600000 -M 1600000"
</PRE
></FONT
></TD
></TR
></TABLE
><P
>&#13;After making changes, you can restart CPUspeed with
<B
CLASS="command"
>/etc/init.d/cpuspeed restart</B
> (Fedora Core example).
</P
><P
>&#13;Type <B
CLASS="command"
>/usr/sbin/cpuspeed -h</B
> for details and more options.
</P
><P
>&#13;You can type <B
CLASS="command"
>cat /proc/cpuinfo</B
>
to consult the current processor speed. That's useful
to check that the processor speed is scaled according
to your settings.
</P
></DIV
><DIV
CLASS="sect2"
><H2
CLASS="sect2"
><A
NAME="ecology-howto-pm-resources"
></A
>1.1.4. Useful Resources for Power Management</H2
><P
>&#13;
<P
></P
><UL
><LI
><P
>&#13;<A
HREF="http://hdparm.sourceforge.net/"
TARGET="_top"
>hdparm</A
>
- <B
CLASS="command"
>hdparm</B
> is a Linux IDE disk utility that lets you set
spin-down timeouts and other disk parameters. It works also for some SCSI features.
</P
></LI
><LI
><P
>&#13;<A
HREF="http://www.xs4all.nl/~bsamwel/laptop_mode/"
TARGET="_top"
><B
CLASS="command"
>Laptop Mode</B
></A
>
- A feature implemented in the Linux kernel since the 2.6.6 version.
The idea is to spin up the hard disk only when reading uncached data,
to delay and group disk writes, in order to reduce hard disk power consumption
and save battery life. Control scripts are shipped by default by recent
distributions.
</P
><P
>&#13;<B
CLASS="command"
>Laptop Mode</B
> may not be activated by default by distributions,
as it is not recommended for servers and laptops running on AC power,
because of the risk to loose data in a crash or sudden power off.
</P
></LI
><LI
><P
>&#13;<A
HREF="http://muru.com/linux/dyntick/"
TARGET="_top"
>Dynamic Tick</A
>
is available since kernel 2.6.21 and later.
When enabled, this kernel feature allows to disable the
CPU timer interrupts when all processors are idle.
This way, idle systems are not woken up every 4 ms
(default setting in Linux 2.6) just to realize there is nothing to do!
This can save a little bit of power in notebooks
(and CPU cycles in virtual hosting servers).
Regular timer interrupts are re-enabled when something
really happens, when a real hardware interrupt is received.
In kernel configuration, this feature can be selected
from the <B
CLASS="command"
>Kernel Features</B
>
section (<B
CLASS="command"
>NO_IDLE_HZ</B
> setting).
You can verify whether it is enabled with
<B
CLASS="command"
>cat /boot/config-$(uname -r) | grep CONFIG_NO_HZ</B
>.
</P
></LI
><LI
><P
>&#13;<A
HREF="http://www.complang.tuwien.ac.at/ulrich/linux/tips.html"
TARGET="_top"
>Mobile Update Daemon</A
>
is a drop-in replacement for the standard <B
CLASS="command"
>update</B
> daemon, <B
CLASS="command"
>mobile-update</B
> minimizes disk spin ups and reduces disk uptime. It flushes buffers only when other disk activity is present. To ensure a consistent file system call <B
CLASS="command"
>sync</B
> manually. Otherwise files may be lost on power failure. <B
CLASS="command"
>mobile-update</B
> does not use APM. So it works also on older systems.
</P
></LI
><LI
><P
>&#13;The <B
CLASS="command"
>noatime</B
> and <B
CLASS="command"
>nodiratime</B
>
mount options can be used to reduce disk writings.
In operating systems like Linux which comply with the POSIX standard,
filesystems are supposed to record the last time files are read.
With default kernel settings, even if files are read from the file
cache in RAM, this causes time data to be written to disk every
5 seconds. You may use a line like this
<B
CLASS="command"
>/dev/hda3 /data ext3 defaults,noatime,nodiratime, 1 2</B
> for example
in <TT
CLASS="filename"
>/etc/fstab</TT
>.
</P
><P
>&#13;To avoid this and reduce disk activity, you can add the <B
CLASS="command"
>noatime</B
>
mount option to lines in the <TT
CLASS="filename"
>/etc/fstab</TT
> file.
</P
><P
>&#13;This option doesn't have any known or significant impact on regular programs,
except perhaps for backup / archiving software for which file access time information
is useful.
</P
></LI
><LI
><P
>&#13;<A
HREF="http://www.buzzard.me.uk/toshiba/index.html"
TARGET="_top"
>Toshiba Linux Utilities</A
>
- This is a set of Linux utilities for controlling the fan, supervisor passwords, and hot key functions of Toshiba Pentium notebooks. There is a KDE package <B
CLASS="command"
>Klibreta</B
>, too.
</P
></LI
><LI
><P
>&#13;<A
HREF="http://lcdproc.omnipotent.net/"
TARGET="_top"
>LCDproc</A
>
- "LCDproc is a small piece of software that will enable your Linux box
to display live system information on a LCD display. It
supports a lot of serial and parallel LCDs.
</P
></LI
><LI
><P
>&#13;<A
HREF="http://sourceforge.net/projects/diald/"
TARGET="_top"
>Dial Daemon</A
>
- The Diald daemon provides on demand Internet connectivity using the SLIP or PPP protocols. Diald can automatically dial in to a remote host when needed or bring down dial-up connections that are inactive.
</P
></LI
><LI
><P
>&#13;Getting your computer to use the least amount of power can be problematic.
Intel's
<A
HREF="http://www.linuxpowertop.org/"
TARGET="_top"
>http://www.linuxpowertop.org/</A
> project provides information on reducing power usage, tips, and tricks for Intel-based computers running Linux.
As a first step, Intel has released PowerTOP, a tool that helps you find what
software is using the most power. By fixing (or closing) these applications or
processes, you can immediately see the power savings in the tool. You'll also
see the estimated time left for battery power if you are running a laptop. The
Tips &#38; Tricks page has fixes for a lot of the issues that are already found.
</P
></LI
></UL
>
</P
></DIV
><DIV
CLASS="sect2"
><H2
CLASS="sect2"
><A
NAME="ecology-howto-restoring"
></A
>1.1.5. Restoring your Work after Shutdown</H2
><P
>&#13;Even if you don't use hibernate or suspend and
switch off your system in a standard way, you still
have ways of saving time getting back to your work.
</P
><P
>&#13;Modern graphical environments (KDE or Gnome)
restart the applications that were open when you logged out.
However, most applications just get back to their initial state
and you will probably need to open your files again.
</P
><P
>&#13;For people who do not want to loose the HTML pages
they were browsing, the <A
HREF="http://www.mozilla.com/firefox/"
TARGET="_top"
>&#13;Mozilla Firefox browser</A
> as a nice <B
CLASS="command"
>Bookmark All Tabs...</B
>
command in the <B
CLASS="command"
>Bookmarks</B
> menu.
This is very convenient to restore a set of tabs
or just to start your browser with all your favorite information
sites when you arrive in the morning.
Firefox v3 can save the current state of the browser and will
restore it upon powerup.
</P
><P
>&#13;So, unless your computer is really computing something,
you have less excuses for keeping it on!
</P
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="ecology-howto-power-consumption.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="ecology-howto-pmu.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Reduction of Power Consumption</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ecology-howto-power-consumption.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Power Management Unit - PMU (Apple PowerBook)</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>