How to disable core(s) of CPU
Introduction ~
The question is why we need to disable few core of CPU? Sometime it is necessary to run certain applications, which are not compatible with multi core processing. Disabling core will not affect physically your hardware. Linux OS will simply ignore the core(s) you selected to disable.
Steps 1] How to do it?
Debian/Ubuntu ~
root@laptop:/home/arunsb# cat /boot/grub/menu.lst
title Ubuntu 9.04, kernel 2.6.28-11-generic
kernel /vmlinuz-2.6.28-11-generic root=UUID=55d33e45-75c7-54sc-b204-97b44e1d6a39 ro quiet splash maxcpus=1
initrd /initrd.img-2.6.28-11-generic
Redhat/Fedora based system ~
root@laptop:/home/arunsb# cat /boot/grub/grub.conf
title Red Hat Enterprise Linux ES (2.6.9-78.ELsmp)
root (hd0,4)
kernel /boot/vmlinuz-2.6.9-78.ELsmp ro root=LABEL=/ maxcpus=1
initrd /boot/initrd-2.6.9-78.ELsmp.img
Note ~ after changing grub config file please reboot the system to apply changes!
As shown above “maxcpus=1” indicates that Linux will use only one CPU core. you can change this value as per your requirement and hardware available.
You can also change this value during starting of system from GRUB menu but it is temporary setting. To make it permanent you need to modify the grub.conf (Redhat/Fedora) or menu.lst (debian/Ubuntu) GRUB config file.
Step 2] How to verify ~
I have dual core CPU as shown below and I have disable 1 core so After reboot I should get only one CPU core active
** Before above setting!
root@laptop:/home/arunsb# cat /proc/cpuinfo | grep processor
processor : 0
processor : 1
root@laptop:/home/arunsb#
* Verify after above setting ~
root@laptop:/home/arunsb# cat /proc/cpuinfo | grep processor
processor : 0
root@laptop:/home/arunsb#
* How to Disable CPU without Reboot?
root@arunb:~# echo 0 > /sys/devices/system/cpu/cpu1/online
* Confirm ?
root@arunb:~# cat /proc/cpuinfo | grep -i ‘Processor’
processor : 0
root@arunb:~#
Thank you,
Arun Bagul
Similar Posts:
- How to create edit/extract initrd in Ubuntu/Debian and Redhat/Fedora Linux ?
- Ubuntu – GRUB splash image as background for GRUB menu
- What’s new in GRUB-2?
- GRUB (GRand Unified Bootloader)
- Single user mode – How to reset(bypass) root password without bootable CD
- Xen virtualization on CentOS linux
- How to configure TATA Indicom/BSNL/Reliance Broadband+ Netconnect ( EDVO usb modem ) on Ubuntu Linux
2 Replies to “How to disable core(s) of CPU”
Nice article…
But I don’t have any application which needs single processor.. 😀
Thanks!
Your post helped to save some power until I need remaining cores for more performance.