Saturday, 1 November 2014

CPU Scalling Kali linux

Making sure that fancy laptop wont crash n burn when you leave it overnight to crack something. Overheating is a common problem with quite a few laptops which is expected when you have QuadCore CPU with disks and GFX cards all crammed up in a tinny little space.. but I digress. What worked for me is scaling down the CPU to a level that even with max utilization temperature did not go higher than 75 degrees Celsius (less fan noise as well). The following was done on a Kali box so Debian and Ubuntu should be applicable as well.

Required tools:
apt-get install cpufrequtils
(will allow you to change polices and governors etc etc)
apt-get install lm-sensors
(will allow you to monitor temperature from the CPU sensors via command line)
apt-get install htop
(top version that is colorful and supports scrolling and multiple CPU graphs via command line)
john
(comes out of the box with kali)

Check out what your current settings are:
cpufreq-info

The line we are looking for is
available frequency steps: 2.67 GHz, 2.67 GHz, 2.53 GHz, 2.40 GHz, 2.27 GHz, 2.13 GHz, 2.00 GHz, 1.87 GHz, 1.73 GHz, 1.60 GHz, 1.47 GHz, 1.33 GHz, 1.20 GHz

While we can also see in the current policy that the maximum is defined
current policy: frequency should be within 1.20 GHz and 2.67 GHz.
You should also notice how many cores your system has at this point so time to scale it back a bit
cpufreq-set -r -g ondemand --max 1.73GHz -c 0
cpufreq-set -r -g ondemand --max 1.73GHz -c 1
cpufreq-set -r -g ondemand --max 1.73GHz -c 2
cpufreq-set -r -g ondemand --max 1.73GHz -c 3

We can run cpufreq-info to confirm and we will see the policy has changed
current policy: frequency should be within 1.20 GHz and 1.73GHz.
The governor "ondemand" may decide which speed to use within this range.
Now to make something for john to play with (I am assuming that you have changed your password from toor and john will actually have a challenge!)
unshadow /etc/passwd /etc/shadow > john-test

Almost there... you need to prep the sensors now so you can make sure to monitor the temperature... we want to test... not burn!
sensors-detect
(will detect the sensors you have in place.. the default options are fine)

Finally open up two more terminals, each of them should run
htop
watch sensors
john john-test
Kick off john and find the sweet-spot for your laptop's CPU :) (give it a couple of minutes to reach maximum temp)
(you can stop john and watch with Crtl-C and exit htop by typing "q")

When you have you can add your settings on /etc/rc.local so they are applied at boot time.

Enjoy :)

No comments:

Post a Comment