Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm on a Compaq 615 and it's fan is loud. Not much you can do about that but I'm trying to keep the CPU/GPU as cool as possible. This is what Powertop has to say:

PowerTOP 1.97 - Overview - Idle stats - Frequency stats - Device stats - Tunables

If I change all of them to "good", the changes don't survive a reboot.

I added the line to the "grub"-file as suggested here

How do I make the Powertop suggested "Tunables" permanent?

share|improve this question
    
You're not editing the file correctly. You probably either messed up the path or forgot you need to use sudo to edit the file. –  Chan-Ho Suh Jun 8 '12 at 9:04
1  
Just my two cents: after disabling what powertop said was bad for battery life, I found myself in a stage where I could not plug any USB device cause it wouldn't be recognised. I had to manually load the modules into kernel and later plug in the device. Leaving "USB Controllers" options turned 'bad' made it work as expected. –  Pedro Brito Dec 2 '12 at 14:05
    
askubuntu.com/questions/285434/… –  Qasim Jun 14 '13 at 14:40
    
First check whether each suggested Tunable is really saving power. Note #2: the measurements from powertop might not be accurate due to internal battery re-calibrations. Source: askubuntu.com/questions/161774/… –  Pro Backup Sep 1 at 11:43

8 Answers 8

Here's how you can make the changes permanent:

sudo powertop --html

This will generate a powertop-xxxxxxxxxx-xxxxxx.html file.

Now either open that up in the browser and copy the echo commands from "... in need of Tuning" to /etc/rc.local.

Or extract the commands using something like this:

echo "grep 'echo ' powertop-20120805-125538.html | sed 's/.*\(echo.*\);.*/\1/g'"

If rc.local contains exit 0 you need to make sure to put the commands before this line.

share|improve this answer
1  
Eliah, I am running Powertop 2.0 which I compiled. I have run the --html command and can't find where it's depositing the file, or even if it's writing it. Also when Powertop starts I get this message: Cannot load from file /var/cache/powertop/saved_parameters.powertop –  Kendor Aug 11 '12 at 21:05
    
Tried this approach, but my powertop file (@Kendor - it gets saved in the same directory you were in) doesn't contain any echo (or other) commands. –  kermit666 Aug 26 '12 at 16:08
    
@kermit666 you will only have "echo" in there if there's actually things to change. so if you have applied the settings in powertop already you need to undo that first. maybe just to reboot would be easier –  pumpupthevolume Sep 22 '12 at 8:38
    
Gee, why is that so f**** complicated? If powertop would just output a script if I want that! Your solution ignores that the greater than > is written as > within the html output... –  Zordid Apr 18 at 9:32
    
Put the output into a file, then search and replace. In vi :%s/>/>/g –  bebbo Sep 30 at 20:14

You need to download and compile it because no one have the latest version

Download powertop https://01.org/powertop/downloads/2013/powertop-v2.3

powertop-2.3.tar.gz < < < Click & Download Me

Before compiling you need to install dependencies

Installing Dependencies ( Just copy paste the following commands )

sudo apt-get install libtool autoconf libnl-dev ncurses-dev pciutils-dev build-essential -y

Installing Powertop

To build and install PowerTOP type the following commands,

cd Downloads/powertop*  # assuming that you have downloaded in Downloads folder in you home directory   
configure 
make        # use -j option if you want to see details below
make install

You can also use -j2 for how many cores you want to use in ./make.Replace -j2 with whatever number of CPU cores you want to use for the compilation process. for example i have used ./make -j8

Powertop is installed you can unplugged ac power and can run

sudo powertop

However, most of the settings are not saved and they are lost after a reboot. You, can, however, make them permanent, by using the commands provided in the PowerTOP html report. To generate an HTML report, run the following command: webupd8.org

sudo powertop --html=powertop.html

Implementing Powertop Suggestion On Battery And Back To Maximize Performance On Ac Power

For that you need to make a script that run powertop suggestion on battery and maximize the performance on ac power

