##(see the SpecSpec for an explanation) * '''Launchpad Entry''': https://launchpad.net/distros/ubuntu/+spec/reduced-power-usage * '''Created''': <> by CoreyBurger2 * '''Contributors''': CoreyBurger2 * '''Packages affected''': == Summary == Battery life is very dear to laptop users and thus we need to take a look at proactive ways to reduce power usage. This will involve profiling what is causing battery usage (screen, hdd hits, etc.) and working to reduce them. == Rationale == We want to increase usage of Ubuntu on laptops and help those existing users by making their experience better. == Use cases == * Jane is travelling on a plane from Cape Town to London and would like to be able to work on her document for as long as possible. With two batteries, she can almost make the entire flight, but not quite. * Alan works in the field and can only charge his laptop from generator, which only runs at night. During the day he works off a car battery, charged at night from the generator. He would like to be able to last the whole day on a single car battery. == Scope == * Any package in the default install which can cause excessive battery usage, such as accessing the harddrive, etc. == Design == * Profile a current install of Ubuntu to figure out what is using the battery * Tweak each program in turn to reduce power usage * Analyse disk profiles to set appropriate hdparm settings * PCMCIA deactivation == Implementation == *powertop* is a very good way to point out a lot of power draining programs. === Code === '''acpi scripts''' '''/etc/acpi/ac.d/10-vm_settings.sh''' {{{ #!/bin/bash # Tweak virtual memory for running on AC. echo 60 > /proc/sys/vm/swappiness echo 3000 > /proc/sys/vm/dirty_expire_centisecs echo 500 > /proc/sys/vm/dirty_writeback_centisecs echo 10 > /proc/sys/vm/dirty_background_ratio echo 40 > /proc/sys/vm/dirty_ratio}}} '''/etc/acpi/battery.d/10-vm_settings.sh''' {{{ #!/bin/bash # Tweak virtual memory to conserve power when running on batteries. echo 10 > /proc/sys/vm/swappiness echo 0 > /proc/sys/vm/dirty_expire_centisecs echo 0 > /proc/sys/vm/dirty_writeback_centisecs echo 60 > /proc/sys/vm/dirty_background_ratio echo 95 > /proc/sys/vm/dirty_ratio}}} (on feisty, something else is setting dirty_expire_centisecs/dirty_writeback_centisecs/dirty_background_ratio) '''/etc/acpi/ac.d/20-wireless_power.sh''' {{{ #!/bin/bash # Change the wireless power mode to AC. # This should work for most chipsets for x in $(/bin/ls -d /sys/class/net/*/wireless | /usr/bin/cut -d'/' -f5); do /sbin/iwconfig $x power off /sbin/iwpriv $x set_power 6 done}}} '''/etc/acpi/battery.d/20-wireless_power.sh''' {{{ #!/bin/bash # Change the wireless power mode to Battery. for x in $(/bin/ls -d /sys/class/net/*/wireless | /usr/bin/cut -d'/' -f5); do /sbin/iwconfig $x power on power period 2 power timeout 300u /sbin/iwpriv eth1 set_power 7 done}}} '''video card low power mode''' DavidP8 - For the open source ATI/radeon driver there is the xorg.conf driver option: {{{ Option "DynamicClocks" "on"}}} The following is a nasty hack for the fglrx driver. It sets the video card to low power mode on boot. https://help.ubuntu.com/community/BinaryDriverHowto/Fglrx_lowpower The need for this hack points to the usefulness there would be of an acpi event generated upon user login/display activation. (perhaps this event already exists). The event could then trigger an acpi script which sets the video card to low power mode. === Data preservation and migration === None === Comments === ''Where does laptop_mode fit into this ?'' - TormodVolden Reducing battery usage should really be addressed ASAP, but is not that easy: there are already some bugs filled against Ubuntu, acpi-support, powernowd stating battery life is reduced on Ubuntu (for me too). The sources of power consumption need a better testing scheme, so more information can be gathered. - NikolausFilus ''I don't see where scaling fits in here?'' - MrProper2 In the current release '7.04' there does not seem to be an easy way to configure cpu scaling. The only way i found to do cpu scaling properly is to write a script to see if the ac adapter is plugged in?: if [ -z "`grep 'off-line' /proc/acpi/ac_adapter/AC0/state`" ] I currently put that in a script and set my cpufreq governors based on the AC state and symlink it into /etc/acpi/*.d/99-scale-cpu.sh This gives a much better battery life (somewhere around the 50% more mark on a core 2 duo) NicolòChieffo: Please take care of these patches by Intel too!!! [[http://www.linuxpowertop.org/known.php|#patches-by-intel]] DavidP8 - The following are the scripts I use for CPU freq management (very noticeable battery life extension): MartijnVanDeStreek: Gnome Power Manager already handles CPU scaling governors while on battery. {{{ #!/bin/bash # Set CPU scaling / max freq to AC mode for x in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do echo "ondemand" > $x X=${x%/*} awk '{print $1}' $X/scaling_available_frequencies > $X/scaling_max_freq done}}} {{{ #!/bin/bash # Set CPU scaling / max freq to battery mode for x in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do echo "conservative" > $x X=${x%/*} # The second column is the second from the highest freq most power savings / least slowdown awk '{print $2}' $X/scaling_available_frequencies > $X/scaling_max_freq done}}} == Outstanding issues == == See also == *[[power-management-in-Ubuntu]] *[[MobileAndEmbedded/PowerPolicyManagement]] * http://www.lesswatts.org/ * http://phc.athousandnights.de/ Linux Processor Hardware Control is a patch for the Linux kernel that provides a userspace interface to control the core voltage of a computer processor(s). ---- CategorySpec