Page 1 of 4 123 ... LastLast
Results 1 to 10 of 35

Thread: The simple & effective power management guide (how to save battery power)

  1. #1
    Join Date
    Nov 2006
    Location
    Germany
    Beans
    244
    Distro
    Ubuntu 14.04 Trusty Tahr

    The simple & effective power management guide (how to save battery power)

    v 0.25 - This guide is written for Ubuntu 9.10 Karmic Koala

    This guide is focused on how to implement most common power management tips, taken from the community and powertop suggestions, in the simplest way. Its aim is to be rock stable and quite effective without putting notebooks at risks. It has been tested by me on a Lenovo Thinkpad X60s with almost exclusively Intel hardware.

    Hard disks
    In Karmic hard drives are managed by a script and gnome-power-manager (g-p-m). The settings are very safe and probably there could still be some power to save but I prefer to play on the safe side with my hard disk.

    I decided not to enable laptop-mode and not to play with the values in /usr/lib/pm-utils/power.d/95hdparm-apm or the seconds2sleep in gnome-power-manager.

    Probably buying a good solid state drive could get much better results, but they are still very expensive.

    Screen brightness
    In karmic it is handled again by g-p-m, the standard values can be played with though.
    Press alt+F2 and type
    Code:
    gconf-editor
    scroll the "apps" section on the left and open "gnome-power-manager". The related part is "backlight". The "brightness_dim_battery" key is defaulted at 50, that means a 50% reduction.

    Personally I'm fine with the lowest brightness on my screen. Double click on the key name, in the pop up instead of 50 write 99 (that practically means 100% reduction, but the 100 value gives me problems).

    Try different values to see which one is better for you, of course higher value, lower brightness, lower power consumption.

    link power management policy
    This is a tip among the ones suggested by running the powertop program (software center > powertop).
    Run gedit (applications>accessories) and paste the following text in the empty document
    Code:
    #!/bin/sh
    
    path_host0="/sys/class/scsi_host/host0/link_power_management_policy"
    path_host1="/sys/class/scsi_host/host1/link_power_management_policy"
    path_host2="/sys/class/scsi_host/host2/link_power_management_policy"
    path_host3="/sys/class/scsi_host/host3/link_power_management_policy"
    val=max_performance
    
    case "$1" in
    	true)
    		echo "**lpm policy powersave ON"
    		val=min_power
    		;;
    	false)
    		echo "**lpm policy powersave OFF"
    		val=max_performance
    		;;
    esac
    
    # max_performance on AC min_power on battery
    
    if [ -w "$path_host0" ] ; then
    	echo $val > $path_host0
    fi
    
    if [ -w "$path_host1" ] ; then
    	echo $val > $path_host1
    fi
    
    if [ -w "$path_host2" ] ; then
    	echo $val > $path_host2
    fi
    
    if [ -w "$path_host3" ] ; then
    	echo $val > $path_host3
    fi
    
    exit 0
    close and save (in your home directory) calling it
    Code:
    link_pm_policy
    Run a terminal (applications>accessories) and paste the following lines one at a time pressing return after each one
    Code:
    chmod 755 link_pm_policy
    sudo su
    install link_pm_policy /usr/lib/pm-utils/power.d/
    exit
    you WILL be asked for your password, just type it in and press return.

    virtual memory dirty writeback
    Again as suggested by powertop.
    Run gedit (applications>accessories) and paste the following text in the empty document
    Code:
    #!/bin/sh
    
    path_dwc="/proc/sys/vm/dirty_writeback_centisecs"
    val=500
    
    case "$1" in
    	true)
    		echo "**VM dirty writeback 15 seconds"
    		val=1500
    		;;
    	false)
    		echo "**VM dirty writeback 5 seconds"
    		val=500
    		;;
    esac
    
    # 5 seconds on AC, 15 seconds on battery
    
    if [ -w "$path_dwc" ] ; then
    	echo $val > $path_dwc
    fi
    
    exit 0
    close and save (in your home directory) calling it
    Code:
    vm_dirty_writeback
    Run a terminal (applications>accessories) and paste the following lines one at a time pressing return after each one
    Code:
    chmod 755 vm_dirty_writeback
    sudo su
    install vm_dirty_writeback /usr/lib/pm-utils/power.d/
    exit
    you WILL be asked for your password, just type it in and press return.

    Scheduling policy powersave
    This is managed by a default script that comes with Karmic.

    Usb auto suspend
    This is a key issue for failure of power saving in Linux.
    Run gedit (applications>accessories) and paste the following text in the empty document
    Code:
    #!/bin/bash
    if [ "$1" = "true" ]; then
    
      for i in /sys/bus/usb/devices/*/power/level; do
    	[ "$(cat $i)" = "auto" ] && continue
    	echo "auto" > $i
      done
    
      for i in /sys/bus/usb/devices/*/power/autosuspend; do
    	[ "$(cat $i)" -ge 0 2>/dev/null ] && continue
    	echo "2" > $i
      done
    
    fi
    close and save (in your home directory) calling it
    Code:
    usb_autosuspend
    Run a terminal (applications>accessories) and paste the following lines one at a time pressing return after each one
    Code:
    chmod 755 usb_autosuspend
    sudo su
    install usb_autosuspend /usr/lib/pm-utils/power.d/
    exit
    you WILL be asked for your password, just type it in and press return.

    When starting the notebook with AC on this script doesn't do anything, it is automatically run when going from AC to Battery and it sets usb to autosuspend after 2 secs. NOTE that this could turn off some old usb devices plugged to the computer. To avoid any problem (and save the most battery) DON'T leave usb devices plugged when going from AC to Battery, even better, don't use usb devices when running on battery at all. When using AC there is absolutely no problems at all.

    Intel HD audio
    Karmic has finally added a line to alsa configuration files that turn off the card after few second of inactivity. HDA cards can be named Intel, Nvidia, Ati and others but all should have this power saving active.

    Intel wireless cards
    Since kernel 2.6.30 the behavior of such cards has changed, there is no possibility of tuning the power consumption.

    Results
    Running the powertop program
    Code:
    sudo powertop -d -t 60
    these are my results after unplugging the cable
    Cn permanenza media
    C0 (cpu occupata) ( 0,7%)
    C0 0,0 ms ( 0,0%)
    C1 halt 0,0 ms ( 0,0%)
    C2 0,2 ms ( 0,0%)
    C3 28,4 ms (99,3%)

    P-state (frequenze)
    1,67 Ghz 0,6%
    1333 Mhz 0,0%
    1000 Mhz 99,4%

    Wakeup-da-idle al secondo: 35,5 intervallo: 60,0s
    Utilizzo energetico (stima ACPI): 11,3W (1,9 ore)

    Cause principali di wakeup:
    27,2% ( 12,6) <interrupt> : iwl3945
    22,2% ( 10,3) <core del kernel> : hrtimer_start_range_ns (tick_sched_timer)
    16,0% ( 7,4) <IPI kernel> : Rescheduling interrupts
    6,4% ( 3,0) <interrupt> : acpi
    4,4% ( 2,0) <core del kernel> : hrtimer_start (tick_sched_timer)
    4,2% ( 1,9) gnome-terminal : hrtimer_start_range_ns (hrtimer_wakeup)
    3,0% ( 1,4) <interrupt> : uhci_hcd:usb2, i915
    2,1% ( 1,0) python : hrtimer_start_range_ns (hrtimer_wakeup)

    Suggestion: Enable laptop-mode by executing the following command:
    echo 5 > /proc/sys/vm/laptop_mode
    The program is still suggesting me to run laptop-mode which is another way to handle the hard drive (and other variables) but I still prefer to avoid it as it's not recommended by Ubuntu.

    Known issues & things to do
    - The guide could be simplified, creating a package for the scripts but I don't know how to do it.

    - The "link pm..." script on some notebooks runs fine but doesn't change the sys value. Let me know if that's your case.

    ------------------------------------------------------------------------------------
    Version 0.25 typo correction and bug inserted
    Version 0.2 chmod commands were incorrect
    Version 0.1 first post

    Special thanks to:
    Scragar related discussion
    Sdennie related post
    Last edited by Axx83; November 29th, 2009 at 12:53 PM.

  2. #2
    Join Date
    Nov 2006
    Location
    Germany
    Beans
    244
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: The simple & effective power management guide (how to save battery power)

    I'm just replying to see if someone has tested the script and can help me improve it. Thanks

  3. #3
    Join Date
    Nov 2009
    Location
    Damascus
    Beans
    225
    Distro
    Kubuntu

    Re: The simple & effective power management guide (how to save battery power)

    OMG !! this is so hard for me

  4. #4
    Join Date
    Nov 2006
    Location
    Germany
    Beans
    244
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: The simple & effective power management guide (how to save battery power)

    please tell me what part you found not clear, I'm sure there's a lot of room for improvement, especially to make it easy and quick to install.

  5. #5
    Join Date
    Apr 2005
    Location
    Singapore
    Beans
    69
    Distro
    Ubuntu

    Re: The simple & effective power management guide (how to save battery power)

    @Axx83:
    How much did your battery life improve?
    With my extended battery on my Lenovo x60s I get ~8 hours per battery charge and only 3 hours in Ubuntu Linux.

    Grazie!

  6. #6
    Join Date
    Nov 2006
    Location
    Germany
    Beans
    244
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: The simple & effective power management guide (how to save battery power)

    Now I have the 3 cell standard battery on my x60s, it doesn't last very long on Ubuntu or Windows, probably in windows I get +15 minutes with all the settings of lenovo power manager to the minimum. Now i can get circa 2 hours on linux.

    The problem is that before these tweaks the computer on Ubuntu did not last more than 55 minutes, which was ridiculous.

    The big problem here is the battery:
    Actual charge: 22,6 Wh
    Last full charge: 27,1 Wh
    Factory charge: 28,8 Wh

    As you can see even of the original max charge is well below a crappy eeepc standard battery. Can't get much more our of this pc...

    But if you have the extended I'm sure it's just a matter of some components not going in to save mode, try installing this guide and let me know.

  7. #7
    Join Date
    Apr 2005
    Location
    Singapore
    Beans
    69
    Distro
    Ubuntu

    Re: The simple & effective power management guide (how to save battery power)

    Thanks for the quick reply.

    I will definitely try. Maybe the culprit was also the fast & hot Hitachi hard disk that I have now substituted with an Intel SSD

    How are the idle temperatures in your laptop? In Ubuntu my CPU was usually hitting 50-55 degrees Celsius.

    Bye.

  8. #8
    Join Date
    Nov 2006
    Location
    Germany
    Beans
    244
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: The simple & effective power management guide (how to save battery power)

    Well if you switched to ssd it's a good idea to install from scratch with ext4 partition, I'm sure you will save a good amount of energy.

    The temperatures were never above 60c, I checked them with the tpfan program, but anyway the cpu is low voltage, it rarely gets heated

  9. #9
    Join Date
    Dec 2005
    Location
    Western Australia
    Beans
    11,480
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: The simple & effective power management guide (how to save battery power)

    I think "vm" in this instance stands for "Virtual Memory", not "Virtual Machine". Just a small correction.

    I might give this a try on my netbook. If I do, then I'll be sure to create a Debian package around it for you.
    Last edited by 3rdalbum; November 22nd, 2009 at 12:53 PM.
    I try to treat the cause, not the symptom. I avoid the terminal in instructions, unless it's easier or necessary. My instructions will work within the Ubuntu system, instead of breaking or subverting it. Those are the three guarantees to the helpee.

  10. #10
    Join Date
    Apr 2009
    Location
    Costa Rica
    Beans
    255
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: The simple & effective power management guide (how to save battery power)

    Just installed, My power consumption is at 12.1W, a lot less than before, thank you. A little recommendation though. If you have to install everything in the same exact place, why not make a SINGLE script instead of separate ones?
    Linux User#498977
    There are only 10 types of people in the world. Those who understand binary, and those who dont.
    My Blog about Linux and other stuff

Page 1 of 4 123 ... LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •