This tutorial shows how to turn off CPU turbo boost, and/or set constant maximum (or minimum) CPU speed in Ubuntu 22.04 and/or Ubuntu 24.04.
Disable turbo boost will limit your CPU speed to prevent running over the base frequency. It’s useful to save power and prevent your computer from overheating. For choice, user can also set constant CPU speed for either minimum power consumption or maximum performance.
Most machine today has option in the BIOS page to enable/disable and even change CPU frequency, however, it’s not flexible.
For Linux, the Kernel has a tool called cpupower
can do the job from command line, and user can turn on/off turbo boost through sysfs. Gnome Desktop even has a GRAPHICAL extension (scroll-down to see step 4) to make things easier.
Depends on the CPU scaling driver, there are 2 commands to enable/disable CPU turbo boost.
First, press Ctrl+Alt+T on keyboard to open up a terminal windows, then run following commands accordingly.
If you have Intel
CPU in your machine, first try running the command below:
cat /sys/devices/system/cpu/intel_pstate/no_turbo
The command should output:
If it outputs 0, then you can run command to set its value to 1 to disable turbo boost:
echo "1" | sudo tee /sys/devices/system/cpu/intel_pstate/no_turbo
If 1, then use command to re-enable the feature:
echo "0" | sudo tee /sys/devices/system/cpu/intel_pstate/no_turbo
If the first command above outputs “No such file or directory”, then other scaling driver is in use.
In the case, run command to check anther sysfs:
cat /sys/devices/system/cpu/cpufreq/boost
As well, the command should output either 0 or 1. And, you can disable turo boost by setting its value to 1:
echo "1" | sudo tee /sys/devices/system/cpu/cpufreq/boost
The commands above work until reboot! In next boot, you system will restore the change and by default enable the turbo boost feature.
In the case, you can create a systemd service to run the above command automatically while booting the system.
But, why not disable it from BIOS settings 🤔?
1. To do so, first run command to create a system service:
sudo nano /etc/systemd/system/boostoff.service
The command will create a service called boostoff.service
and edit it in terminal. When it opens, paste following lines:
[Unit] Desciption=Disable Turbo Boost at startup [Service] Type=oneshot ExecStart=/bin/sh -c "echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo" [Install] WantedBy=multi-user.target
NOTE: for non-intel_pstate
driver, use /sys/devices/system/cpu/cpufreq/boost
instead of the bold text of ‘ExeStart’ value.
When done editing, press Ctrl+S to save file and Ctrl+X to exit.
2. Finally, enable the service, so to automatically disable turbo boost at startup:
systemctl enable boostoff.service
Without turning off boost, you can for choice limit the maximum frequency or set a constant CPU frequency. This can be done a cpupower
tool.
1. First, open terminal (Ctrl+Alt+T) and run command to install the tool for current Linux Kernel.
sudo apt install linux-tools-$(uname -r)
2. Then, you may run command to check which scaling driver is in use, minimum and maximum CPU frequency supported by your hardware, etc information.
cpupower frequency-info
3. To set constant minimum CPU Speed, just run:
sudo cpupower frequency-set --max 800MHz
This command will limit the maximum CPU speed to 800MHz
, which is the minimum speed according to last screenshot. Change the number according to your cpupower frequency-info
output.
To set constant maximum CPU Speed, run:
sudo cpupower frequency-set --min 4.30GHz --max 4.30GHz
Other than 4.30GHz, you can set any speed in last command that beyond your CPU capability. It will try running at maximum speed. If turbo boost disabled, then base frequency.
For choice, you may also set CPU to a specific speed by running command (2000MHz for example):
sudo cpupower frequency-set --freq 2000Mhz
Since Kernel 6.6, there’s also an option to disable turbo boost. But don’t know why, it does not work in my case for Intel CPU.
sudo cpupower set --turbo-boost 0
For the default GNOME Desktop, the built-in power mode settings may conflict with the cpupower
commands above.
In the case, you can disable the power-profiles-daemon by running the 2 commands below:
(Optional) To re-enable the service, run:
systemctl unmask power-profiles-daemon.service
systemctl start power-profiles-daemon.service
cpupower
option work in next bootLike the command to disable turbo boost, cpupower also works until reboot!
To make it work at startup, first create the service:
sudo nano /etc/systemd/system/cpupower.service
[Unit] Desciption=Adjust CPU speed via cpupower [Service] Type=oneshot ExecStart=/bin/sh -c "cpupower frequency-set --max 800MHz" [Install] WantedBy=multi-user.target
Then, enable the service via command:
systemctl enable cpupower.service
After (or while) making changes, you may monitor the real-time CPU speed, by running command:
watch -n1 "grep "^[c]pu MHz" /proc/cpuinfo"
It displays the frequency for all CPU cores and updates every second.
If you’re looking for a graphical tool to manage CPU power and frequency, I’ve written about it via following tutorials. They include:
The post Disable Turbo Boost / Set Constant CPU Speed in Ubuntu 22.04/24.04 appeared first on Osgrove.
2024 was the GenAI year. With new and more performant LLMs and a higher number…
Canonical’s Kubernetes LTS (Long Term Support) will support FedRAMP compliance and receive at least 12…
Welcome to the Ubuntu Weekly Newsletter, Issue 878 for the week of February 2 –…
At Canonical, we firmly believe that delivering an outstanding, customer-centric support experience is impossible without…
I want to share how to install osTicket v1.14 for Ubuntu 20.04 server. osTicket written…
Now I want to share how to install WordPress on ubuntu 20.04 server. WordPress is…