Linux battery life: how to improve it?


As we all know, notebooks' battery life on Linux isn't what we would want it to be. Things are slowly improving, for example developers of a popular distro which name starts and ends on "U" are researching power saving options to include in 12.04 version of their Linux flavour. As for more interesting distributions (like my Arch), user is usually left in the dark (but hey, isn't it the purpose of non-foolproof Linux distros? :] ). This article hopes to shed some light at some disabled-by-default Linux power saving options and tricks.


1. Install laptop-mode-tools
This package enables kernel's laptop-mode, which in turn enables many power-saving features of Linux, like spinning down hard disks or enabling some power-saving modules. You can see /etc/laptop-mode/laptop-mode.conf file for details. You will need to enable acpid and laptop-mode services to be started on boot. You should also take a look at individual module settings in /etc/laptop-mode/conf.d because many of the modules are off by default (at least on Arch). The config files are nicely explained, so I won't tell much about setting them up, just enable and check the ones that you think you need.

2. Hybrid graphics
Not really a power management trick, but still a worthy advice. If your laptop is as new and shiny as mine, you might have 2 graphic cards (so-called Hybrid Graphics). One of these is usually Intel, which keeps your notebook cool and quiet, not to mention it drains less battery. But as Intel cards are not the fastest ones out there, there's another card for gaming/high performance tasks. If second one is ATI (AMD), then I wish you good luck. I'm not too familiar with the situation but things just started to look better (after being very bad), with AMD beginning to support hybrid configurations in their binary driver. See Linux Hybrid Graphics blog link below for more info.

If the second card is NVIDIA, you need to use community-driven Bumblebee (no official hybrid graphics support from NVIDIA as of yet). As the installation procedure is distro-specific, you need to find a howto on your own. But it's as simple as googling "<yourdistroname> bumblebee". Link for Arch is below. What you need to remember if you have 64-bit Linux, and you want to run 32-bit games/apps (Wine included) with NVIDIA card: install necessary 32bit libraries (both for nvidia driver and virtualgl packages). Intel card is used by default, to run a program using NVIDIA card, run it through optirun (i.e. 'optirun glxgears'). Also, you might want to install and enable bbswitch to have the NVIDIA card disabled when unused.

3. Use Linux 3.3 kernel, or enable Active State Power Management manually
If you didn't hear yet about this infamous kernel regression, it basically disables power saving features in PCI Express devices because BIOSes of popular motherboards are faulty - they don't tell Linux about supporting ASPM, which results in this feature being disabled on lots of computers. To enable it again, you need to add pcie_aspm=force to your kernel's command line (in your GRUB configuration file). You don't need to do this if you're running 3.3 kernel, or using a distro with the fix backported (Ubuntu 12.04).

4. Intel graphics power savings
You can add i915.i915_enable_rc6=1 i915.i915_enable_fbc=1 i915.lvds_downclock=1 to your kernel's command line as well, if you have Intel Sandy Bridge (or newer) graphics (if your processor is called i3/i5/i7 then you do) to further lower the power consumption (when idle). On older systems these commands might result in crashes, compositing problems, or flickering, so you need to see for yourself if these options are safe for you.

4. Disable unnecessary hardware to save battery life
Make a file (filename isn't important) in /etc/modprobe.d/ and write "blacklist module" for every device driver we want to disable, each in new line. For driver names we need to consult our notebook specs and commands like lsmod, lshw etc. This method makes the module not to load AUTOMATICALLY. So if we ever need it, we can just load the driver again. Be aware though, that if you have any program that needs some blacklisted module, it will be able to load it as well. So you need to disable the program (or look for some option to stop using the hardware) or find another method of disabling the device.

5. Use rfkill to block wireless devices from being turned on
I can't block my Bluetooth using first method - Gnome Bluetooth keeps loading it again, and I can't simply uninstall it because entire Gnome depends on it. And my distro is Arch, which I believe is the most modular one (not counting Gentoo as it's a different story) out there, so I expect if Arch devs didn't find a way to separate Gnome-shell from Bluetooth support, then no one did. But there's another solution. Install rfkill, and use 'rfkill block bluetooth' to block all Bluetooth devices. You need to issue this command on every boot.

As for the results... I have yet to test the eventual improvements, and will edit the article. What I can tell now is that usually I had 2h45min predicted battery time left when unplugging (and usually this time was genuine). Now it predicts 5 hours, which is quite good :)

On Windows, with ASUS PowerGear's battery saving profile (which surprisingly does something good to battery life, first time in my life I saw useful bundled software...) I have 7h of predicted battery life, and effective time seems to be ~5 to 5,5h (internet browsing, coding, nothing that needs exceptional performance). I'll be back in a week of extensive testing on boring lectures on my studies :) Keep in mind that based on how many things you enabled (or disabled), results may vary.






Links:
Arch Wiki: Bumblebee
Arch Wiki: Laptop Mode Tools
Arch Wiki: Laptop, section Power Management
Linux Hybrid Graphics blog
A Proper Solution To The Linux ASPM Problem
Phoronix: Tweaks To Extend The Battery Life Of Intel Linux Notebooks

Comments

Popular Posts