|
Power Management on Linux, Part 2
Five Degrees of Laptop OffIn part 1 of this series we learned how to measure how much power our systems are using, both hardware and software, and some tricks for reducing power usage without degrading performance. Today we're going to dive into the world of power management on laptops: ACPI, APM, hard disk spindowns, and spinups. Power management on laptops is all about squeezing out more battery time. It's a losing battle as laptops get more powerful and use bigger displays. For example, my old Thinkpad R32 runs for three hours on a charge, even on wireless. My shiny new dual-core T61 lasts a bit under two hours. The new machine is brighter and faster, and it has a magnesium roll cage. (Oo la la, like a race car.) Modern laptops with wide glossy screens are lucky to get ninety minutes. You can get more battery time by dimming the screen, and mobile CPUs can be configured to run slower on battery. So sticking with an old slow dim machine might be a good option, because you get the same effect with no work. Managing interruptions is a common problem for laptop users. Shutting down and starting up again takes time and eats power. And so we have a confusing array of not-really-off options:
ACPI vs. APMAPM (Advanced Power Management) is the old power management daemon and utilities for Linux. It's simple and easy, and it leaves most of the power management to your system BIOS. The modern replacement is ACPI (Advanced Configuration and Power Interface). The ACPI standard has several advantages over APM: it puts control of power management in the operating system instead of the system BIOS, and it handles events like slow and idle states in different components. For example, Intel led the way in dynamic CPU power management, and now both Intel and AMD CPUs scale their power needs according to demand. Network interfaces, video cards, and hard drives that support going into idle states can all be managed by ACPI. ACPI is well-supported by Windows, which translates into wide ACPI support. Which can also a source of problems, because of Microsoft's famous habit of implementing standards in their own non-standard ways, but these days some laptop manufacturers actually test for ACPI compliance on the major Linux distributions. Amazing and true. As always, shop carefully, and if it means spending a few more dollars to get a machine that works well with Linux, it's money well-spent, because it means you're buying better-quality hardware. Those bargain Winmachines are cheap through and through, and they use a lot of shoddy Windows hacks as substitutes for good hardware. Lenovo Thinkpads and ASUS are my favorites (ASUS even has free recycling). Toshiba and Fujitsu laptops are good-quality and Linux works well on them too.
The Easy WayIf you need easy, reliable power management for your laptop then I officially recommend using a Linux distribution that does it correctly out of the box, because trying to set it up from scratch is a heroic undertaking. This includes recent releases of Fedora, Ubuntu, SUSE, and Mandriva, and I'm sure there are more. Fedora has a good configuration menu in the Preferences menu, and the shutdown command includes Suspend and Hibernate. It also suspends or hibernates when you close the lid, and wakes up reliably. Nice and easy just like it should be. Most modern Linux distributions default to ACPI. You can check your own distribution; this command shows you if your kernel supports ACPI: $ grep -i acpi_sleep /boot/config-'uname -r' CONFIG_ACPI_SLEEP=y CONFIG_ACPI_SLEEP_PROC_FS=y CONFIG_ACPI_SLEEP_PROC_SLEEP=yOr check which daemon is running: $ ps ax|egrep "apmd|acpi"
4720 ? S 0:00 hald-addon-acpi: listening \
on acpid socket /var/run/acpid.socket
5239 ? Ss 0:00 /usr/sbin/acpid -c \
/etc/acpi/events -s /var/run/acpid.socket
These examples show that ACPI is supported and running. The laptop-mode-tools package is an interesting tool for configuring your laptop hard drive to save power, plus a few other devices as well, but its main claim to fame is controlling hard drive spin-down. The Linux kernel likes a nice balanced I/O, so your hard drive works at a fairly steady pace. laptop-mode-tools changes this behavior by caching writes for longer periods in memory, then committing writes in bursts. So your hard drive can spin down between bursts, which saves a bit of power. You only want to do this with laptop hard disks, which are built to survive 600,000 or more spinups. Desktop hard drives are rated for up to 50,000 spinups, so using laptop-mode-tools will kill them quickly. 30 seconds to a minute are optimal spindown intervals; anything greater than that doesn't save more power. laptop-mode-tools is included in Debian and Ubuntu, and packages for other distributions are at Laptop Mode. It integrates itself with ACPI, so it already knows to go to work only when you're on battery power. ResourcesLessWatts.org, everything you'll ever want to know about ACPILaptops, power management, and Ubuntu Battery Powered Linux Mini-HOWTO is a bit dated, but still informative Carla Schroder is the author of the Linux Cookbook and the newly-released Linux Networking Cookbook, and is a regular contributor to LinuxPlanet.
|