Place it in /etc/pm/power.d/ and give execution rights

sudo gedit /etc/pm/power.d/power

Copy paste the following the following in power file

 #!/bin/sh

 # Shell script to reduce energy consumption when running battery. Place
 # it in /etc/pm/power.d/ and give execution rights.

 if on_ac_power; then

 # Start AC powered settings --------------------------------------------#


 # Disable laptop mode
 echo 0 > /proc/sys/vm/laptop_mode

 #NMI watchdog should be turned on
 for foo in /proc/sys/kernel/nmi_watchdog;
 do echo 1 > $foo;
 done

 # Set SATA channel: max performance
 for foo in /sys/class/scsi_host/host*/link_power_management_policy;
 do echo max_performance > $foo;
 done

 # CPU Governor: Performance
 for foo in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor;
 do echo performance > $foo;
 done 

 # Disable USB autosuspend
 for foo in /sys/bus/usb/devices/*/power/level;
 do echo on > $foo;
 done

 # Disable PCI autosuspend
 for foo in /sys/bus/pci/devices/*/power/control;
 do echo on > $foo;
 done

 # Disabile audio_card power saving
 echo 0 > /sys/module/snd_hda_intel/parameters/power_save_controller
 echo 0 > /sys/module/snd_hda_intel/parameters/power_save

 # End AC powered settings ----------------------------------------------#

 else

 # Start battery powered settings ---------------------------------------#

 # Enable Laptop-Mode disk writing
 echo 5 > /proc/sys/vm/laptop_mode

 #NMI watchdog should be turned on
 for foo in /proc/sys/kernel/nmi_watchdog;
 do echo 0 > $foo;
 done

 # Set SATA channel to power saving
 for foo in /sys/class/scsi_host/host*/link_power_management_policy;
 do echo min_power > $foo;
 done

 # Select Ondemand CPU Governor
 for foo in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor;
 do echo ondemand > $foo;
 done

 # Activate USB autosuspend
 for foo in /sys/bus/usb/devices/*/power/level;
 do echo auto > $foo;
 done

 # Activate PCI autosuspend
 for foo in /sys/bus/pci/devices/*/power/control;
 do echo auto > $foo;
 done

 # Activate audio card power saving
 # (sounds shorter than 5 seconds will not be played)
 echo 5 > /sys/module/snd_hda_intel/parameters/power_save
 echo 1 > /sys/module/snd_hda_intel/parameters/power_save_controller

 # End battery powered settings -----------------------------------------#

 fi

Now you need to assign execution permission of power script

 sudo chmod +x /etc/pm/power.d/power

Now when you Unplugged, Powertop suggestion will take over and maximize the battery life & you Plugged in AC power you will have Max Performance.

Helpfull Links

http://ubuntuforums.org/showthread.php?t=1855126&page=3 http://www.webupd8.org/2012/08/install-powertop-21-in-ubuntu-1204.html

For -j Option http://dnscrypt.org/

share|improve this answer
1  
Instead I suggest you use checkinstall. It will also let you create a .deb package which you can uninstall/upgrade later You can install it with sudo apt-get install –  GuySoft May 27 '13 at 13:27
    
bash: ./make: No such file or directory - Why is this so? pastebin.com/bX3iLygx –  Tracy Iquiña Jun 22 '13 at 11:48
    
@TracyIquiña sorry its ... sudo make not ./make..... –  Qasim Jun 22 '13 at 12:28
1  
@Qasim I realized that mistake yesterday, (and read your comment just now) so I did make and sudo checkinstall. It worked as expected. The README file needs corrections on that one. –  Tracy Iquiña Jul 23 '13 at 17:32
    
@TracyIquiña thats g8 also please have a look at my answer askubuntu.com/questions/285434/… –  Qasim Jul 24 '13 at 15:08

It's not the answer you're asking for, but you can try running in laptop-mode. To do this:

open a terminal and type:

gksu gedit /etc/default/acpi-support

