Выбрать главу

3.1.1.4. Managing power from the command line

If you are using your system through a text-mode console, you can still access the important power-management tools.

To suspend the system, execute the pm-suspend script:

$ pm-suspend

To hibernate, use the pm-hibernate script:

$ pm-hibernate

To view the battery status, access ACPI through the /proc filesystem:

$ cat /proc/acpi/battery/*/state

present: yes

capacity state: ok

charging state: charging

present rate: 3079 mA

remaining capacity: 2912 mAh

present voltage: 16273 mV

Battery details are also available from ACPI:

$ cat /proc/acpi/battery/*/info

present: yes

design capacity: 6450 mAh

last full capacity: 5154 mAh

battery technology: rechargeable

design voltage: 14800 mV

design capacity warning: 515 mAh

design capacity low: 156 mAh

capacity granularity 1: 5 mAh

capacity granularity 2: 5 mAh

model number: DELL 0017F

serial number: 14639

battery type: LION

OEM info: Sony

By dividing the last full capacity by the design capacity, you can determine the condition of the battery. In this case, the battery can presently store 5154/6450 mAh, or about 80 percent of its design capacity, indicating that it's in reasonably good condition.

3.1.1.5. Other ways to extend battery life

To further reduce power consumption:

 Dim your screen as much as the ambient lighting conditions will allow. The backlight for the screen draws a huge amount of power; one of my systems draws 31 percent more power in total when the screen is at maximum brightness than when it is set to minimum brightness.

 Turn off all unneeded services, reducing CPU and disk activity.

 Use a lightweight desktop environment such as Xfce instead of GNOME or KDE.

Xfce can be easily installed (see Lab 5.3, "Using Repositories"). To select your desktop environment, use the Session menu on the graphical login screen. 

 Unplug any unneeded external devices, including USB devices, headphones, mice, and keyboards. Each USB device can consume up to 2.5 watts of power, increasing your power consumption by as much as 20 percent.

 Turn off your wireless network radio when it is not in use. Most laptops have a wireless kill switch (sometimes labeled airplane or flight mode ) that turns off the radio portion of the wireless card. This can cut your power consumption by up to 5 percent.

3.1.2. How Does It Work?

The ACPI specification enables a system's BIOS to supply data and program code to the operating system. The code is written in a unique, processor-independent pseudo-machine language called ACPI Machine Langauge (AML). The Linux kernel interpretively executes the AML code to access certain features of the host hardware system. You can think of the AML code as a type of device driver that is downloaded from the BIOS to the operating system.

The Linux kernel uses the ACPI data and code to collect data that is then exposed through the /proc/acpi directory. Information received through the /proc/acpi directorysuch as instructions to change the CPU frequencyis passed to the ACPI code.

Applications such as cpuspeed and gnome-power-manager monitor the ACPI information and combine it with other information (such as current process load) and then make power management decisions. These decisions cause actions to be taken by various subsystems such as the ACPI, the X Window server, storage, and loadable modules.

The Fedora power-management system is in active development. To stay informed of the latest developments, subscribe to the fedora-laptop-list (see Lab 9.1, "Participating in the Fedora Mailing Lists"). 

3.1.3. What About...

3.1.3.1. ...stopping the hard drive motors when the drives are not in use?

The hdparm program can be used to stop a drive immediately or to configure it to stop if it is idle for a certain length of time; this is called a spin-down (and restarting the drive is called a spin-up ). This does save some power; however, the drive is rarely idle for very long and the length of time (and amount of energy) required to spin-up the drive is significant (and hard on some hardware), so opinion is divided on whether it makes sense to use this feature.

In the case of a two-drive system where the second drive is rarely used, an idle spin-down timeout is a good idea. Configure it with the hdparm command:

# hdparm -S 6 /dev/[hs]d[a-z]

The -S option configures the amount of time that the drive must be idle before spin-down is triggered. The scheme used to encode the timeout period is a bit convoluted (it is described in detail on the manpage for hdparm ), but 0 means that spin-down is disabled, and a value from 1 to 240 sets the idle timeout in multiples of 5 seconds (5 seconds to 20 minutes). The value of 6 used here indicates a 30-second idle timeout.

3.1.3.2. ...turning the computer on and off (or hibernating and resuming) at certain times automatically?

Some important operations are best performed when a system is not in normal use, such as backup, software updating, and data indexing. It's not necessary to keep a system running 24x7 in order to schedule nighttime tasks.

Most modern system BIOSes contain an alarm wake feature, which causes the system to turn on at a preset time. This feature can be used with the hibernate state or a full system shutdown to automate nocturnal activities.

The BIOS configuration utility varies from system to system; consult your system or motherboard documentation. 

Some BIOS versions permit the wake time to be set through ACPI. To see if this is possible on your system, enable the alarm wake feature using your BIOS configuration utility, then boot Fedora and examine the /proc/acpi/alarm file:

$ cat /proc/acpi/alarm

2007-03-17 00:00:00

Attempt to set this to a time in the future (the date portion of the time may be ignored by your system). If your system clock is maintained in UTC, be sure to also specify this time in UTC:

# echo " 2007-03-17 16:45:00" >/proc/acpi/alarm

$ cat /proc/acpi/alarm