[How-To] Disable CPU cores in Linux

Although there’s no reason to do this, but some of you might have problem with apps not running well in multi-core environment or maybe looking to save some power (although disabling cores on sandy-bridge CPUs won’t save much power), I’ve written this simple tutorial to disable CPU cores in Linux.

I have i7 2630QM process which has 4 physical cores and 4 logical cores. I’ll show you how to make it act like a dual core machine instead.

Method 1:
This method is dynamic and doesn’t require a reboot. You can just open a terminal and try this out:

  • sudo sh -c "echo 0 > /sys/devices/system/cpu7/online"
    sudo sh -c "echo 0 > /sys/devices/system/cpu6/online"

    Repeat the above steps for cpu2 to cpu7 and it’ll leave you with cpu0 and cpu1 active which is essentially what we’re trying to achieve.

Method 2:
This method will make the linux boot with 2 cores which might make kernel more optimized for dual core environment than the method above.

  • Add maxcpus=2 to GRUB command line by doing the following:
    gksu gedit /etc/default/grub

    Find:

    GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

    and change it to

    GRUB_CMDLINE_LINUX_DEFAULT="quiet splash maxcpus=2"
  • Then run:
    sudo update-grub

    When you reboot, linux will run on 2 cores.

Leave a Reply

Your email address will not be published. Required fields are marked *