Open Minded Brain Open source, open mind, open future

9May/1080

Undervolting in Ubuntu 10.04 (Lucid) LTS

This is a guide to Undervolting your Intel CPU under Ubuntu 10.04 LTS. For the ones that do not know, Undervolting means taking some of the voltage from the CPU which in return gives a longer battery life and lower temperature during intensive use of the CPU.

And what are the negative aspects of Undervolting? Well actually taking some voltage from the CPU could bring in computational problems, basically when taking too much of it the CPU could start mixing 1's and 0's which can crash the entire system (reset needed) or bring in data loss/corruption. Not so good eh? So how is that people manage to do it without causing those side effects?

It depends on every CPU. Because it is not possible to create two CPU's 100% alike in the factory, tests are made to ensure all CPU's sold can work with the voltages specified under all circumstances. The fact is that some of the CPU's can work with voltages many times inferior than others that came from same factory/same box. The trick is to discover the limits of your CPU and set the voltage just a little above this limit and you are good to go.

WARNING because of the negative aspects shown above, by following the steps given below, I am not under any circumstances responsible for any data loss or corruption, damage to the CPU/PC. Those next steps were proven to work for many people around the world, but no guarantee is given that it would work for you without possible side effects. Just make sure that at least you have an updated backup of the data before continuing.


Ok, so now that you accept full responsibilities for the steps below, let's get going. I actually did this several years ago under other version of Ubuntu (using a single core Pentium M CPU back then) and it worked alright, but many things changed since then, we've got multi core CPU's everywhere and the way the undervolting issue is handled in Linux is very different also.

So what do we need? A single or multi core Intel Mobile/Laptop CPU and Ubuntu 10.04 LTS installed on it and some time because it will take a little before having everything configured. Here are the complete steps that worked for me:

  1. As we are going to use a custom kernel, we need to add the linux-phc PPA repository, so just open a terminal and execute:
    $ sudo add-apt-repository ppa:linux-phc/ppa
    $ sudo apt-get update
    
    Basically they provide the same kernel as the Ubuntu one but with the patch that is capable for Undervolting.
  2. Next we need to install the phc kernel, with headers:
    $ sudo apt-get install linux-generic-phc linux-headers-generic-phc
    
    Ok, now we need to restart and use the installed phc kernel when booting. After restarting, you can check if you are using the phc kernel by using
    $ uname -r
    2.6.32-21-generic-phc
    
    If no "phc" appears, then you have to configure grub2 to allow you to chose boot options and select the phc kernel at boot time. This can be done many ways one would be:
    sudo update-grub
    
    and count the number of lines that says "Found linux image" (first one is 0) and, when you found the phc one, do:
    sudo gedit /etc/default/grub
    
    then just change the "GRUB_DEFAULT=0" to the number of the entry you found that has phc. Save the file and do a update-grub command again like in the first step. Now you can reboot into the phc kernel.
  3. Great, we are using a phc kernel, now we need to add the actual undervolt module, as the kernel comes only with support for it, not the actual module. First download phc-intel offtree module from here. Right now they have "phc-intel-0.3.2-10 offtree" version. Direct link to the tar.bz2 file here. Unpack the files anywhere and point the terminal to the directory where you extracted the files and do:
    $ make prepare
    $ make
    $ sudo make install
    
    Right now you should have the module installed, check if everything worked by typing:
    $ cat /sys/devices/system/cpu/cpu0/cpufreq/phc_default_vids 
    40 34 31 27 23 15
    
    If everything worked, you should see some numbers (the ones above are the default ones for my CPU). If not, you may try to restart and check back to see if it works.
  4. So right now we are set, the only thing we have to do is... undervolt the CPU.
    Now we have to discover the limits of the CPU by lowering it's current voltage one step at a time and set the voltage 4 steps above the critical limit (where the cpu starts to give wrong calculations or the PC simply crashes).

    Why four? Well the recommendation was 2 steps above, but with this limit the PC crashed in the same day hours later, so I made it 3 steps, then some days after it crashed again. So I think 4 steps should actually do it. If not, you may increase this value until it suits you.

    Ok great now how to find the actual critical limit? There exists a script, created by the community, but it's old and it does not work for multi core CPU's and also in my particular case it sets the voltage directly below this critical limit so the PC crashes instantly.

    I updated this script and made it work on multi core CPU's (hopefully it will work for you too), so you just have to download the script, then give it execution permissions and execute it and follow on-screen indications:
    $ chmod +x intel-phc-undervolt.bash
    $ ./intel-phc-undervolt.bash
    
    Oh and make sure you close as many applications as possible when executing the script as the system may actually turn instable (it is intended actually) just to prevent any data loss. The script treats all CPU's cores with the same voltages, so if one of them is weaker than the other (does not support such a aggressive undervolting) is this the critical value that the script uses for all of the others, even if they could possibly use a even lower value.
  5. After you finished with the script, now you should have a "phc_tweaked_vids" file, containing the acceptable steps for your CPU. Now you only have to make changes permanent (load them at every boot of the pc) by editing /etc/rc.local file:
    $ sudo gedit /etc/rc.local
    
    and adding one entry for every core you have, something like:
    echo "23 20 4 4 4 4" > /sys/devices/system/cpu/cpu0/cpufreq/phc_vids
    echo "23 20 4 4 4 4" > /sys/devices/system/cpu/cpu1/cpufreq/phc_vids
      .
      .
      .
    echo "23 20 4 4 4 4" > /sys/devices/system/cpu/cpu8/cpufreq/phc_vids
    
    just before the "exit 0". Note that "23 20 4 4 4 4" are my values, you have to replace the above with your values, that came from the "phc_tweaked_vids" file. So that's about it. Not too easy, not too complicated.

