Page 1 of 4 123 ... LastLast
Results 1 to 10 of 504

Thread: HowTo: Undervolt your notebook CPU for longer battery life

Hybrid View

  1. #1
    Join Date
    Jul 2006
    Location
    Tschörmany
    Beans
    111
    Distro
    Kubuntu 12.04 Precise Pangolin

    Red face HowTo: Undervolt your notebook CPU for longer battery life

    Edit: This Post is outdated! The underlying principles still apply, but newer Ubuntu versions requiere a slightly different approach.
    • Ubuntu 10.04 LTS
      A newer guide for Ubuntu 10.04 LTS Lucid Lynx can be found at: http://openmindedbrain.info/09/05/20...-04-lucid-lts/
    • Recent versions
      An even more recent guide for the most recent Versions of Ubuntu is linked here: http://linuxsolver.blogspot.com/2011...in-ubuntu.html. It offers a graphical utility to set the voltages for you, but only covers installation. Afterwards, you still have to find and test your individual voltages. Therefor you can use this method from the same author or the method in this post. Whitchever method you choose, be sure to read the short chapter on safety below. Especially important are points 3 and 4 and these still aply to all current and future methods.




    This howto is based on own experiences and this german wiki page, so thx to them.

    It is tested for intel Core2Duo and CoreDuo cpus. I have no clue if it works for AMD as well. Some answers I received suggest that it currently doesn't work with AMD cpus however.

    From wikipedia: Undervolting is the practice of reducing the supply voltage of a computer's CPU. There are many reasons to perform this sort of modification, but a common one is to reduce power consumption and thus heat generation in laptop computers. Lower heat generation provided by undervolting and underclocking is also helpful in making computers quieter.

    Performance will not suffer as the energy you will save was just wasted (as heat) before.


    Safety:

    Undervolting notebook processors is not uncommon. My older notebook (Toshiba S1) even came with a Windows utility that did automatic undervolting preinstalled. So the "undervolted" processor is nothing dangerous.

    The way to get there might be, if no care is taken.
    What might happen:
    1) The voltage controls stability and temperature. The higher the voltage the higher the temp, but without enough voltage the cpu wont be stable and your PC will lock up. In fact with the following procedure we are trying to find the minimum stable voltage to get the cpu as cool as possible. The energy saved will increase battery life as well.

    2) So if you were to INCREASE the voltage, you would rise the temperature. This might damage the cpu in case it got too hot - obvious one. (Though all Intel (probably AMD as well) mobile chips are equiped with safety cut off mechanisms afaik) However with the optimizer scipt it automatically REDUCES the voltage so harm to your hardware is very unlikely.

    3) To find the named "minimum" voltage, the optimizer scipt needs to test if the cpu runs stable at every voltage setting. So in case it gets too low, your notebook will lock up. Then afterwards the script knows what is too low and will stay safely above.
    That sth gets damaged by locking up is rather unlikely - overclocking my desktop machine in younger years I experienced it at least a hundred times and never fried anything.

    4) While locking up however your linux and all open applications crash as well. Wich might result in data loss. Be prepared to see the fsck utility at next boot up checking for data integrity. And let it run! Furthermore, don't open any files while running the optimizer script and, before doing this optimization, unmount as many partitions as possible to reduce the risk. (unmounted partitions cannot be corrupted during the lockup)

    Once the scipt finishes (you need to run it several times, once for every freqency your cpu is capable of), no more lock-ups are to be expected as the script now knows the individual critical voltage for your cpu and will stay savely above.

    With all these precautions I think it is rather save to undervolt.


    Still there? Then let's get on to it! Step by step:

    1. This howto depends on the kernel module acpi-cpufreq to control your cpu. To find out if you're using it try
    Code:
    lsmod | grep acpi_cpufreq
    You should see sth. like this:
    Code:
    acpi_cpufreq           14892  2 
    freq_table              5536  3 acpi_cpufreq,cpufreq_stats,cpufreq_ondemand
    processor              36872  4 acpi_cpufreq,thermal
    In case you don't see anything, you don't use acpi-cpufreq, but maybe the speedstep.centrino module. Then this howto is not for you unfortunately. speedstep.centrino is in theory supported as well, but I have no experience with it. If someone knows how to do it with speedstep.centrino please tell me and I will add it here.

    2. You need to get a modified version of your acpi_cpufreq module, one with PHC support build in. PHC means processor hardware control and is the magic that makes it going. There are several ways to get this module.

    a) You can download a patch on their website and compile it yourself. If you have never compiled anything, this is not for you as there are easier ways (see b) ). However as I hardly find the time to post updates here I will give a mini-howto for compilation here in case a kernel update breakes compatibility with old modules. You need to compile yourself in case you are running 64 bit as well as the precompiled modules I offer below are 32bit only.
    Mini-Howto for compilation
    Code:
    sudo apt-get install build-essential linux-source
    extract the tar from /usr/src to /home/"your-username"/"kernelversion"
    download latest patch to /home/"your-username"/"kernelversion"
    copy /boot/config-$(uname -r).config to /home/"your-username"/"kernelversion"
    Code:
    cd /home/"your-username"/"kernelversion"
    patch -p1 < linux-phc*.patch
    make oldconfig
    make prepare
    make scripts
    make M=./arch/x86/kernel/cpu/cpufreq
    The finished module should be in /home/"your-username"/"kernelversion"/arch/x86/kernel/cpu/cpufreq
    Proceed as if you had downloaded this module with copying it to the right place (see 2. c) ). After all is done you can savely remove the folder /home/"your-username"/"kernelversion" and uninstall linux-source to save harddisk space.

    b) Download a precompiled module. It has to match your kernel.

    1) First backup your old module.
    Code:
    sudo cp /lib/modules/`uname -r`/kernel/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.ko /lib/modules/`uname -r`/kernel/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.ko.old
    (basically copies it to a new name)

    2) There are right now versions for kernel 2.6.24-16-generic, 2.6.24-17-generic, 2.6.24-18-generic and 2.6.24-19-generic. To find out what kernel you have open a terminal and type:
    Code:
    uname -r
    So once you know, download the right kernel module for 2.6.24-16-generic or 2.6.24-17-generic or 2.6.24-18-generic or 2.6.24-19-generic.

    c) Then copy the downloaded file to the right place:
    Code:
    sudo cp acpi-cpufreq.ko /lib/modules/$(uname -r)/kernel/arch/x86/kernel/cpu/cpufreq
    You have to redo the entire Step 2 every time you update your kernel, so you might want to save your downloaded module file, as it might work again after a kernel upgrade, i.e. the version -16 worked with -14 and -15 as well, but not with -17.

    3. Reboot. If the module is installed correctly,
    Code:
    cat /sys/devices/system/cpu/cpu0/cpufreq/phc_controls
    should give you sth like this:
    Code:
    12:38 10:30 8:24 6:18
    The value before the : stands for the frequency, the later for the voltage.

    4.
    Okay, now we need to find the lowest save voltages. We will use this optimizer script.
    Download it (you will need this file as well), then right-click the files, open the permissions tab, and and down at the bottom check the box that says "allow executing the file....." Then run it from the terminal with
    Code:
    sudo ./linux-phc-optimize.bash
    It needs cpuburn installed, so you might want to install it in advance with synaptic. What this scipt does is: It stresses your cpu while lowering the cpu voltage step by step unil your system crashes. Then the script knows what is too low and will stay safely above. The script needs to run once for every frequency step your cpu is capable of, usually around 4-6 times. It will tell you, just run it so often until it tells you finished.
    IMPORTANT:
    This script will crash your system. Several times. This is normal and intended. No harm to your hardware is to be expected. However in case you have open files and / or mounted filesystems data loss or corruption might occur. So be advised to unmount as many partitions as possible and open as few files as necessary while doing this. After a reset the fsck utility will check your partitions for data corruption so be strongly advised to let that check run!

    Second, the script stresses only one cpu core. In case you have a dual core, open a terminal and type "burnMMX" to run a second thread to stress the second core while doing this.

    When you're finished with the script, you will have a text file with the new and optimized frequency : voltage pairs.

    5. To use these optimized values, you will need to echo them to /sys/devices/system/cpu/cpu0/cpufreq/phc_controls. An easy way to do it automatically every reboot is to add a line like this:
    Code:
    echo "12:21 10:1 8:1 6:1" > /sys/devices/system/cpu/cpu0/cpufreq/phc_controls
    to your /etc/rc.local file. Of course you have to replace the values with your own. Any second core should automatically use the same voltages.

    6.
    Check if it works:
    Code:
    cat /sys/devices/system/cpu/cpu0/cpufreq/phc_controls
    should now give you the new values (after a reboot) compared to before, see above.
    Last edited by Ares Drake; October 13th, 2011 at 12:13 PM. Reason: Update
    HowTo: Ask Questions the smart way | keep on rockin'...

    GEEK CODE Version: 3.1: GJ/MD d s a- C++ ULS++ P L+++ E---- W++ N* ?o K- w--- ?O M-- V-- PS+>$ PE++>$ Y+ PGP++ t-- 5- X R tv b+ ?DI D+ G++ e+++ h-- r++ y+

  2. #2
    Join Date
    May 2008
    Beans
    5

    Re: HowTo: Undervolt your notebook CPU for longer battery life

    Hi,

    Thanks for posting this how-to. I am a complete beginner in linux and know absolutely nothing, so its refreshing that someone has posted a tutorial thats easy to understand even for people like me(believe me, Ive been trying to get linux PHC to work for days).

    So I have a problem, when I use your command on Step 5, the terminal says "bash: echo: write error: Invalid argument".

    I tried using this command, "echo "20:18 20:18 20:18 20:18 12:11" > /sys/devices/system/cpu/cpu0/cpufreq/phc_controls" to replace my default(?) voltages, which were "11:47 10:39 8:29 6:18 136:11" on Step 3.

    I am running a Lenovo T61 with a Core 2 Duo T7300 (2 GHZ) on Ubuntu 8.04 64-bit.

    Thanks alot for your responses, this is a very great and helpful community!

    EDIT: I dont know why there are 5 of these settings for mine and you only have 4. I searched around and found a formula for the VID: Vcc = 712.5 + VID*12.5 Is this the right formula for the VID? I wanted to run my laptop at a constant 2 GHZ with .9375 volts.
    Last edited by w4ngsta07; May 11th, 2008 at 03:42 AM.

  3. #3
    Join Date
    May 2008
    Beans
    5

    Re: HowTo: Undervolt your notebook CPU for longer battery life

    Well ok, this is probably easy to answer. I cant run the linux-phc optimizer script. I downloaded it to my desktop. double clicking it does nothing, just runs the text editor, and terminal says 'command not found'

  4. #4
    Join Date
    Dec 2006
    Location
    Vietnam (U.S. expat)
    Beans
    134
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: HowTo: Undervolt your notebook CPU for longer battery life

    w4ngsta07:

    you need to make a script executable before you can run it.

    The easiest way is right-click the file, open the permissions tab, and and down at the bottom check the box that says "allow executing the file....."

    That should do it.

  5. #5
    Join Date
    Jul 2006
    Location
    Tschörmany
    Beans
    111
    Distro
    Kubuntu 12.04 Precise Pangolin

    Re: HowTo: Undervolt your notebook CPU for longer battery life

    Thanks for your hint, I added it to the howto.

    Quote Originally Posted by Harpoon View Post
    w4ngsta07:

    you need to make a script executable before you can run it.

    The easiest way is right-click the file, open the permissions tab, and and down at the bottom check the box that says "allow executing the file....."

    That should do it.
    HowTo: Ask Questions the smart way | keep on rockin'...

    GEEK CODE Version: 3.1: GJ/MD d s a- C++ ULS++ P L+++ E---- W++ N* ?o K- w--- ?O M-- V-- PS+>$ PE++>$ Y+ PGP++ t-- 5- X R tv b+ ?DI D+ G++ e+++ h-- r++ y+

  6. #6
    Join Date
    Apr 2007
    Beans
    1

    Question Re: HowTo: Undervolt your notebook CPU for longer battery life

    When I run phc optimize script, I get
    Code:
    ./linux-phc-optimize.bash: line 3: functions.bash: No such file or directory
    ERROR: Could not load functions.bash
    Where can I find functions.bash?
    Thanks

  7. #7
    Join Date
    Jul 2006
    Location
    Tschörmany
    Beans
    111
    Distro
    Kubuntu 12.04 Precise Pangolin

    Re: HowTo: Undervolt your notebook CPU for longer battery life

    Quote Originally Posted by w4ngsta07 View Post
    So I have a problem, when I use your command on Step 5, the terminal says "bash: echo: write error: Invalid argument".

    I tried using this command, "echo "20:18 20:18 20:18 20:18 12:11" > /sys/devices/system/cpu/cpu0/cpufreq/phc_controls" to replace my default(?) voltages, which were "11:47 10:39 8:29 6:18 136:11" on Step 3.
    You might try:
    Code:
    sudo -s
    -> password,
    then run your echo command again.

    But to be honest, I don't think it is an access problem to that file so it probably won't help. I think it is rather a problem with your value pairs.

    I don't know if it is possible to use PHC to keep your cpu constant at 2ghz. I for myself kept the first value for the frequency step and just changed the voltage for it after the :

    Try doing the same, you then can still lock your cpu frequency with other methods to 2ghz, i.e. there is a terminal command (wich I can't remember, but I read it in this forum) to change the access permissions of the panel cpu freq applet to let you control your cpu speed manually from there.
    HowTo: Ask Questions the smart way | keep on rockin'...

    GEEK CODE Version: 3.1: GJ/MD d s a- C++ ULS++ P L+++ E---- W++ N* ?o K- w--- ?O M-- V-- PS+>$ PE++>$ Y+ PGP++ t-- 5- X R tv b+ ?DI D+ G++ e+++ h-- r++ y+

  8. #8

    Re: HowTo: Undervolt your notebook CPU for longer battery life

    Very nice howto. I've moved it into Tutorials and Tips.
    Ubuntu user #7247 :: Linux user #409907
    inconsolation.wordpress.com

  9. #9
    Arthur Archnix is offline Grande Half-n-Half Cinnamon Ubuntu
    Join Date
    Aug 2007
    Beans
    Hidden!

    Re: HowTo: Undervolt your notebook CPU for longer battery life

    I got to the step where you run the script, and it wasn't clear if the script itself started burnMMX or not, so I opened up a new tab and typed "burnMMX". It's not clear to me that it's working or doing anything, it kinda just sits there.

    Anyway, then I ran the script and it counted all the way down to zero, but failed to crash my system. It just stopped and said something about "that's not a valid VID to try". I tried to rerun the script but it gave me and error saying
    Load VIDs from 'phc_tweaked_vids'
    > ERROR: Wrong VID count!
    I've deleted those and am rerunning the script. Everything else appears to be working, and all the steps up to this point have worked great. Any ideas what's going wrong?

  10. #10
    Join Date
    Jul 2006
    Location
    Tschörmany
    Beans
    111
    Distro
    Kubuntu 12.04 Precise Pangolin

    Re: HowTo: Undervolt your notebook CPU for longer battery life

    Quote Originally Posted by Arthur Archnix View Post
    I got to the step where you run the script, and it wasn't clear if the script itself started burnMMX or not, so I opened up a new tab and typed "burnMMX". It's not clear to me that it's working or doing anything, it kinda just sits there.
    One thread of burnMMX is started automatically. You can verify this with "top" in a terminal or the gnome system monitor. In case you have a dualcore just start a second thread of burnMMX as described in the howto.

    Quote Originally Posted by Arthur Archnix View Post
    Anyway, then I ran the script and it counted all the way down to zero, but failed to crash my system. It just stopped and said something about "that's not a valid VID to try". I tried to rerun the script but it gave me and error saying

    I've deleted those and am rerunning the script. Everything else appears to be working, and all the steps up to this point have worked great. Any ideas what's going wrong?
    The voltage are calculated with a formula that looks like voltage = a+bx, where a is a base level of voltage witch is increased in x steps with a step size of b.
    The script returning zero means x=0, so you don't need to increase the base voltage for your cpu. So everything should be fine, the script will write 1 instead of zero to its result file and you can use that. In my example I get zeros as well.
    Last edited by Ares Drake; June 2nd, 2008 at 02:55 PM.
    HowTo: Ask Questions the smart way | keep on rockin'...

    GEEK CODE Version: 3.1: GJ/MD d s a- C++ ULS++ P L+++ E---- W++ N* ?o K- w--- ?O M-- V-- PS+>$ PE++>$ Y+ PGP++ t-- 5- X R tv b+ ?DI D+ G++ e+++ h-- r++ y+

Page 1 of 4 123 ... LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •