1.1. Advanced Power Management (APM/ACPI)
Putting your GNU/Linux PC in suspend or hibernate mode.
1.1.1. ACPI
Most modern PCs support the ACPI (Advanced Configuration and Power Interface) standard. The ACPI4Linux project works on implementing full ACPI support in the Linux kernel, including fan control, dock/undock detection.
All ACPI related information (such as processor or board temperature) is available through files in /proc/acpi. For example, this makes it very easy for desktop environments (or for your own programs) to display to temperature information somewhere on your screen.
1.1.1.1. Hibernate to disk
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!
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...
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.
Technical details
Hibernation to disk is implemented by the Suspend 2 for Linux 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 hibernate).
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.
Both the patched kernel and the user-space program are very easy to install through packages.
Here are Fedora Core packages for download.
At least in the 6.06 release of (K)Ubuntu, hibernating is directly available as an option from the battery icon.
Go to your favorite package source for other distributions
1.1.2. Older hardware with APM
1.1.2.1. Linux Compatibility Check
From the Battery Powered Linux Mini-HOWTO " .. 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 dmesg command and in the /proc/apm file.
1.1.2.2. Introduction
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.
APM support consists of two parts: kernel support and user-land support.
For kernel support, enable the parameters in the corresponding kernel section. AFAIK not all features work with laptops. AFAIK the feature CONFIG_APM_POWER_OFF works with most laptops.
The utilities for userland support may be found at WorldVisions. 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 <seasons at falcon.sch.bme.hu> has made a kernel patch that allows you to hibernate any Linux system to disk, even if your computers APM BIOS doesn't support it directly.
1.1.2.3. Caveats
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.
1.1.2.4. Troubleshooting
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 apm -s. Folks with this affliction might want switch to the console virtual terminal then suspend chvt 1; apm -s as root, or, more appropriately, sudo chvt 1; sudo apm -s. I have these commands in a script, say, my-suspend and then do xapmload --click-command my-suspend .
On some new machines (for instance HP Omnibook 4150 - 366 MHz model) when accessing /proc/apm, you may get a kernel fault general protection fault: f000. Stephen Rothwell 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."
1.1.3. Processor frequency scaling
cpufreq 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.
This driver lets user programs control cpu frequency by writing files in /sys/devices/system/cpu/cpu<n>/cpufreq/.
Actually, frequency scaling is usually handled by a governor program, according to system or user specific preferences.
CPUSpeed is the de-facto governor for Linux. It allows to control the cpufreq driver according to user defined criteria: CPU load, board temperature, battery / plugged in... It is released by default in recent distributions.
CPUspeed is usually configured through the /etc/cpuspeed.conf file (Fedora Core 4 example):
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" |
After making changes, you can restart CPUspeed with /etc/init.d/cpuspeed restart (Fedora Core example).
Type /usr/sbin/cpuspeed -h for details and more options.
You can type cat /proc/cpuinfo to consult the current processor speed. That's useful to check that the processor speed is scaled according to your settings.
1.1.4. Useful Resources for Power Management
hdparm - hdparm is a Linux IDE disk utility that lets you set spin-down timeouts and other disk parameters. It works also for some SCSI features.
Laptop Mode - 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.
Laptop Mode 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.
Dynamic Tick 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 Kernel Features section (NO_IDLE_HZ setting). You can verify whether it is enabled with cat /boot/config-$(uname -r) | grep CONFIG_NO_HZ.
Mobile Update Daemon is a drop-in replacement for the standard update daemon, mobile-update 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 sync manually. Otherwise files may be lost on power failure. mobile-update does not use APM. So it works also on older systems.
The noatime and nodiratime 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 /dev/hda3 /data ext3 defaults,noatime,nodiratime, 1 2 for example in /etc/fstab.
To avoid this and reduce disk activity, you can add the noatime mount option to lines in the /etc/fstab file.
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.
Toshiba Linux Utilities - 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 Klibreta, too.
LCDproc - "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.
Dial Daemon - 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.
Getting your computer to use the least amount of power can be problematic. Intel's http://www.linuxpowertop.org/ 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 & Tricks page has fixes for a lot of the issues that are already found.
1.1.5. Restoring your Work after Shutdown
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.
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.
For people who do not want to loose the HTML pages they were browsing, the Mozilla Firefox browser as a nice Bookmark All Tabs... command in the Bookmarks 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.
So, unless your computer is really computing something, you have less excuses for keeping it on!