So... is it worth it? I have done some tests to see if the above actually works as said, so first I tested to see if on battery using powertop application and the CPU temperature I could see any differences. None actually, if the CPU is in idle state, there is no actual gain using undervolting, be it battery or temperature.

But when I've done the test under full load (using 2 burnMMX instances, one for every core) and with the CPU set at it's maximum 2.4Ghz I could see a very very noticeable difference.

First let's see the power drain of the battery in Watts, as indicated by powertop application (with the PC disconnected from the charger, of course):

It seems that Undervolting can spare you 10 Watt of power under full CPU load (Actual values from 38.4Watt to 28.7Watt). Now let's see how this translates actually to CPU temperature:

So those 10 Watt of power actually translates into having the CPU 7°C cooler (from 59°C to 52°C) while doing the same tasks under full load.

UPDATE: Thanks to aldeby in comments, just to clarify a little about the results of the CPU undervolt script. If the result of the script goes down to 0, that means is a fake value and that the CPU is locked and actually can't go below the lowest value (in my example the last values that have "4" value are faked by the CPU because he is actually running at it's lowest hardware allowed value, that would be 15). What this means is that at idle for example (when on 800Mhz in my case) I don't benefit anything by undervolting, but at higer frequencies (especially the 2.4Ghz one) I benefit a lot from it (see the charts abobe).

So that's about it. Hope you enjoyed the reading and that the steps were easy and clear to follow. Any questions/suggestions you can add them below, in the comments.