enter password and then go to the bottom and in the section where it talks about laptop-mode write true instead of false, close document and save of course

Then enter:

gksu gedit /etc/laptop-mode/laptop-mode.conf

this file is a bit longer, but here is how I edited mine. I added # before the default line on those line I modified, like this:

#
# Should laptop mode tools add the "noatime" option to the mount options when 
# laptop mode is enabled?
#
#CONTROL_NOATIME=0
CONTROL_NOATIME=1

the default was 0 and I turned it to 1, modify only the lines I modified. There are a few options in here you'll want to review and toggle as you see fit. When you're close and save.

After this is done you will want to type:

gksu gedit

now in the text editor click open and go into /etc/laptop-mode/conf.d/ folder, there are various files, you probably are interested in usb autosuspend, hda audio, iwl intel wireless, intel sata and sched mc powersaving. Open these files one by one and read them, they're written in a perfect standard english and explain everything very well. You will know what to do, remember that 0 stands for off and 1 for on most of the time.

When you're done close and save each file.

Now restart and admire laptop-mode in action, then:

sudo powertop

and examine power consumption, if you've done everything correctly powertop won't have any addition suggestion to make because you've tweaked all there is to tweak (more or less).

Source: http://ubuntuforums.org/showthread.php?t=1157408&p=7271995#post7271995 (by Axx83)

share|improve this answer
    
Thanks. But there's no way to just make the Powertop changes permanent? –  arno Mar 13 '12 at 20:45
    
I did a search on the subject and the best solution I could find (off site) was to enable laptop-mode. It is a workaround - if I find a better solution I will add it as well. Hopefully this can help for the time being. –  rlemon Mar 13 '12 at 21:46
2  
In acpi-support file it says this about laptop-mode:"# Note: to enable "laptop mode" (to spin down your hard drive for longer # periods of time), install the laptop-mode-tools package and configure # it in /etc/laptop-mode/laptop-mode.conf." I installed the package and opened the file. I assume that I'm now in laptop-mode? It says that "laptop-mode-tools" is enabled. I also made the other change you suggested (noatime). –  arno Mar 14 '12 at 10:02
    
ohh that was a example for editing the file. you will want to review the function of each option and toggle as you see fit. laptop mode should choak down your fan though. –  rlemon Mar 14 '12 at 12:59

I solved this by creating a dash script /root/power_save.sh:

#!/bin/dash
find /sys/devices/pci* -path "*power/control" -exec bash -c "echo auto > '{}'" \;

Set it as executable:

sudo chmod u+x /root/power_save.sh

And add it to root crontab with sudo crontab -e:

@reboot /root/power_save.sh
share|improve this answer
    
@dago Here is how I implemented solutions in your answer. –  Seppo Erviälä Jun 22 '11 at 20:23
    
Some questions, hoping to educate me: First, why dash not bash, difference? What is the advantage to put in /root/power.sh? CRON is another version of an terminal? Does your solution ask for password? –  dago Jun 22 '11 at 20:29
    
dash is another shell which is used in Ubuntu for running all the startup scripts because it starts faster than bash. See wiki.ubuntu.com/DashAsBinSh for more info. –  Seppo Erviälä Jun 22 '11 at 20:40
    
cron is tool for creating timed tasks (eg. run this script every n hour). It can also be used for running scripts when system is is started. –  Seppo Erviälä Jun 22 '11 at 20:41
    
This doesn't require password. –  Seppo Erviälä Jun 22 '11 at 20:41

This link talks about the same is talking about the same issue:

https://bbs.archlinux.org/viewtopic.php?pid=860406

I am interested in the solution by myself and will try later. Tell me If you can manage to implement this solution.

I couldnt get it running as the system always told me permission denied to run the executable file.

However this seems to work:

http://philatwarrimoo.blogspot.com/2011/06/powertop-howto-enable-device-power.html

I used the short command and run it with sudo.

As a semi automatic solution I created a launcher:

enter image description here

the script is as follows:

enter image description here

Is there a way to prevent asking for my password?

