{"id":45744,"date":"2024-03-05T14:53:00","date_gmt":"2024-03-05T14:53:00","guid":{"rendered":"https:\/\/ubuntuhandbook.org\/?p=45744"},"modified":"2024-05-05T13:32:56","modified_gmt":"2024-05-05T13:32:56","slug":"disable-cpu-cores-ubuntu","status":"publish","type":"post","link":"https:\/\/ubuntuhandbook.org\/index.php\/2024\/03\/disable-cpu-cores-ubuntu\/","title":{"rendered":"How to Disable CPU Cores to Save Power in Ubuntu 24.04 | 22.04"},"content":{"rendered":"<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/10\/cpu-icon.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-thumbnail wp-image-44610\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/10\/cpu-icon-250x250.webp\" alt=\"\" width=\"250\" height=\"250\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/10\/cpu-icon-250x250.webp 250w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/10\/cpu-icon-300x300.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/10\/cpu-icon-600x600.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/10\/cpu-icon-768x768.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/10\/cpu-icon.webp 1200w\" sizes=\"auto, (max-width: 250px) 100vw, 250px\" \/><\/a><\/p>\n<p>This tutorial shows how to disable certain CPU cores in Ubuntu to save power and prevent your machine from overheating.<\/p>\n<p>There are a few tools to manage CPU frequency and save power in Linux today. They include <code>power-profile-daemon<\/code> (Gnome built-in power mode settings), <a href=\"https:\/\/linrunner.de\/tlp\/index.html\" target=\"_blank\" rel=\"noopener\">TLP<\/a> laptop battery life saving tool, auto-cpufreq, and more.<\/p>\n<p>Besides limiting CPU frequency, turn off few CPU cores is another choice to cool down your PC or laptop. And, Motherboard BIOS settings page usually have a corresponding option. For choice, here&#8217;s how to do the job in Ubuntu Linux.<\/p>\n<p><!--more--><\/p>\n<h3>Option 1: Single command to disable CPU core<\/h3>\n<p>Ubuntu and most other Linux has a <code>\/sys\/devices\/system\/cpu\/<\/code> directory handles the CPU configurations.<\/p>\n<p>1. First, press <code>Ctrl+Alt+T<\/code> on keyboard to open terminal. Then, run command to list the directory content:<\/p>\n<pre>ls \/sys\/devices\/system\/cpu\/<\/pre>\n<p><i>In terminal output, you&#8217;ll see <code>cpu0<\/code>, <code>cpu1<\/code>, <code>cpu2<\/code>, <code>cpu3<\/code> etc sub-folders\u00a0for your CPU cores. In my case, I have 8 cores (4c\/8t). They are cpu0 ~ cpu7.<\/i><\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/03\/ls-sysdevicescpu.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-45745\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/03\/ls-sysdevicescpu-700x330.webp\" alt=\"\" width=\"610\" height=\"288\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/03\/ls-sysdevicescpu-700x330.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/03\/ls-sysdevicescpu-300x142.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/03\/ls-sysdevicescpu-768x363.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/03\/ls-sysdevicescpu.webp 786w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<p>2. Each sub-folder contains a &#8216;<code>online<\/code>&#8216; config file. To disable a CPU core, just set its <code>online<\/code> file content to 0.<\/p>\n<p>For example, disable cpu7 by running command:<\/p>\n<pre>sudo sh -c \"echo 0 &gt; \/sys\/devices\/system\/cpu\/cpu7\/online\"<\/pre>\n<p>By re-running last command and changing number <code>7<\/code>, you may continue to disable more CPU cores one by one.<br \/>\n<a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/03\/disable-cpu7.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-45746\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/03\/disable-cpu7-700x362.webp\" alt=\"\" width=\"610\" height=\"315\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/03\/disable-cpu7-700x362.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/03\/disable-cpu7-300x155.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/03\/disable-cpu7-768x398.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/03\/disable-cpu7.webp 786w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<p>Or, use single command to disable multiple cores:<\/p>\n<pre>for file in $(ls \/sys\/devices\/system\/cpu\/cpu[578]*\/online); do sudo sh -c \"echo 0 &gt; $file\"; done<\/pre>\n<p><i>The command above will disable CPU ids with number 5, 7, 8 (<code>cpu5<\/code>, <code>cpu7<\/code>, and <code>cpu8<\/code> if exist).<\/i><\/p>\n<p>3. After making changes, <b>verify<\/b> by either going to system &#8216;About&#8217; page, or running the command below in terminal:<\/p>\n<pre>lscpu | grep 'CPU(s)'<\/pre>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/03\/verify-cpucores.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-45747\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/03\/verify-cpucores-700x424.webp\" alt=\"\" width=\"610\" height=\"369\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/03\/verify-cpucores-700x424.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/03\/verify-cpucores-300x182.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/03\/verify-cpucores-768x465.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/03\/verify-cpucores.webp 1251w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<h3>Option 2: Use Kernel Parameter to set how many CPU Cores to enable on startup<\/h3>\n<p>The changes you made in &#8220;Option 1&#8221; will be overridden on system reboot. If you want to make it work on every boot, then there&#8217;s a <code>maxcpus<\/code> kernel parameter can do the job.<\/p>\n<p>1. First, press <code>Ctrl+Alt+T<\/code> on keyboard to open terminal. When it opens, run command to edit the grub boot-loader config file:<\/p>\n<pre>sudo gedit \/etc\/default\/grub<\/pre>\n<p><i>For <strong>Ubuntu 24.04<\/strong>, replace <code>gedit<\/code> with <code>gnome-text-editor<\/code>. For non-default GNOME desktop, replace <code>gedit<\/code> with your favorite text editor, or use <code>nano<\/code> that works in most desktops.<\/i><\/p>\n<p>2. When file opens, add the <code>maxcpus=4<\/code> (<i>change number 4 as you want.<\/i>) parameter as value to <b>GRUB_CMDLINE_LINUX_DEFAULT<\/b>. Then, save file. For nano command line text editor, press <b>Ctrl+S<\/b> to save, then <b>Ctrl+X<\/b> to exit.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/03\/grub-maxcpus.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-45748\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/03\/grub-maxcpus-700x355.webp\" alt=\"\" width=\"610\" height=\"309\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/03\/grub-maxcpus-700x355.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/03\/grub-maxcpus-300x152.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/03\/grub-maxcpus-768x390.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/03\/grub-maxcpus.webp 948w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<p>3. Finally, apply the change by updating grub configuration (this command varies in different Linux Distros):<\/p>\n<pre>sudo update-grub<\/pre>\n<p>For those who have &#8220;Grub Customizer&#8221; installed, you can also open the app and navigate to &#8220;General Settings&#8221; tab to add the kernel parameter and finally click save.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/03\/grub-customizer-maxcpus.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-45749\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/03\/grub-customizer-maxcpus-700x472.webp\" alt=\"\" width=\"610\" height=\"411\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/03\/grub-customizer-maxcpus-700x472.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/03\/grub-customizer-maxcpus-300x202.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/03\/grub-customizer-maxcpus-768x518.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/03\/grub-customizer-maxcpus.webp 916w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<p>In addition, the kernel parameter usually load the first 4 (or other number depends your setting) CPU cores. If you want to re-enable the left CPU cores, for example <code>cpu7<\/code>, run command:<\/p>\n<pre>sudo sh -c \"echo 1 &gt; \/sys\/devices\/system\/cpu\/cpu7\/online\"<\/pre>\n<p>Instead of running the command above one by one with different core number, you may alternatively run single command below to re-enable all CPU cores:<\/p>\n<pre>for file in $(ls \/sys\/devices\/system\/cpu\/cpu[0-9]*\/online); do sudo sh -c \"echo 1 &gt; $file\"; done<\/pre>\n<h3>Use graphical tool to disable CPU cores<\/h3>\n<p>For GNOME, the default desktop environment in Ubuntu and Fedora Workstation, there&#8217;s a lightweight power management extension that can do the job.<\/p>\n<p>It&#8217;s cpufreq which however supports GNOME up to version 44 so far (Ubuntu 23.04\/Fedora 38 and earlier). <strong>Ubuntu 24.04 is supported at the moment of writing.<\/strong><\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/03\/ge-cpufreq.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-45750\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/03\/ge-cpufreq-700x591.webp\" alt=\"\" width=\"610\" height=\"515\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/03\/ge-cpufreq-700x591.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/03\/ge-cpufreq-300x253.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/03\/ge-cpufreq.webp 764w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<p>Ubuntu user can first search for and install &#8220;<b>Extension Manager<\/b>&#8221; from Ubuntu Software (App Center), then use the tool to search &amp; install the cpufreq extension. While, Fedora and other Linux with GNOME can visit the <a href=\"https:\/\/extensions.gnome.org\/extension\/1082\/cpufreq\/\" target=\"_blank\" rel=\"noopener\">extension web page<\/a> then use ON\/OFF toggle to install (<i>need to install browser extension<\/i>).<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/03\/install-ge-cpufre.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-45751\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/03\/install-ge-cpufre-700x548.webp\" alt=\"\" width=\"610\" height=\"478\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/03\/install-ge-cpufre-700x548.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/03\/install-ge-cpufre-300x235.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/03\/install-ge-cpufre-768x601.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/03\/install-ge-cpufre.webp 922w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<p>For non-Gnome users, there&#8217;s previously <a href=\"https:\/\/github.com\/vagnum08\/cpupower-gui\" target=\"_blank\" rel=\"noopener\">cpupower-gui<\/a> tool for Ubuntu 20.04. Sadly, it lacks development for recent Ubuntu versions support.<\/p>\n<p>If you know any other graphical tool to do the job, feel free to leave comment below.<\/p>","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to disable certain CPU cores in Ubuntu to save power and prevent your machine from overheating. There are a few tools to manage CPU frequency and save power in Linux today. They include power-profile-daemon (Gnome built-in power mode settings), TLP laptop battery life saving tool, auto-cpufreq, and more. Besides limiting CPU [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":44610,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[1515],"class_list":["post-45744","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","tag-power-saving"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/45744","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/comments?post=45744"}],"version-history":[{"count":0,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/45744\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media\/44610"}],"wp:attachment":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media?parent=45744"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/categories?post=45744"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/tags?post=45744"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}