Comments (80) Trackbacks (2)
  1. I have an Intel Celeron M Processor ULV 743 (Acer Aspire 1410) and I get this after adding the module to the kernel:

    FATAL: Error inserting phc_intel (/lib/modules/2.6.32-25-generic-phc/extra/phc-intel.ko): No such device

  2. Thanks for the guide, Im using 10.10 now but when I try to install the phc intel I get this message

    Makefile detected your kernel version as 2.6.35
    ***NO MATCHING PATCHSET FOUND FOR 2.6.35***

    make: *** No rule to make target `phc-intel.c’, needed by `phc-intel.ko’. Stop.

  3. Thank you very much for this guide. Installation went well and the scripts seem to work.

    Since my warranty for a HP dv6799eg special edition (Intel T8100) is gone, I tried it and guess what? Something went … not exactly right.

    The script went (on governor 2101MHz) down to VID 0. I assume a value of 700mV cannot be correct (my amd phenom 955 c3 runs at 700mV @ 800MHz, but thats a different story). Minimum for that clockspeed should be something around 900mv i guess.

    Do you have any idea why it goes so extremely low?

  4. Yes, i have the same thing as Pete – on Intel laptop with T7300, the script goes down to 0 VID. On windows i used the RightMark CPU clock program, so i know the stable voltages in mV the CPU can run on. So i set them manually, but for whatever reason the PC still freezes from time to time, so i guess the voltages i had on windows are not applicable in Ubuntu 10.04. Still playing with settings, but i wonder why does the script not detect the voltages?

  5. @ Justin Ong

    Go into the ‘inc’ folder and rename the folder ’2.6.34′ to ’2.6.35′

  6. Hello,
    i got a kernel update today (2.6.32.-25.45 to 2.6.32.-26.48 – Ubuntu 10.04 LTS 64bit)
    the kernel is loaded but the voltage setting take no effekt (the files /sys/devices/system/cpu/cpu0/cpufreq/phc_vids and /sys/devices/system/cpu/cpu1/cpufreq/phc_vids are not there)
    so i try to recompile te modul:

    uwe@tux:/media/daten/phc-intel-0.3.2-10$ make prepare
    FOUND AVAILABLE PATCHSET. PREPARING.
    patching file phc-intel.c
    uwe@tux:/media/daten/phc-intel-0.3.2-10$ makemake -C /lib/modules/`uname -r`/build SUBDIRS=/media/daten/phc-intel-0.3.2-10 modules
    make[1]: Betrete Verzeichnis ‘/usr/src/linux-headers-2.6.32-26-generic-phc’
    make[1]: *** Keine Regel, um »PHC« zu erstellen. Schluss.
    make[1]: Verlasse Verzeichnis ‘/usr/src/linux-headers-2.6.32-26-generic-phc’
    make: *** [phc-intel.ko] Fehler 2

    i dont understand the problem ?

  7. To run the make prepare you need the patch app installed, a newbie won’t have that, need sudo apt-get install build-essential

  8. @Nigel
    build-essential is installed – PHC was running for some months
    I think i removed something when i removed some old kernels.

  9. I have to say this is a brilliant tutorial.
    many thanks for it.

    with the phc kernel installed,phc-intell gives me this error:
    make[1]: *** No rule to make target `Drive/phc/phc-intel-0.3.2-10′. Stop.
    make[1]: Leaving directory `/usr/src/linux-headers-2.6.32-26-generic-phc’
    make: *** [phc-intel.ko] Error 2
    at the make process
    looked in the read me file and nothing new except build essentials and I did that and got build essentials is already in it’s newest version

  10. jj@jj-laptop:~/Documentos/phc-intel-0.3.2-10$ sudo make prepare
    FOUND AVAILABLE PATCHSET. PREPARING.
    patching file phc-intel.c
    jj@jj-laptop:~/Documentos/phc-intel-0.3.2-10$ make
    make -C /lib/modules/`uname -r`/build SUBDIRS=/home/jj/Documentos/phc-intel-0.3.2-10 modules
    make[1]: se ingresa al directorio `/usr/src/linux-headers-2.6.32-27-generic-phc’
    CC [M] /home/jj/Documentos/phc-intel-0.3.2-10/phc-intel.o
    Building modules, stage 2.
    MODPOST 1 modules
    LD [M] /home/jj/Documentos/phc-intel-0.3.2-10/phc-intel.ko
    make[1]: se sale del directorio `/usr/src/linux-headers-2.6.32-27-generic-phc’
    jj@jj-laptop:~/Documentos/phc-intel-0.3.2-10$ sudo make install
    install -m 644 -o root -g root phc-intel.modprobe /etc/modprobe.d/phc-intel.conf
    mkdir -p /lib/modules/2.6.32-27-generic-phc/extra
    install -m 644 -o root -g root phc-intel.ko /lib/modules/2.6.32-27-generic-phc/extra/
    depmod 2.6.32-27-generic-phc -a
    jj@jj-laptop:~/Documentos/phc-intel-0.3.2-10$

    As you can se the script does not show any error, but in
    /sys/devices/system/cpu/cpu0/

    I can only find the subfolders

    cpuidle crash_notes topology

    What is happenning? I have a pentium 4 mobile at 2600 mhz, single core.

    Thanks

  11. Hi. I am running phc on a 2 x Celeron U3600 (cpuinfo) system. The default vids I see are “9 8 7 6 5.” The above script returned a default value of “0″ and the text file created as “0 8 7 6 5.” Does this mean my cpu is possibly locked against undervolting? Should I bother with step 5?

    Thanks for the article and the help.

  12. I got a replacement T61 and re-applied your HOWTO and script and for some reason the exact same specification machine behaved very differently to undervolting, in particular your script rendered useless. It would give quite different recommended settings and none of them worked. It gave me vids 24 23 4 4 4 , and yet when I applied them to the 1st core it worked and when applied to 2nd core it immediately crashed the system. I nudged these up a little til system appeared stable and then lowered a little and confirmed unstable, so my actual (as I type, just a day in) stable vids are 27 24 4 4 4. Handbrake, which I self-built optimized for my ubuntu 10.04 AMD64 seems the most crash-causing, possibly it touches more of the silicon?
    Anyhow, system now is very quiet its lowered the heat enough to make the system not use the fan a lot less than before. Sorry, in this case my own trial+error found higher than your script and is core-specific in this laptop’s case.

  13. I got a replacement T61 and re-applied your HOWTO and script and for some reason the exact same specification machine behaved very differently to undervolting, in particular your script rendered useless. It would give quite different recommended settings and none of them worked. It gave me vids 24 23 4 4 4 , and yet when I applied them to the 1st core it worked and when applied to 2nd core it immediately crashed the system. I nudged these up a little til system appeared stable and then lowered a little and confirmed unstable, so my actual (as I type, just a day in) stable vids are 27 24 4 4 4. Handbrake, which I self-built optimized for my ubuntu 10.04 AMD64 seems the most crash-causing, possibly it touches more of the silicon?
    Anyhow, system now is very quiet its lowered the heat enough to make the system not use the fan a lot less than before. Sorry, in this case my own trial+error found higher than your script and is core-specific in this laptop’s case.

  14. Great tutorial, thanks very much!

  15. “phc_tweaked_vids” file not recreated, and script ./intel-phc-undervolt.bash ran to 0.
    HP DV4 with intel i5 dual core (4 threads as cpu). Would be nice to lower voltage as fan seems to run most of the time. David-Maryland youtube:letsgomd

  16. My cpu’s report a default value of 19 for the lowest frequency. My script results were 20 4 4 4 4. Taking into account your explanation of the 0 values (which are added 4 for precaution, hence all 4′s), do I have to set the VIDS to 20 19 19 19 19?

    Just to make it clear — in the tweaks file, for every value lower than my lowest default value, when it comes to actually changing the phc_vids file, do I change said lower values to the reported lowest default value?

    Example

    43 37 31 25 19 – default

    20 4 4 4 4 – script result

    20 19 19 19 19 – new phc_vids values

    Or am I getting it wrong?

  17. hi ,I did everything according to instructions this is the output


    bigley@ux:~$ uname -r
    2.6.32-31-generic-phc

    bigley@ux:~$ cd Downloads/undervolt/phc-intel-0.3.2-10/

    bigley@ux:~/Downloads/undervolt/phc-intel-0.3.2-10$ make prepare
    FOUND AVAILABLE PATCHSET. PREPARING.
    patching file phc-intel.c

    bigley@ux:~/Downloads/undervolt/phc-intel-0.3.2-10$ make
    make -C /lib/modules/`uname -r`/build SUBDIRS=/home/bigley/Downloads/undervolt/phc-intel-0.3.2-10 modules
    make[1]: Entering directory `/usr/src/linux-headers-2.6.32-31-generic-phc’
    CC [M] /home/bigley/Downloads/undervolt/phc-intel-0.3.2-10/phc-intel.o
    Building modules, stage 2.
    MODPOST 1 modules
    CC /home/bigley/Downloads/undervolt/phc-intel-0.3.2-10/phc-intel.mod.o
    LD [M] /home/bigley/Downloads/undervolt/phc-intel-0.3.2-10/phc-intel.ko
    make[1]: Leaving directory `/usr/src/linux-headers-2.6.32-31-generic-phc’

    bigley@ux:~/Downloads/undervolt/phc-intel-0.3.2-10$ sudo make install
    [sudo] password for bigley:
    install -m 644 -o root -g root phc-intel.modprobe /etc/modprobe.d/phc-intel.conf
    mkdir -p /lib/modules/2.6.32-31-generic-phc/extra
    install -m 644 -o root -g root phc-intel.ko /lib/modules/2.6.32-31-generic-phc/extra/
    depmod 2.6.32-31-generic-phc -a

    bigley@ux:~/Downloads/undervolt/phc-intel-0.3.2-10$ cat /sys/devices/system/cpu/cpu0/cpufreq/phc_default_vids
    cat: /sys/devices/system/cpu/cpu0/cpufreq/phc_default_vids: No such file or directory

    Because of this the patch wont work, this is the output

    bigley@ux:~/ubuntu$ ./intel-phc-undervolt.bash

    This script will optimize your voltages at every speed setting
    by systematically lowering them while stressing the CPU.
    Each voltage will be turned down until your system crashes, and the final
    setting for that voltage will be 4 VIDs above that to “ensure” stability.

    WARNING:
    This script will crash your system as many times as there are VIDs to tweak.
    You might destroy your hardware, break laws and/or die in vain if you continue.

    Do you want to continue? [Y/n/?] Yes
    > ERROR: No CPU core capable of undervolting found.

    please help my sony ux with intel u7700. many thanks

  18. wait ignore that, one must restart after installing the “sudo make install”

  19. I since I have been using this awesime phc patch there has been some official kernel updates to 2.6.32-30-generic. Is there any way to patch this one? I updated to the new kernel, but its not phc patched, so currently I force to set grub to load the older 2.6.32-31-generic-phc version in order to take advantage of this undervolting

  20. A link to this posting was at Christian Dillstrom’s list of recommended blog pages – you must be doing a good job as mobile and social media marketing pro is pointing towards you!

  21. My Values: 39 28 23 17

    Ok, there is something I odn’t understand. When I run your script it goes down from 39 to 0. Then I restart your script and it gows down from 39 0 23 17. Then I restart your script and it goes down from 39 28 0 17, etc.

    So what exactly I got to add in /etc/rc.local then?

  22. Sebastian, to be on the safe side I would put in the higer values of the two sets of tests.
    For me I was lucky, that everytime I ran the script it resulted in the same values.

    I would probably try in your case 39 28 23 17 in the rc.local.

    You will find out if these values don’t work when your PC suddenly becomes unstable for no apparent reason. Good luck

  23. thx, but 22 20 20 17 worked fine. Problem was the script always counted down to 0 for all 4 values.
    Now I installed Ubuntu 11 and the installation of phc doesn’t work :( When I run sudo make, terminal returns:
    make[2]: *** No rule to make target `kernel/bounds.c’, needed by `kernel/bounds.s’. Stop.
    make[1]: *** [prepare0] Error 2
    make[1]: Leaving directory `/usr/src/linux-headers-2.6.38-8-generic-phc’
    make: *** [phc-intel.ko] Error 2

  24. Everyone, do an update. noticed that there is a new PHC kernel 2.6.32-33 out for us lucid user. Many thanks for the update ;)

  25. I have a laptop with a Core 2 Duo P8xxx. I run W7 and Ubuntu 10.04 (both 64-bit) on it.

    I use RMClock on my W7 partition and I know that my system runs fine under full load at 0.925V (I have been running it for more than 30 months now).

    Is there any way I can painlessly undervolt the CPU on Ubuntu without going through the long testing steps? If not, I may just have to suck it up and follow the above instructions.

    Thank you, this is a great guide. :-)

  26. This is what I get:
    scott@scott-laptop:~/Desktop/phc-intel-0.3.2-10$ uname -r
    2.6.32-33-generic-phc
    scott@scott-laptop:~/Desktop/phc-intel-0.3.2-10$ make prepare
    FOUND AVAILABLE PATCHSET. PREPARING.
    patching file phc-intel.c
    scott@scott-laptop:~/Desktop/phc-intel-0.3.2-10$ make
    make -C /lib/modules/`uname -r`/build SUBDIRS=/home/scott/Desktop/phc-intel-0.3.2-10 modules
    make[1]: Entering directory `/usr/src/linux-headers-2.6.32-33-generic-phc’
    CC [M] /home/scott/Desktop/phc-intel-0.3.2-10/phc-intel.o
    Building modules, stage 2.
    MODPOST 1 modules
    LD [M] /home/scott/Desktop/phc-intel-0.3.2-10/phc-intel.ko
    make[1]: Leaving directory `/usr/src/linux-headers-2.6.32-33-generic-phc’
    scott@scott-laptop:~/Desktop/phc-intel-0.3.2-10$ sudo make install
    install -m 644 -o root -g root phc-intel.modprobe /etc/modprobe.d/phc-intel.conf
    mkdir -p /lib/modules/2.6.32-33-generic-phc/extra
    install -m 644 -o root -g root phc-intel.ko /lib/modules/2.6.32-33-generic-phc/extra/
    depmod 2.6.32-33-generic-phc -a
    scott@scott-laptop:~/Desktop/phc-intel-0.3.2-10$ cat /sys/devices/system/cpu/cpu0/cpufreq/phc_default_vids
    cat: /sys/devices/system/cpu/cpu0/cpufreq/phc_default_vids: No such file or directory

    I have rebooted a couple times already and am not sure where to go from here. I did navigate to /sys/devices/system/cpu/ and instead of cpufreq being a subfolder of cpu0 it is in the same folder. I think this may be causing this but if I look in cpufreq there is not phc_default_vids. Any suggestions?

  27. How long shoult I wait after ‘make prepare’? It seems nothing is happening and I’m waiting since five minutes or more…

  28. Thanks alot, that script just made my day :) I’m on oneiric, I have phc kernel, drivers but I wasn’t able to run phc-tool… Your script just did what I needed :)
    Btw. I have Acer 6920g and default voltage set 200mV higher than the values from Intel is really not cool…
    Once more, thank You :)

  29. In Ubuntu 11.10 i had to add phc-intel to /etc/modules in order to get it to load at boot instead of acpi-cpufreq. to unload acpi-cpufreq on my running system caused an error since the module was in use.

  30. Thank you for your great guide, I have 3.2.0-24-generic-phc, So when i try to make prepare the phc-intel-0.3.2-12-1 said : Makefile:37: *** Only support for 2.6 series kernels. Stop.
    and when i try to make prepare the phc-intel-0.3.2-10 nothing happed, even after a quite 10 minute, what should i do to undervolt my cpu…?


Leave a comment