![]() |
ubuntu.com - launchpad.net - ubuntu help
|
|
|||||||
Ubuntu 9.10 is out!!!
When downloading Ubuntu 9.10 please consider using bittorrent to get your copy of Ubuntu. The Ubuntu Developers Summit for Lucid Lynx will be held the week of 16-Nov-2009 till 20-Nov-2009 in Dallas, TX USA. Visit the the Ubuntu wiki for more information about UDS and how to participate remotely. |
|
Tutorials & Tips The place to find Ubuntu related Tips & Tricks. |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Ubuntu Café con Leche
![]() Join Date: Jan 2007
Location: Buenos Aires
Beans: 3,564
Ubuntu 8.04 Hardy Heron
|
HOWTO: Improve battery life on a laptop
By default Gutsy/Hardy is reasonable on laptop battery life but, with very little work, it's not difficult to dramatically increase battery life. Some of this information is from lesswatts.org or straight out of the powertop tool however, neither of them (that I've seen) give you a way to automate the switch between AC power and battery.
Essentially the idea is to create a script that plugs into the acpi system that should properly handle events like switching to/from battery as well as resuming from suspend. It's possible to do some of these things via the laptop-mode tool but, I prefer this method because it gives a more fine grained control over what settings you use. The basic script looks like this: Code:
#!/bin/bash if on_ac_power; then # Reset back to normal settings else # Turn on aggressive power savings fi Code:
#!/bin/bash if on_ac_power; then # Reset back to normal settings echo 0 > /proc/sys/vm/laptop_mode echo 10 > /proc/sys/vm/dirty_ratio echo 5 > /proc/sys/vm/dirty_background_ratio echo 500 > /proc/sys/vm/dirty_writeback_centisecs echo max_performance > /sys/class/scsi_host/host0/link_power_management_policy else # Turn on aggressive power savings echo 5 > /proc/sys/vm/laptop_mode echo 40 > /proc/sys/vm/dirty_ratio echo 10 > /proc/sys/vm/dirty_background_ratio echo 1500 > /proc/sys/vm/dirty_writeback_centisecs echo min_power > /sys/class/scsi_host/host0/link_power_management_policy fi For users of nvidia laptop cards, you can also save some power by adding Code:
Option "OnDemandVBlankInterrupts" "True" Code:
for x in /tmp/.X11-unix/*; do
displaynum=`echo $x | sed s#/tmp/.X11-unix/X##`
getXuser;
if [ x"$XAUTHORITY" != x"" ]; then
export DISPLAY=":$displaynum"
if on_ac_power; then
su $user -c "gconftool-2 --type boolean --set /apps/compiz/general/screen0/options/sync_to_vblank 1"
else
su $user -c "gconftool-2 --type boolean --set /apps/compiz/general/screen0/options/sync_to_vblank 0"
fi
fi
done
(Note: The compiz/nvidia solution doesn't work on Hardy. I'm working on a solution for it.) Finally, you'll need to install the script. You will want to name the script something like 99-save_power.sh and then to install it, you can use a command like this: For Hardy: Code:
$ sudo install 99-save_power.sh /etc/pm/power.d $ sudo install 99-save_power.sh /etc/pm/sleep.d Code:
$ sudo install 99-save_power.sh /etc/acpi/ac.d $ sudo install 99-save_power.sh /etc/acpi/battery.d $ sudo install 99-save_power.sh /etc/acpi/resume.d $ sudo install 99-save_power.sh /etc/acpi/start.d This should make the script run whenever you start the machine, resume it from suspend or plugin/unplug the power cable. The script(s) as written above may not save you huge amounts of power but, the idea is more to provide a general harness for adding power saving options and reverting those options when on AC power. Once you have the basic scripts in place, things like lesswatts.org or the powertop tool should be able to help guide you in further power savings. For a machine specific example of how I use this script on a Dell XPS m1330, see: http://ubuntuforums.org/showthread.php?t=847773 Last edited by sdennie; July 8th, 2008 at 04:58 AM.. Reason: More Hardy updates |
|
|
|
|
|
#2 |
|
A Carafe of Ubuntu
![]() Join Date: Feb 2007
Location: Gray, TN, USA
Beans: 144
Xubuntu 9.04 Jaunty Jackalope
|
Re: HOWTO: Improve battery life on a laptop
I've got a riddle for you -- a conundrum, if you will. What do you do when "on_ac_power" returns true no matter whether the laptop is plugged in or not? How does gnome-power-manager know whether the laptop is on battery or on AC? In other words, is there some sort of something in /proc or /dev that gnome-power-manager reads to know whether to display a battery or a plug in the tray? Is there something I could grep to determine whether my script should call either the fullBlast or the powerSave function, rather than calling on_ac_power, which is apparently lying?
__________________
Q: How many ADD kids does it take to screw in a lightbulb? A: Hey! Let's go ride bikes! |
|
|
|
|
|
#3 |
|
Ubuntu Café con Leche
![]() Join Date: Jan 2007
Location: Buenos Aires
Beans: 3,564
Ubuntu 8.04 Hardy Heron
|
Re: HOWTO: Improve battery life on a laptop
Actually, on_ac_power is just a script in /usr/bin that checks /proc/acpi/ac_adapter/state (or status). You could look at that as a start or you could probably do something like:
Code:
grep discharging /proc/acpi/battery/BAT0/state |
|
|
|
|
|
#4 |
|
A Carafe of Ubuntu
![]() Join Date: Dec 2007
Location: pacific northwest
Beans: 152
Ubuntu 9.10 Karmic Koala
|
Re: HOWTO: Improve battery life on a laptop
how would you install the above script for use by pm-utils in 8.04 hardy?
|
|
|
|
|
|
#5 |
|
Ubuntu Café con Leche
![]() Join Date: Jan 2007
Location: Buenos Aires
Beans: 3,564
Ubuntu 8.04 Hardy Heron
|
Re: HOWTO: Improve battery life on a laptop
Updated first post for pm-utils in Hardy.
__________________
Don't try to make something "fast" until you are able to quantify "slow". |
|
|
|
|
|
#6 |
|
A Carafe of Ubuntu
![]() Join Date: Dec 2007
Location: pacific northwest
Beans: 152
Ubuntu 9.10 Karmic Koala
|
Re: HOWTO: Improve battery life on a laptop
another question: how do these settings relate to/interact with what exists in /usr/lib/pm-utils/power.d/laptop-tools ? and also the ones in laptop-mode-tools if laptop-mode is enabled? it is all very confusing to have so many different places where a single parameter can be set, or perhaps be in conflict or be overridden...
|
|
|
|
|
|
#7 |
|
Ubuntu Café con Leche
![]() Join Date: Jan 2007
Location: Buenos Aires
Beans: 3,564
Ubuntu 8.04 Hardy Heron
|
Re: HOWTO: Improve battery life on a laptop
Yes, it's quite confusing and worse in Hardy with the inclusion of /usr/lib/pm-utils. However, one nice things is that all these ".d" directories should be looking at the numbers at the beginning of the filename and executing them in order so, "99-foo.sh" will get executed after "50-bar.sh". I think if you name your personal settings "99-whatever.sh", you can essentially override any other setting that has come before it.
__________________
Don't try to make something "fast" until you are able to quantify "slow". |
|
|
|
|
|
#8 |
|
5 Cups of Ubuntu
![]() Join Date: Nov 2005
Beans: 34
Ubuntu 6.06
|
I am using 8.04 x86-64 on a HP6715b with a Turion TL60. I know the processor supports C1E but I never see the processor in any state but C0.
Does anyone else see the "power management: yes" in the processor info? I would like to enable C1E in linux to improve battery life. :/proc/acpi/processor/C000$ more info processor id: 0 acpi id: 1 bus mastering control: yes power management: no throttling control: yes limit interface: yes :/proc/acpi/processor/C000$ more power active state: C0 max_cstate: C8 bus master activity: 00000000 maximum allowed latency: 8000 usec states: C1: type[C1] promotion[--] demotion[--] latency[000] usage[00000000] duration[00000000000000000000] thanks
__________________
windows @ work , Linux @ home AM2-X2 4200 GA-M61P-S3, 2GB, Samsung 906BW HP6715b laptop TL60, 2GB |
|
|
|
|
|
#9 |
|
Ubuntu Café con Leche
![]() Join Date: Jan 2007
Location: Buenos Aires
Beans: 3,564
Ubuntu 8.04 Hardy Heron
|
Re: HOWTO: Improve battery life on a laptop
smsmith050, I've never used an AMD CPU before. Have you used powertop to check the C and P states of the CPU? I'm not sure if it works with AMD CPUs but, it's possible that /proc/acpi is simply wrong and that powertop can give you more accurate information.
__________________
Don't try to make something "fast" until you are able to quantify "slow". |
|
|
|
|
|
#10 |
|
5 Cups of Ubuntu
![]() Join Date: Nov 2005
Beans: 34
Ubuntu 6.06
|
The Intel powertop app is not able to identify the AMD Turion.
For C1E not working I suspect something is wrong with the BIOS. C1E does work with windows.... I have the latest BIOS During C1E the hyper-transport link is stopped, the memory is in self-refresh, and the processor clocks are divided down. It saves a good amount of power. S PowerTOP version 1.9 (C) 2007 Intel Corporation P-states (frequencies) 2.00 Ghz 0.0% 1.80 Ghz 0.0% 1.60 Ghz 0.0% 800 Mhz 100.0% < Detailed C-state information is only available on Mobile CPUs (laptops) >
__________________
windows @ work , Linux @ home AM2-X2 4200 GA-M61P-S3, 2GB, Samsung 906BW HP6715b laptop TL60, 2GB |
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|