This is a guide to Undervolting your Intel CPU under Ubuntu 10.10. 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.
Note: this is an copy/update of my old post about undervolting in Ubuntu 10.04 found over here. Be sure to check it out, especially because of the comments, some could be helpful and address possible questions/difficulties you may have.
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.10 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:
- 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 updateBasically they provide the same kernel as the Ubuntu one but with the patch that is capable for Undervolting.
- Next we need to install the phc kernel, with headers:
$ sudo apt-get install linux-generic-phc linux-headers-generic-phcOk, 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.35-22-generic-phcIf 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-gruband 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/grubthen 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.
- 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 we need to download phc-intel offtree module from here. Right now they do not have a compatible version for the 2.6.35 kernel, but give the link a try, maybe by the time you read this post there is already a module that can be used in 2.6.35 kernels. Meanwhile there was a kind user on linux-phc forum that managed to create a module for the 2.6.35 and 2.6.36 kernels. Topic about it here. Direct link to the tar.gz file he kindly shared to the rest of us here. So download and unpack the files anywhere and point the terminal to the directory where you extracted the files and do:
$ make prepare $ make $ sudo make installRight 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 15If 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.
- 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.bashOh 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.
- 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
$ sudo gedit /etc/rc.localand 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_vidsjust 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.
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.