Disable a few cores when you want to save power.

2012-12-28 219 words 2 mins read

If you have a lot of CPU power and working on battery. If you do not need that much of power and would like to rather save some battery power by disabling some cpus then you can use the below script. This script disables cpus from 4 to 7. You can change the number in the for loop. You would need the sudo to be setup or remove sudo and run the script as root. The script will show you the currently active cpu’s before and after disabling the CPU’s.

If you want to disable to cpus from the grub itself then you can add the below parameter in grub.cfg or grub2.cfg in the vmlinuz line:

    <div class="bash codecolorer">
      <span class="re2">maxcpus</span>=<span class="nu0">4</span>

Here is the script:

#!/bin/bash -
#          FILE: disablecpu.sh
#         USAGE: ./disablecpu.sh
#       OPTIONS: ---
#          BUGS: ---
#         NOTES: ---
#        AUTHOR: Amit Agarwal (aka)
#      REVISION:  ---

#set -o nounset                              # Treat unset variables as an error
cat /proc/cpuinfo|grep cores|wc -l
for i in {4..7}
    sudo sh -c "echo 0 > /sys/devices/system/cpu/cpu$i/online"
cat /proc/cpuinfo|grep cores|wc -l
Enhanced by Zemanta


Authored By Amit Agarwal

Amit Agarwal, Linux and Photography are my hobbies.Creative Commons Attribution 4.0 International License.

We notice you're using an adblocker. If you like our webite please keep us running by whitelisting this site in your ad blocker. We’re serving quality, related ads only. Thank you!

I've whitelisted your website.

Not now
This website uses cookies to ensure you get the best experience on our website. Learn more Got it