Power saving tips for Ubuntu on laptops

One of the things that Ubuntu (gutsy 7.10) and probably most versions of linux) are currently lacking is out of the box support for power saving and hence suffers from poor battery life when unplugged.

My HP nc8430 also runs particularly hot by default - but I've spent a bit of time hunting down tips for reducing the power usage and heat produced from the laptop to get a longer battery life. I'm sure there are a lot more ways that power can be saved and I suspect that future versions of Ubuntu will catch up and produce the same level of battery life or even longer than windows.

Here is what I am using so far:

Set powerplay mode on ATI fglrx driver

aticonfig --lsp # show current and available modes
aticonfig --set-powerstate=1 #set to low power mode

If anyone has equivalent code for other video cards please let me know and I'll add it here.

Disable 'hal' from polling your cdrom

From powertop: 'hal' is the component that auto-opens a window if you plug in a CD but disables SATA power saving from kicking in.

sudo hal-disable-polling --device /dev/scd0

Disable bluetooth if you are not using it

sudo hciconfig hci0 down
sudo rmmod hci_usb

Remove the usb 1.1 kernel driver if not using it

Apparently the usb 1.1 driver does frequent polling and prevents the processor from staying in low power states for any length of time.

sudo rmmod uhci_hcd

Increase the VM dirty writeback time

From powertop: This wakes the disk up less frequenty for background VM activity.

echo 1500 |sudo tee /proc/sys/vm/dirty_writeback_centisecs

Turn off second processor

This is a very extreme measure and I haven't measured how much extra battery life it gives - but it is a bit cool to be able to turn it on and off if you have a dual core or dual CPU machine.

echo 0 | sudo tee /sys/devices/system/cpu/cpu1/online
and to turn it back on use the following:
echo 1 | sudo tee /sys/devices/system/cpu/cpu1/online

How cool is that?

Let me know if you come across any more tips. Cheers, Mark

Updated 17/Mar/07: Fixed commands based on feedback from Neil. Thanks Neil.

Related Blog Entries

Comments
Too bad, none of these commands worked for me, i got "Cannot find storage device /dev/scd0", "ERROR: Module hci_usb does not exist in /proc/modules", "Can't get device info: No such device", etc
# Posted By Mike Henke | 3/11/08 1:42 AM
Hi Mike,

Sorry it didn't help much - did you have a look to see what device you cdrom is connected as? Try:

cat /etc/fstab

and look for a line that mentions cdrom, eg:
/dev/scd0 /media/cdrom0 udf,iso9660 user,noauto 0 0

/dev/scd0 might be something different on your machine.

Re the hci_usb - it probably means it's not loaded anyway - so nothing to save there. You can try the following command to check:

lsmod | grep hci

This will list all modules that have 'hci' in them. If it comes back empty then the module is not loaded.

Cheers,
Mark
# Posted By Mark Lynch | 3/11/08 2:17 AM
None of the examples like
sudo echo 1500 > /proc/sys/vm/dirty_writeback_centisecs
are correct

those echo as root but still try to write to file as the user

what you intend is done by

echo 1500 | sudo tee /proc/sys/vm/dirty_writeback_centisecs
# Posted By Neil | 3/17/08 9:21 AM
Hi Neil,

Thanks for that - I've updated the samples above - and learned something new.

With a bit of digging I also found that you can suppress the output of the commands to the screen by appending piping the standard output to /dev/null. So the command would be:

echo 0 | sudo tee /sys/devices/system/cpu/cpu1/online > /dev/null

Cheers,
Mark
# Posted By Mark Lynch | 3/17/08 10:39 AM
BlogCFC was created by Raymond Camden. This blog is running version 5.1.004.