You are not logged in.
I was a bit disappointed with the battery life of crunchbang out of the gate. I installed laptop-mode-tools but that did not do much. So I hacked together a little script that will enable some power saving tweaks when on battery power, and default to best performance while on AC. It should work on most setups, but YMMV. It is a good idea to check that the /sys/ entries actually exist on your system, and that the values are sane; Some are hardware specific for instance. We are going to take advantage of a pm-utils feature; any script placed in /etc/pm/power.d/ will automatically run when the AC power is connected or disconnected. Create and open /etc/pm/power.d/powersave, and copy the following script into it. Don't forget to make it executable. Note this part:
# List of modules to unload, space seperated. Edit depending on your hardware and preferences.
modlist="uvcvideo"
In modlist you can put a list of modules to automatically load and unload. The uvcvideo entry will disable most webcams. Remove this if you want to use your webcam on battery without having to sudo modprobe uvcvideo first.
"/etc/pm/power.d/powersave"
#!/bin/sh
# A script to enable laptop power saving features for #! & Debian GNU+linux.
# http://crunchbanglinux.org/forums/topic/11954
# List of modules to unload, space seperated. Edit depending on your hardware and preferences.
modlist="uvcvideo"
# Bus list for runtime pm. Probably shouldn't touch this.
buslist="pci spi i2c"
case "$1" in
true)
# Enable some power saving settings while on battery
# Enable laptop mode
echo 5 > /proc/sys/vm/laptop_mode
# Less VM disk activity. Suggested by powertop
echo 1500 > /proc/sys/vm/dirty_writeback_centisecs
# Intel power saving
echo Y > /sys/module/snd_hda_intel/parameters/power_save_controller
echo 1 > /sys/module/snd_hda_intel/parameters/power_save
# Set backlight brightness to 50%
echo 5 > /sys/devices/virtual/backlight/acpi_video0/brightness
# USB powersaving
for i in /sys/bus/usb/devices/*/power/autosuspend; do
echo 1 > $i
done
# SATA power saving
for i in /sys/class/scsi_host/host*/link_power_management_policy; do
echo min_power > $i
done
# Disable hardware modules to save power
for mod in $modlist; do
grep $mod /proc/modules >/dev/null || continue
modprobe -r $mod 2>/dev/null
done
# Enable runtime power management. Suggested by powertop.
for bus in $buslist; do
for i in /sys/bus/$bus/devices/*/power/control; do
echo auto > $i
done
done
;;
false)
#Return settings to default on AC power
echo 0 > /proc/sys/vm/laptop_mode
echo 500 > /proc/sys/vm/dirty_writeback_centisecs
echo N > /sys/module/snd_hda_intel/parameters/power_save_controller
echo 0 > /sys/module/snd_hda_intel/parameters/power_save
echo 10 > /sys/devices/virtual/backlight/acpi_video0/brightness
for i in /sys/bus/usb/devices/*/power/autosuspend; do
echo 2 > $i
done
for i in /sys/class/scsi_host/host*/link_power_management_policy
do echo max_performance > $i
done
for mod in $modlist; do
if ! lsmod | grep $mod; then
modprobe $mod 2>/dev/null
fi
done
for bus in $buslist; do
for i in /sys/bus/$bus/devices/*/power/control; do
echo on > $i
done
done
;;
esac
exit 0
To check that the script is running, and to see any errors run cat /var/log/pm-powersave.log
To save even more power check out this thread to enable undervolting. If you have Nvidia graphics check here for xorg.conf settings to save power.
After applying all these tweaks I have seen a healthy increase in battery life. Without the tweaks applied I would get 3:20 of wireless browsing. After applying tweaks I get 4:15.
If you find any hardware specific settings to add please leave a reply, it will help all #! laptop users.
Updated March 4rd, 2011
Running powertop always recommended "Enabling Runtime PM", but I could never find out what that did. Thanks to this thread on the Archlinux forums, I have been able to add it to this script.
Update #2 March 18th, 2011
Thanks to this reply we can save some more power. I simply copied the harddrive, journal_commit, and readahead scripts to my /etc/pm/power.d folder. You can add others if you want, but some duplicate the preceding script. The scripts I added replace laptop-mode-tools, which is deprecated. Thanks Jelloir!
Last edited by hardran3 (2011-03-22 16:21:48)
Offline
How much extra battery life are you getting with this?
Offline
Thanks for posting this, hardran3. I, too, have been disappointed with battery life in CrunchBang; Ubuntu Netbook Edition is noticeably better. I tried installing gnome-power-manager, which makes it a bit better, but your script looks to go much deeper. I'll try it on my Acer 1810TZ and report back.
Mac user with Linux tendencies
#!CrunchBang Waldorf & Ubuntu 13.04 on Acer 1810TZ (OCZ Vertex 2 128gb SSD)
Various linux virtual machines on a Mac mini, an iMac and a MacBook Air
Offline
If somebody tries it on a Toshiba laptop, please report back
Offline
I'm wondering how you run the script? You have to be root to execute it.
Or does laptop-tools make it run every time the power is unplugged?
Last edited by Tunafish (2011-03-04 09:51:32)
sed 's/stress/relaxation/g'
Privacy & Security on #!
Offline
I'm wondering how you run the script? You have to be root to execute it.
Or does laptop-tools make it run every time the power is unplugged?
Any script in /etc/pm/power.d/ gets ran every time the AC is plugged or unplugged. It is all automatic. if you want more info look into the pm-utils package.
If you want to make sure the settings are being applied, check some values while on AC, then pull the plug and check again.
cat /proc/sys/vm/dirty_writeback_centisecs
This should return 500 on AC and 1500 on battery. You can do the same thing for any of the values in the script.
Last edited by hardran3 (2011-03-04 19:03:02)
Offline
if i use gnome-power-manager do I need to disable it when using this?
failure is only a negative way to describe a learning experience.
i am constantly learning.
Offline
if i use gnome-power-manager do I need to disable it when using this?
I don't think so, but I am not 100% sure. Ubuntu sets all of its power saving settings the same way and uses gnome-power-manager so I think you should be OK. Let us know if it is working.
Offline
ok im using it now how can i check to make sure its executing correctly? where would i check for errors?
it does seem to have lowered cpu usage
Last edited by monkeybritt (2011-03-04 19:47:36)
failure is only a negative way to describe a learning experience.
i am constantly learning.
Offline
definitely should have read your answer to tunafish's question. lol
anyway seems to be working great
failure is only a negative way to describe a learning experience.
i am constantly learning.
Offline
If you want to make sure the settings are being applied, check some values while on AC, then pull the plug and check again.
cat /proc/sys/vm/dirty_writeback_centisecs
This should return 500 on AC and 1500 on battery. You can do the same thing for any of the values in the script.
I installed your script and according to /var/log/pm-powersave.log, the script is working.
However, cat /proc/sys/vm/dirty_writeback_centisecs returns a value of 60000, not 1500. What does that mean?
Mac user with Linux tendencies
#!CrunchBang Waldorf & Ubuntu 13.04 on Acer 1810TZ (OCZ Vertex 2 128gb SSD)
Various linux virtual machines on a Mac mini, an iMac and a MacBook Air
Offline
hardran3 wrote:If you want to make sure the settings are being applied, check some values while on AC, then pull the plug and check again.
cat /proc/sys/vm/dirty_writeback_centisecs
This should return 500 on AC and 1500 on battery. You can do the same thing for any of the values in the script.
I installed your script and according to /var/log/pm-powersave.log, the script is working.
However, cat /proc/sys/vm/dirty_writeback_centisecs returns a value of 60000, not 1500. What does that mean?
Something else on your system is setting the value after this script. If anything it will mean less disk writes.
Offline
@hardan3 (or anyone), I installed the package you mentioned, put this script in and +x'd it, and...though I'm on battery, /proc/sys/vm/dirty_writeback_centisecs is still 500. Also, my laptop lid, when shut, won't suspend the computer like it used to...
Any thoughts on what might be happening? I am running Statler on a Sony VAIO with a liquorix kernel (i believe---not sure how to check).
PS. The log shows the script is working correctly...at least everything returns success.
EDIT: I used the workaround found in the Ubuntu (gasp!) forums and suspend works now, at least. The workaround allows me to have laptop-mode-tools and pm-utils (which allows suspending) installed. I thought this might be helpful so it's here.
Last edited by mahatman2 (2011-03-06 06:26:59)
Punch all your friends.
Offline
Tunafish wrote:I'm wondering how you run the script? You have to be root to execute it.
Or does laptop-tools make it run every time the power is unplugged?
Any script in /etc/pm/power.d/ gets ran every time the AC is plugged or unplugged. It is all automatic. if you want more info look into the pm-utils package.
If you want to make sure the settings are being applied, check some values while on AC, then pull the plug and check again.
cat /proc/sys/vm/dirty_writeback_centisecs
This should return 500 on AC and 1500 on battery. You can do the same thing for any of the values in the script.
Thanks for your answer!
sed 's/stress/relaxation/g'
Privacy & Security on #!
Offline
@hardan3 (or anyone), I installed the package you mentioned, put this script in and +x'd it, and...though I'm on battery, /proc/sys/vm/dirty_writeback_centisecs is still 500. Also, my laptop lid, when shut, won't suspend the computer like it used to...
Any thoughts on what might be happening? I am running Statler on a Sony VAIO with a liquorix kernel (i believe---not sure how to check).
PS. The log shows the script is working correctly...at least everything returns success.
EDIT: I used the workaround found in the Ubuntu (gasp!) forums and suspend works now, at least. The workaround allows me to have laptop-mode-tools and pm-utils (which allows suspending) installed. I thought this might be helpful so it's here.
This shouldn't be necessary on crunchbang. On Ubuntu laptop mode tools and pm-utils are marked as conflicting, while on debian pm-utils is a recommend of laptop mode tools, they are designed to run together. The creators of laptop-mode-tools actually recommend installing the debian packages on Ubuntu. Glad to hear it is working for you anyways.
Offline
^ huh, that's really weird. maybe it's because i'm using testing repos? But when I reinstalled pm-utils it made me remove laptop-mode-tools (even though in synaptic there were no conflicts on the package details) and when I originally installed laptop-mode it made me remove something (don't remember what, but it must have been pm-utils)... oh well. Like you said, it works! So I don't question
Punch all your friends.
Offline
I am running Arch at present but felt I should post, since google bought me here and it may help you.
acpi is deprecated but laptop-mode-tools on Arch still needs the acpid daemon running to register changes in power state from battery to AC. I am not sure if this is the case for Debian Squeeze (perhaps someone can tell me).
I don't really like using deprecated software so went looking...
I un-installed apci completely including acpid and laptop-mode-tools
Then grabbed the latest pm-utils source and found a handful of scripts that can be placed in /etc/pm/power.d/ and made executable to provide various power saving options on battery power and restore those on AC. There is also some suspend stuff I haven't tried yet.
I just copied everything from pm-utils-1.4.1/pm/power.d/* to /etc/pm/power.d/ and made them executable and pulled the AC and checked powertop. Including manually setting the power for my Lenovo R500's Radeon Graphics to low, it was down to 15W from running at about 28W.... Excellent!
So I figure if I just write some extra scripts that laptop-mode-tools would otherwise have controlled, including one for power saving on the Radeon in my laptop (at last!!!) then i'll be equalling or bettering the power saving on Windows.
@mahatman2 - perhaps thats because laptop-mode-tools is now marked as a conflict with pm-utils due to scripts that might end up in /etc/pm/power.d/.... apt-cache show laptop-mode-tools should tell you.
Last edited by jelloir (2011-03-08 10:56:39)
Offline
@jelloir...that makes sense but it just doesn't show up...in fact laptop-mode-tools only conflicts with noflushd.
BUT::: I just checked pm-tools and that DOES conflict with laptop-mode-tools. So that must have been causing the problem and you're probably right as to why. Thanks for clearing that up!
Punch all your friends.
Offline
Script worked well on my EEE 1001pxd. I ended up lowering backlight brightness. I found your setting a bit to bright for my screen.
Went from around 5h30m to 6h40 min.
My watt usage went from the low 9's to the mid 8's
Thanks!
Offline
wow, this is great! I just did it and have been running my laptop with the screen brightness at 100% downloading lots of files and on the internet for 10 minutes and my battery is still at 100%!! it used to be that by now it would be at 95!
I love all of your hacks to make things better. I just added the liquorix kernel as well and now a couple of things work better than they did ever before. and faster I'm a slow typer so it's been about 20 minutes now and I'm still at 100!!
my battery, honestly has a longer battery life than in my windows 7 now.
thank you soooo much!!
registered Linux user: #533379
registered #! user: #6769
Whenever someone calls me a computer 'nerd' or a 'Unix-based-system'
all I can think is: You just wait. In a couple of years. I'll be your IT. Then where will you be!
Offline
my battery, honestly has a longer battery life than in my windows 7 now.
thank you soooo much!!
You are welcome. I am glad things have worked out so well for you!
Offline
Installed on my EEE PC 1000HE and it's working great.
Definitely a must-have tweak. Thanks a bunch!
Offline
I'm not getting *loads* of power saving - any advice what I'm doing wrong and how to fix?
silinz@stinkpad:~$ cat /var/log/pm-powersave.log
/usr/lib/pm-utils/power.d/anacron true:success.
/etc/pm/power.d/powersave true:/etc/pm/power.d/powersave: 66: cannot create /sys/bus/pci/devices/*/power/control: Directory nonexistent
/etc/pm/power.d/powersave: 66: cannot create /sys/bus/spi/devices/*/power/control: Directory nonexistent
/etc/pm/power.d/powersave: 66: cannot create /sys/bus/i2c/devices/*/power/control: Directory nonexistent
success.
/usr/lib/pm-utils/power.d/sched-powersave true:**sched policy powersave ON
success.
/usr/lib/pm-utils/power.d/anacron false:success.
/etc/pm/power.d/powersave false:/etc/pm/power.d/powersave: 66: cannot create /sys/bus/pci/devices/*/power/control: Directory nonexistent
/etc/pm/power.d/powersave: 66: cannot create /sys/bus/spi/devices/*/power/control: Directory nonexistent
/etc/pm/power.d/powersave: 66: cannot create /sys/bus/i2c/devices/*/power/control: Directory nonexistent
success.
/usr/lib/pm-utils/power.d/sched-powersave false:**sched policy powersave OFF
success.
Debian Wheezy on VeryPC Low Energy Desktop | Elementary on Lenovo Thinkpad SL510 | #! on Lenovo Ideapad S205 | Raspbmc on Pi | Linux Mint 17 XFCE on Lenovo W530.
Offline
I'm not getting *loads* of power saving - any advice what I'm doing wrong and how to fix?
Doesn't really look like anything is going wrong. There are three warnings for non-existent bus power saving options. You could change this (in the /etc/pm/power.d/powersave script)
# Bus list for runtime pm. Probably shouldn't touch this.
buslist="pci spi i2c"
to this
# Bus list for runtime pm. Probably shouldn't touch this.
buslist=""
to get rid of these warnings.
Tweaking power usage will vary from system to system. A good start is usually to google "$YOUR_PC_MODEL linux power saving" Someone may have done the work for you already. Using my script as a base you should be able to integrate things you find for your hardware.
Last edited by hardran3 (2011-04-03 18:07:14)
Offline
Many thanks I shall give this a go. I'm only getting just under 2 hours (with wireless on) at the mo. Which isn't too good for a Thinkpad!
Debian Wheezy on VeryPC Low Energy Desktop | Elementary on Lenovo Thinkpad SL510 | #! on Lenovo Ideapad S205 | Raspbmc on Pi | Linux Mint 17 XFCE on Lenovo W530.
Offline
Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.
Server: acrobat