share|improve this answer
    
@dago - the reason why the "permission denied" errors is because you need to run "chmod +x setauto.sh" i.e. make the script that does the filtering executable. –  fossfreedom Jun 22 '11 at 19:19
1  
@dago - also, tie the solution into a script and use this solution to get the script to run automatically rather than manually - askubuntu.com/questions/9806/… –  fossfreedom Jun 22 '11 at 19:20
    
Understood the first remark. However the second approach seems easier to me. I tried to execute tis command via launcher by putting xterm -e upfront. It asks me for my password but actually doesn't work. Can you help me? It would like to run it semi manually as I only need it when on battery. –  dago Jun 22 '11 at 19:40
    
@dago - suggest create a desktop file and run your script with gksudo. If in doubt - tidy up your answer with a copy and paste of the code from philatwarrimoo describing your new script file and I'll edit your answer with a suggested newfile.desktop file that you can launch from the natty launcher –  fossfreedom Jun 22 '11 at 20:02
    
Did as recommended. Loosing the choosen symbol when adding the launcher icon to the launcher. –  dago Jun 22 '11 at 20:16

If you change all of them to good anyway, you could simply use the command

sudo powertop --auto-tune

To call this automatically at boot time, add this line at the end to /etc/rc.local

powertop --auto-tune
exit 0

Note: if the script already contains exit 0 be sure you place all commands before that line, cause that exits the script

If you want to set all to good but one line you could first auto-tune and then disable one setting with an extra line, for example, if you want to re-enable the touchscreen-device (at usb 2-7), add this before the exit 0:

powertop --auto-tune
echo 'on' > '/sys/bus/usb/devices/2-7/power/control'
exit 0
share|improve this answer
    
I noticed, that disabling the WiFi connection saves even more energy. Even with the power_save option set the WiFi card still uses around 4 W on my system if active –  rubo77 Jul 1 at 16:37

I've been having a similar problem and after reading a question on this site found out that the program "powertop" is, apparently, more suited to developers.

How do I install powertop 1.13?

The version, more useful, for users is "powertop-1.13" found in the repositories. It shows power saving suggestions as well as the command that it uses to carry out the suggestion.

This Red Hat Docs site has further instructions for making these changes permanent.

Specifically:

To help you make the changes permanent, PowerTOP displays the exact command it runs to perform this optimization. Add the command to your /etc/rc.local file with your preferred text editor so that it takes effect every time that the computer starts.

Good luck!

share|improve this answer

Use udev rules for permanent power savings configure settings directly at the source, instead of creating scripts or relying on possible not installed packages. Thus as soon as hardware gets added by udev your settings are applied.

A correct udev rule makes the settings not apply when the hardware is not there, thus making the configuration more portable. And you learn more about the inner workings of your Linux kernel :-). The configuration made this way, do also apply when not running on battery.

An example for tunable Enable SATA link power Managmenet for host0. The suggestion is to:

# echo 'min_power' > '/sys/class/scsi_host/host0/link_power_management_policy'`

This already gives you an idea where the hardware is: in /sys/class/scsi_host. You can verify this with:

# udevadm info -a -p /sys/class/scsi_host/host?
…
  looking at device '/devices/pci0000:00/0000:00:1f.2/ata1/host0/scsi_host/host0':
    KERNEL=="host0"
    SUBSYSTEM=="scsi_host"
…
    ATTR{eh_deadline}=="0"
    ATTR{link_power_management_policy}=="max_performance"
    ATTR{host_busy}=="0"

Better not touch the system udev rules in /lib/udev/rules.d/ and create your own udev rule file roughly at level 60 in /etc/udev/rules.d/. For example with the nano editor:

$ nano /etc/udev/rules.d/60-power.rules

Some other examples write rules like:

KERNEL=="host[0-5]", SUBSYSTEM=="scsi_host", ATTR{link_power_management_policy}="min_power"

I would say don't and make your rule even better by only applying it when the link power management policy is set to max_performance. Have a look at the little difference (look for the double equation sign):

