My laptop has issues with coil whine, resulting in me needing to disable Intel Turbo Boost. I usually use a GNOME Extension like CPU Power Manager but at the time of writing that extension isn’t compatible with GNOME 40, and isn’t much use for non-GNOME users.
Firstly elevate to sudo with
sudo -i, then:
Paste in the following:
[Unit] Description=Disable Intel Turbo Boost using pstate driver [Service] ExecStart=/bin/sh -c "/usr/bin/echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo" ExecStop=/bin/sh -c "/usr/bin/echo 0 > /sys/devices/system/cpu/intel_pstate/no_turbo" RemainAfterExit=yes [Install] WantedBy=sysinit.target
Next reload the systemd management configuration, enable and then start the new service, then lastly check the service is running. Enabling the service will start it automatically on a reboot, thus keeping Turbo Boost switched off all the time. If you only want to use it occasionally, skip the enable step and just start/stop the service as/when needed.
systemctl daemon-reload systemctl enable disable-intel-turboboost systemctl start disable-intel-turboboost systemctl status disable-intel-turboboost
The last command should give you:
[[email protected] ~]# systemctl status disable-intel-turboboost ● disable-intel-turboboost.service - Disable Intel Turbo Boost using pstate driver Loaded: loaded (/etc/systemd/system/disable-intel-turboboost.service; enabled; vendor preset: disabled) Active: active (exited) since Tue 2021-05-04 20:58:57 BST; 10s ago Process: 22392 ExecStart=/bin/sh -c /usr/bin/echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo (code=exited, status> Main PID: 22392 (code=exited, status=0/SUCCESS) CPU: 7ms May 04 20:58:57 amethyst systemd: Started Disable Intel Turbo Boost using pstate driver.
On my laptop it was immediately obvious Turbo Boost was turned off because the coil whine stopped instantly, but to check your current clock speed you can run:
lscpu | grep "CPU MHz" CPU MHz: 1800.019
To re-enable Turbo Boost permanently:
sudo systemctl disable disable-intel-turboboost
To re-enable Turbo Boost when needed (start service to disable Turbo Boostagain):
sudo systemctl stop disable-intel-turboboost