Monday 5 January 2009

Improve battery life on a Linux laptop



Often I find that one of the key things that matters in a laptop that you plan to lug around, especially at school, is it's battery life. Without electricity the laptop is as good as a brick, although it might be more shinier. Most laptops sold in the market today usually have good battery life. However, the big question is: what can you do if you already have a laptop with a good battery life... but want to INCREASE the battery life? Also, let assume that you are running Linux on the laptop... since right now I am running Ubuntu on my laptop and I love every moment of it.

Improving battery life for Ubuntu/Kubuntu/Edubuntu etc.

The first things that you can do to improve your battery life are pretty obvious, but I'll mention them here anyway:
  • Lower the display brightness to the lowest possible level to make sure that the screen doesn't sip your battery power.
  • Close any applications that you are not using and unplug any usb/external deviceees that you might not be using as well. This saves some memory from being used (and also makes the hard drive work a little less) and ensures that no power is taken for ports that you aren't really using. See below for information on how to disable the USB ports as well to improve more battery life.
  • Disable all Linux eye candy (Do this by going to System > Preferences > Appearance > Visual Effects Tab > Choose 'None') . This means - No Beryl/Compiz Fusion, no wobbly windows and no fancy revolving cubes. It also means a couple of extra minutes of battery power - So choose wisely.
  • Turn off wireless and bluetooth if you don't need it.
Now, for the more technical stuff that's going to improve your battery life. As always, you might want to make sure that you back up your data before you try this, because most of the tips stated below can in fact cause your system to hang and in the worst case scenario - cause it to be inoperable. But on the other hand, if it works fine for your laptop then you might be able to improve the battery power by 20 - 30%.

Step 1: Enable Laptop Mode

This uses the 'laptop' policies that are in ubuntu to ensure that the computer uses only the resources it really needs. As a result, it'll be able to cut down on the resources it doesn't need and save you some battery power. To do so... I did the following:

First, I pressed Alt + F2, which brought up the run application command, and typed in the command:

sudo gedit /etc/default/acpi-support

And checked the box beside 'Run in terminal' and clicked Run.


Then, I typed in my password when Terminal asked me to type it and pressed enter... and Gedit opened with the file.

Then I changed ENABLE_LAPTOP_MODE=true. And saved the file. And finally I restarted the computer... just to let the changes take effect (but I guess there must be some command out there that I don't know of that will make the changes take effect automatically).

Step 2: Make your CPU run slower by enabling CPU frequency scaling


I opened a terminal window, (Applications > Accessories > Terminal) and typed in :

sudo chmod +s /usr/bin/cpufreq-selector

If it asks you for you password... then type it in and press enter. Then, right click on the menubar and click Add to Panel. Then click on the CPU Frequency Scaling Monitor and click Add. From the CPU Scaling Monitor, choose the lowest possible Speed (in my case 1GHz) or choose the "Powersave" option.

Doing so will make the laptop run at a much slower CPU speed and save you a LOT of power.


Step 3: Disabling unused ports on your computer and throttling the wireless card's power



By disabling the unused USB ports etc. on your laptop, and decreasing the power used by your wireless card, you can save even more battery power. Obviously, if you're using a USB mouse or a necessary external USB device, you don't want to disable the ports. But if you're not using then then you can safely disable them.

To disable USB ports, open a terminal window and type:

sudo rmmod uhci_hcd
and then type in your password if necessary and press enter. This should disable the USB ports.

To put your wireless card (sorry... this only works for intel wireless cards) into power saving mode do what i did:
I pressed Alt + F2 like stated above, which brought up the run application command, and typed in the command:

sudo gedit /etc/laptop-mode/conf.d/wireless-ipw-power.conf

And checked the box beside 'Run in terminal' and clicked Run.


Then, I typed in my password when Terminal asked me to type it and pressed enter... and Gedit opened with the file.

Then I changed the 0 to 1 for CONTROL_IPW_POWER. Saved the file and quit Gedit. Of course, you could have changed the other parameters as well... but I didn't bother doing that, since the default looked good enough for me.

Step 4: Enjoy the newly gained battery power


That's it... the "hacks" mentioned above are about the only things you can do (with the exception of restarting Ubuntu in shell mode and using only the text interface.) to boost your battery life.

If you know any other ways of improving battery life or battery performance, do state them in the comments below!




Got a question, tip or comment? Send them to beyondteck+question@gmail.com and we'll try to answer it in a blog post!

11 comments:

  1. Do you have launchpad bugs for why "laptop mode" isn't enabled by default, and why /etc/laptop-mode/conf.d/wireless-ipw-power.conf doesn't have CONTROL_IPW_POWER=1 by default?

    ReplyDelete
  2. When running graphical apps through sudo, you should use gksudo, not regular sudo. Using gksudo helps prevent such annoying things as root-owned files in your home directory.

    gksudo gedit /etc/default/acpi-support

    ReplyDelete
  3. Oh, also, "Ondemand" is probably better for power savings. YMMV, but Ondemand gave me the best results.

    ReplyDelete
  4. @candrews: no, I don't have launchpad bugs for why laptop mode isn't on by default. As far as I know, laptop mode causes problems for some laptops with random shutdowns or something like that. So I understand why laptop mode isn't on by default.

    @jgoguen: Thanks for the tips! I'll keep that in mind. I've never really known the difference between regular sudo and gksudo.. I though it was bot the same. I guess not?

    ReplyDelete
  5. thanks for the articles i appreciate your work

    ReplyDelete
  6. Great to see a collection of blog posts that includes thoughtful and perceptive commentary.Keep up the great work .thanks for sharing this information about Improve battery life on a Linux laptop.

    ReplyDelete
  7. Running Linux on a laptop saves energy. Maximize our Laptop Battery Life under Linux can be done by keeping these points in mind .Putting our computer to sleep when it is inactive, Setting our computer to hibernate mode when battery power is low, Slowing down the hard disk spin, Putting display to sleep when it is inactive, Reducing the back light brightness, Dimming display when the computer is idle, thanks.
    pc repairs brisbane

    ReplyDelete
  8. I would just like to say thanks, for your instructions worked first time.
    reset windows 7 password

    ReplyDelete
  9. Improve Battery Life On A Linux Laptop >>>>> Download Now

    >>>>> Download Full

    Improve Battery Life On A Linux Laptop >>>>> Download LINK

    >>>>> Download Now

    Improve Battery Life On A Linux Laptop >>>>> Download Full

    >>>>> Download LINK qe

    ReplyDelete