Practical Guide to Linux Laptop power management

Source: Internet
Author: User
Tags apm change settings
Article Title: Linux Laptop power management practical guide. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Linux is an open-source operating system with superior performance. With its increasing performance and popularity, the most important thing is its unparalleled price advantage. Many manufacturers have begun to launch Linux laptops, in addition, this trend is becoming increasingly popular. We know that laptops are limited by battery endurance, so we pay special attention to the Power Management of machines. Therefore, this article will discuss how to deal with these issues.
  
   I. Overview
In fact, in addition to using the BIOS on the motherboard to manage power, most Linux systems themselves come with utility software for power management to handle various power events, such:
  
1. Insufficient battery-the machine will issue a warning and display corresponding icons, or suspend the hardware.
  
2. Idle-if the machine remains inactive for a period of time, it can sleep (such as shutting down the hard disk and disabling audio and network services) to effectively extend the battery time.
  
By checking whether your laptop is using AC power or battery, you can bring the machine into the corresponding power management mode. In Fedora, the tools used to manage and repair power supply problems are:
  
1. Advanced Power Management (APM)-the APM software is composed of the following: a pmd daemon to monitor battery usage; multiple utility software to display and respond to battery events. They are included in the apmd software package.
  
2. advanced Configuration and Power Interface (ACPI)-The acpid event daemon monitors power events and sets rules for responding to these events to turn off some hardware or power off the system. ACPI is a more universal tool software designed to replace APM power management, but it still needs to be further improved.
  
3. The hdparm command-hdparm command can be used to enable and disable the power management function. In addition, this command has many options to complete operations such as stopping the hard disk initiator or turning the hard disk into the STANDBY state.
  
Note that when ACPI is used, the operating system is responsible for power management, not BIOS. Although ACPI is more powerful and flexible in power management, it is not so convenient for common users, for example, when ACPI is used, you must tell it in person what power events you want to pay attention to and how to respond to these events. Currently, for general users, APM features are not only rich, but also more user-friendly.
  
Below we will discuss the three common power management tools.
  
   2. Use APM to manage Power Supply
In Fedora, you can configure APM to detect some power events and respond to them. At this time, it runs the daemon/usr/sbin/apmd to listen for events, and then handles these events according to the relevant provisions in the configuration file/etc/sysconfig/apmd. To configure and run APM, enter the following command:
  
# Chkconfig apmd on
# Service apmd restart
  
Note: apmd and acpid cannot be used at the same time. Therefore, if the system is using acpid, stop it first. The specific command is as follows:
  
# Chkconfig acpid off
# Service acpid stop
  
After the APM is started successfully, you should see a message in the file/var/log/messages, indicating that the service has been started and the current Battery status is listed. By default, the pmd daemon runs according to the settings in the/etc/sysconfig/apmd file. We can list the currently running processes to see which options are used by the running apmd:
  
# Ps ax | grep apmd
/Usr/sbin/apmd-p 10-w 5-W-P/etc/sysconfig/apm-scripts/apmscript
  
Based on the options listed in the preceding command, the apmd daemon will:
  
1. record changes in battery power-if the power change exceeds 10% or more, the daemon sends a message to the system log file (/var/log/messages by default. This line is specified by the option "-p 10.
  
2. Record insufficient battery power-a warning message is sent to the system log file when the battery power is less than 5% and is not fully charged. This line is specified by the option "-w 5.
  
3. Remind the user-if the battery power is lower than the value set by the "-w" option, an alarm will be sent to all users logging on to the system. This action is specified by the option "-W.
  
4. Use apmscript to respond to events-when a power event occurs, apmd transfers these events to the scripts used to respond to these events. According to the preceding command, the running script is/etc/sysconfig/apm-scripts/apmscript. The file used depends on the option "-P ".
  
In addition to the above power shortage and power change settings, most of the power events that are responded to are only mentioned in the apmscript file. If you want to know the power management of your machine, you can see the contents of this file at a glance. In FedoraCore, you must create your own scripts to add your own power events to respond. The default apmscript file is/etc/sysconfig/apm-scripts/apmcontinue. This file handles the following events:
  
1. pending-when your laptop is in suspended or STANDBY state, apmscript will stop all audio processing programs, Mount all of its hard drive operations, and disable any NFS connections, disable the network connection and the pcmcia card.
  
2. Restoration-apmscript restores all events that have been suspended during restoration.
  
3. power Change-when the power of the machine changes, the script will respond: If the AC power is used, the machine will run in High Performance; if the battery is used, this allows the machine to run in a more power-saving state.
  
4. Change the battery-if the battery is out of power, this event will stop all apm services and enter the ultimate power-saving mode.
  
5. BOOT-when the machine is started, apmscript will first check the apmcontinue file, unless you have set what to do during startup in this file, otherwise the script will do nothing.
  
6. Stop-the same as when the server is started, the apmscript will first check the apmcontinue file when the server is stopped. Unless you have set what to do during startup in this file, the script will do nothing.
  
Other events can also exist in the apmcontinue file (which does not exist by default) to respond to other selected events. In addition, you can create a/etc/sysconfig/apm-scripts/apmcontinue script to respond to various events stored in files such as apmscript.
  
If you just want to check the APM service, you can use the apm command without parameters to view the battery power status or whether the AC power is used:
  
# Apm
AC on-line, battery charging: 100%
  
You can also bring your laptop into the suspended mode (apm-s) or standby mode (apm-S ). When the AC power is on, the laptop ignores all pending and standby events caused by APM (apm-I.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.