KERNEL=="host[0-5]", SUBSYSTEM=="scsi_host", ATTR{link_power_management_policy}=="max_performance", ATTR{link_power_management_policy}="min_power"

Test you rule with udevadm test /devices/…:

# udevadm test /devices/pci0000:00/0000:00:1f.2/ata1/host0/scsi_host/host0/link_power_management_policy
calling: test
version 204
This program is for debugging only, it does not run any program
specified by a RUN key. It may show incorrect results, because
some values may be different, or not available at a simulation run.

=== trie on-disk ===
tool version:          204
file size:         5660180 bytes
header size             80 bytes
strings            1265196 bytes
nodes              4394904 bytes
load module index
read rules file: /lib/udev/rules.d/40-crda.rules
read rules file: /lib/udev/rules.d/40-gnupg.rules
read rules file: /lib/udev/rules.d/40-hyperv-hotadd.rules
read rules file: /lib/udev/rules.d/42-usb-hid-pm.rules
read rules file: /lib/udev/rules.d/50-firmware.rules
read rules file: /lib/udev/rules.d/50-udev-default.rules
read rules file: /lib/udev/rules.d/55-dm.rules
read rules file: /lib/udev/rules.d/60-cdrom_id.rules
read rules file: /lib/udev/rules.d/60-keyboard.rules
read rules file: /lib/udev/rules.d/60-persistent-alsa.rules
read rules file: /lib/udev/rules.d/60-persistent-input.rules
read rules file: /lib/udev/rules.d/60-persistent-serial.rules
read rules file: /lib/udev/rules.d/60-persistent-storage-dm.rules
read rules file: /lib/udev/rules.d/60-persistent-storage-tape.rules
read rules file: /lib/udev/rules.d/60-persistent-storage.rules
read rules file: /lib/udev/rules.d/60-persistent-v4l.rules
read rules file: /etc/udev/rules.d/60-power.rules
read rules file: /lib/udev/rules.d/61-accelerometer.rules
read rules file: /lib/udev/rules.d/64-btrfs.rules
read rules file: /etc/udev/rules.d/70-persistent-net.rules
read rules file: /lib/udev/rules.d/70-power-switch.rules
read rules file: /lib/udev/rules.d/70-uaccess.rules
read rules file: /lib/udev/rules.d/71-biosdevname.rules
read rules file: /lib/udev/rules.d/71-seat.rules
read rules file: /lib/udev/rules.d/73-idrac.rules
read rules file: /lib/udev/rules.d/73-seat-late.rules
read rules file: /lib/udev/rules.d/75-net-description.rules
read rules file: /lib/udev/rules.d/75-persistent-net-generator.rules
read rules file: /lib/udev/rules.d/75-probe_mtd.rules
read rules file: /lib/udev/rules.d/75-tty-description.rules
read rules file: /lib/udev/rules.d/78-graphics-card.rules
read rules file: /lib/udev/rules.d/78-sound-card.rules
read rules file: /lib/udev/rules.d/80-drivers.rules
read rules file: /lib/udev/rules.d/85-hdparm.rules
read rules file: /lib/udev/rules.d/85-keyboard-configuration.rules
read rules file: /lib/udev/rules.d/85-regulatory.rules
read rules file: /lib/udev/rules.d/95-udev-late.rules
rules contain 24576 bytes tokens (2048 * 12 bytes), 11335 bytes strings
1814 strings (22027 bytes), 1179 de-duplicated (11328 bytes), 636 trie nodes used
ATTR '/sys/devices/pci0000:00/0000:00:1f.2/ata1/host0/scsi_host/host0/link_power_management_policy' writing 'min_power' /etc/udev/rules.d/60-power.rules:1
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:1f.2/ata1/host0/scsi_host/host0
SUBSYSTEM=scsi_host
USEC_INITIALIZED=1203444595
unload module index

I can't find a way to apply the rule, so in this case I did a reboot to apply the newly created udev rule.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.