ÈÐ Wïgê† Ðð† ñåmê

ïñ£ð§ê¢, ïñ£ðrmå†ïðñ §ê¢µr, Ðïgï†ål £ðrêñ§ï¢§, hå¢kïñg, §¥§†êm åÐmïñ阮rå†ïðñ, lïñµx ßlðg


Over the years, I have tried various methods to get more life out of a laptop battery.  I generally always buy a higher capacity battery.  So my current laptop was getting about 3 hours out of a full charge and I was happy with that but lately it has dropped considerably…to about 1 hour.  Usually when I am on the road or away from home, I have my netbook which gets about 9 hours of actual battery time while working.  I wish I had a way to get that kind of battery time out of my full size laptop.

I started looking through old scripts I had from a couple years ago (I replace my laptops every two years), I found these scripts I use for management of power settings.  This has drastically increased the battery time, up to near 3 hours again.  So, I don’t know if some recent kernel update (that I did about two weeks ago) was what was killing battery time or not.

I use either kde or fluxbox and the way I do power management is in kde I use powerdevil.  In fluxbox, I simply runs these scripts manually.

The way I configure kde power savings is like this:

If you notice in the 4th and 5th images above, there are some scripts that get called.  Those scripts are below.  I use performance.sh which basically resets what I enabled, ondemand.sh I use in powersave mode, and then I use powersave.sh in Aggressive and Extreme power save modes.

[codesyntax lang=”bash” title=”performance.sh”]

#!/bin/bash

# set the cpu to performance governor
sudo sh -c "echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"
sudo sh -c "echo 2200000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq"
sudo sh -c "echo 2200000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq"

sudo sh -c "echo 0 > /proc/sys/vm/laptop_mode"
sudo sh -c "echo 10 > /proc/sys/vm/dirty_ratio"
sudo sh -c "echo 5 > /proc/sys/vm/dirty_background_ratio"
sudo sh -c "echo 500 > /proc/sys/vm/dirty_writeback_centisecs"

# reset drive
sudo sh -c "/sbin/hdparm -B 255 -S 24 /dev/sda"
sudo sh -c "/sbin/hdparm -B 255 -S 24 /dev/sdb"

# reset soundcard
sudo sh -c "echo 0 > /sys/module/snd_hda_intel/parameters/power_save"

# load the webcam driver
sudo modprobe uvcvideo

# reset hd
sudo sudo mount -o remount /

[/codesyntax]

[codesyntax lang=”bash” title=”ondemand.sh”]

#!/bin/bash

sudo sh -c "echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"
sudo sh -c "echo 2200000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq" 
sudo sh -c "echo 550000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq"

# Turn on aggressive power savings
  sudo sh -c "echo 1 > /sys/module/snd_hda_intel/parameters/power_save"
  sudo sh -c "echo 5 > /proc/sys/vm/laptop_mode"
  sudo sh -c "echo 40 > /proc/sys/vm/dirty_ratio"
  sudo sh -c "echo 10 > /proc/sys/vm/dirty_background_ratio"
  sudo sh -c "echo 1500 > /proc/sys/vm/dirty_writeback_centisecs"

  # Set the disks to aggressively save power.
  # Some might find these settings too aggressive.  If so, change
  # "-S 4" to something larger like -S 24 (two minutes) and -B 1 to -B 255.
  # -S 4 => put in standby after 20 seconds idle
  # -B 1 => highest degree of power savings
  # -M => not supported by my drive
  sudo sh -c "/sbin/hdparm -B 1 -S 12 /dev/sda"                                                                                                                                                                            
  sudo sh -c "/sbin/hdparm -B 1 -S 12 /dev/sdb"  

  sudo mount -o remount,relatime /  
  sudo ifconfig -v eth0 down

  # Set sound card power savings
  sudo sh -c "echo 10 > /sys/module/snd_hda_intel/parameters/power_save"

# remove the webcam driver
sudo modprobe -r uvcvideo

[/codesyntax]

[codesyntax lang=”bash” title=”powersave.sh”]

#!/bin/bash

# set cpu freq to powersave
sudo sh -c "echo powersave > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"
sudo sh -c "echo 550000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq" 
sudo sh -c "echo 550000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq" 

# Turn on aggressive power savings
  sudo sh -c "echo 1 > /sys/module/snd_hda_intel/parameters/power_save"
  sudo sh -c "echo 5 > /proc/sys/vm/laptop_mode"
  sudo sh -c "echo 40 > /proc/sys/vm/dirty_ratio"
  sudo sh -c "echo 10 > /proc/sys/vm/dirty_background_ratio"
  sudo sh -c "echo 1500 > /proc/sys/vm/dirty_writeback_centisecs"

  # Set the disks to aggressively save power.
  # Some might find these settings too aggressive.  If so, change
  # "-S 4" to something larger like -S 24 (two minutes) and -B 1 to -B 255.
  # -S 4 => put in standby after 20 seconds idle
  # -B 1 => highest degree of power savings
  # -M => not supported by my drive
  sudo sh -c "/sbin/hdparm -B 1 -S 12 /dev/sda"                                                                                                                                                                            
  sudo sh -c "/sbin/hdparm -B 1 -S 12 /dev/sdb"  

  sudo mount -o remount,relatime /  
  sudo ifconfig -v eth0 down

  # Set sound card power savings
  sudo sh -c "echo 10 > /sys/module/snd_hda_intel/parameters/power_save"

  # Remove the webcam driver                                                                                                                                                                               
  sudo modprobe -r uvcvideo

[/codesyntax]

 

Also, for the notes above, you can find the scaling frequencies of your cpu by using this command:

[codesyntax lang=”bash”]

$ sudo cat /sys/devices/system/cpu/*/cpufreq/scaling_available_frequencies
2200000 1100000 550000 
2200000 1100000 550000

[/codesyntax]

You can find out what it is currently set to by looking at:

[codesyntax lang=”bash”]

$ sudo cat /sys/devices/system/cpu/*/cpufreq/scaling_cur_freq
2200000
2200000

[/codesyntax]


Leave a Reply