Linux isn’t exactly known for it’s excellent battery life; in fact, battery life on Linux can often be quite dismal. This was exactly the case with a recent install of LMDE (based upon Debian Wheezy). I was expecting to get at least 4-5 hours of battery life, if not considerably more on my new Lenovo Thinkpad X220. Not even close to being the case; I was getting 3 – 3:30 hours of battery life.
After doing some research, I read complaints about the Linux 3.2 kernel in regard to battery life. It turns out that the stock kernel that comes with Debian Wheezy is horrendous at sipping juice. To make matters worse, when compiling a new kernel on the laptop whilst running Linux 3.2, my CPU was approaching 100C under full load.
Fortunately, there’s a simple(ish) solution that solves this terrible tragedy of battery life: a new kernel.
For those who haven’t upgraded their own kernel before (myself included), it’s a fairly simple process. And don’t worry, it’s fairly difficult to break your system (and even if you do, you should be able to boot with your original kernel by selecting it at boot). Here’s how to upgrade your kernel.
1. Get the Latest Kernel — head on over to kernel.org and select the latest “stable” kernel (be sure to select the .tar.xz file).
$ wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.9.8.tar.xz
2. Create a New Directory and Extract the Kernel.
$ mkdir ~/new_kernel && mv linux-3.9.8.tar.xz ~/new_kernel && cd ~/new_kernel && tar xvf linux-3.9.8.tar.xz && cd linux-3.9.8
3. Install the appropriate packages to compile a new kernel.
$ sudo apt-get install kernel-package fakeroot build-essential ncurses-dev
4. Configure your new kernel. (Note: You may be asked a number of questions. You can always hit “enter” if you don’t understand the question or want to skip it. There is little risk in doing so.)
$ cat /boot/config-`uname -r`>.config
$ make oldconfig
5. Prepare the new kernel to be compiled.
$ make-kpkg clean
6. Compile the new kernel. Be sure to change the “j4” operand to the number of threads / cores you have. (This takes a long time, so feel free to go do something else).
$ sudo time fakeroot make-kpkg -j4 —initrd kernel_image kernel_headers
7. Install the freshly compiled kernel.
$ sudo dpkg -i *.deb
8. Reboot and enjoy.
Props to LinuxG for his article that inspired this post. I would recommend installing Linux 3.9.8 over 3.9.0 because it appears that a bug was introduced in 3.9.0 that caused battery life to drop dramatically after waking the machine from sleep (suspend).
After compiling and installing a new kernel for my laptop, I am now getting between 5-7 hours of battery life depending on usage. That’s a dramatic change and certainly well-desired on a laptop. As for a temperature change, I’m currently idling at 43C and seeing temperatures around 85-90C (as opposed to ~100C) under load.