Manage Intel Turbo Boost with systemd

If you have a little laptop with an Intel CPU that supports turbo boost, you might find that it’s getting a little hot when you’re using it on your lap.

For example, taking a look at my CPU:
lscpu |egrep "Model name|MHz"

We can see that it’s a 2.7GHz CPU with turbo boost taking it up to 3.5GHz.

Model name: Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
CPU MHz: 524.633
CPU max MHz: 3500.0000
CPU min MHz: 400.0000

Here’s a way that you can enable and disable turbo boost with a systemd service, which lets you hook it into other services or disable it on boot.

By default, turbo boost is on, so starting our service will disable it.

Create the service.
cat << EOF | sudo tee \
/etc/systemd/system/disable-turbo-boost.service
[Unit]
Description=Disable Turbo Boost on Intel CPU
 
[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
EOF

Reload systemd manager configuration.
sudo systemctl daemon-reload

Test it by running something CPU intensive and watching the current running MHz.

cat /dev/urandom > /dev/null &
lscpu |grep "CPU MHz"

CPU MHz: 3499.859

Now disable turbo boost and check the CPU speed again.
sudo systemctl start disable-turbo-boost
lscpu |grep "CPU MHz"

CPU MHz: 2699.987

Don’t forget to kill the CPU intensive process ๐Ÿ™‚

kill %1

If you want to disable turbo boost on boot by default, just enable the service.

sudo systemctl enable disable-turbo-boost

As turbo boost is enabled on a Linux system by default, to turn it back on you just need to turn off the script which disables it.

sudo systemctl disable disable-turbo-boost

24 thoughts on “Manage Intel Turbo Boost with systemd

  1. your script is incomplete, I am getting this error:

    @archlinux โžœ ~ ยป sudo systemctl enable disable-turbo-boost
    The unit files have no installation config (WantedBy, RequiredBy, Also, Alias
    settings in the [Install] section, and DefaultInstance for template units).
    This means they are not meant to be enabled using systemctl.
    Possible reasons for having this kind of units are:
    1) A unit may be statically enabled by being symlinked from another unit’s
    .wants/ or .requires/ directory.
    2) A unit’s purpose may be to act as a helper for some other unit which has
    a requirement dependency on it.
    3) A unit may be started when needed via activation (socket, path, timer,
    D-Bus, udev, scripted systemctl call, …).
    4) In case of template units, the unit is meant to be enabled with some
    instance name specified.

  2. Your showing people the longest route to do something. Make sure you read the manuals first before posting articles.

  3. Turbo boost is enabled on a Linux system by default, so to turn it back on, just turn off the script which disables it.

    sudo systemctl disable disable-turbo-boost

    Basically, disable the disable service.

  4. Hi,
    So, I have an issue.
    First of all, the script does nothing whatsoever on my laptop. I mean, it gives some random CPU readouts.

    I have an HP Stream 11, with Celeron N3060 CPU.
    It runs at a base clock speed of 1,60Ghz; 2 cores, no HT.
    It also has a boost speed of 2,48Ghz.
    In Windows, the little device runs at that 2,48Ghz constantly under load, without throttling down.
    The CPU does not get hot enough.
    In Linux (GalliumOS; a Xubuntu variant), even using all your shenanigans, the CPU core speed just does not exceed 1,60Ghz.

    It appears to me, Linux can’t boost CPU clock speed to turbo speeds.
    What do I need to do, to get at least a boost to 2Ghz?

  5. it’s not work on ubuntu 18, i check that service by systemctl status disable-turbo-boost.service
    but it’s result is :
    disable-turbo-boost.service – Disable Turbo Boost on Intel CPU
    Loaded: loaded (/etc/systemd/system/disable-turbo-boost.service; enabled; vendor preset: enabled)
    Active: failed (Result: exit-code) since Tue 2018-11-27 13:47:22 WITA; 25s ago
    Process: 2904 ExecStart=/bin/sh -c /usr/bin/echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo (code=exited, status=127)
    Main PID: 2904 (code=exited, status=127)

    Nov 27 13:47:22 gungp-GL552VX systemd[1]: Started Disable Turbo Boost on Intel CPU.
    Nov 27 13:47:22 gungp-GL552VX sh[2904]: /bin/sh: 1: /usr/bin/echo: not found
    Nov 27 13:47:22 gungp-GL552VX systemd[1]: disable-turbo-boost.service: Main process exited, code=exited, status=127/n/a
    Nov 27 13:47:22 gungp-GL552VX systemd[1]: disable-turbo-boost.service: Failed with result ‘exit-code’.

  6. I don’t know if that CPU is supported under Linux, I would assume so, but maybe not. So is turbo boost enabled? How are you checking the current CPU MHz? What happens you stress the CPU, like:

    dd if=/dev/urandom of=/dev/null

  7. Looks like echo is in a different place in Ubuntu, see the error you pasted:

    /bin/sh: 1: /usr/bin/echo: not found

    Replace the path to echo in the script with the result of this command:

    which echo

  8. Love it. Just discovered today that turbo was chewing through my battery life. This is an elegant solution to enabling or disabling it. Thanks.

  9. Works nicely on Fedora 30 — kernel 5.0.11

    — just hope someone makes an entire package for linux for
    use with laptops to save power….

    everytime on a new install i have to change the governor to powersave, disable turbo boost and run powertop/tlp to save battery.

  10. Cheers for this. Thanks to HP being short sighted my Omen gaming laptop can’t supply enough power to the GPU and boost the CPU at the same time without throttling. Ditching turbo gives nice consistent frame rates and a slightly cooler laptop!

  11. The only thing it did on my laptop was to limit the max frequency to 1700 MHz, so it would drop to 800 when something demanding was happening ๐Ÿ™

    Its range is from 800 to 2600.

  12. Hello,
    This is a handy utility to have.
    On Linux Mint 20.3, I can enable it and disable Turboboost, but I cannot disable it to re-enable Turboboost.
    Can you modify it to work for me?

  13. Hi Thomas, stopping the service re-enables turbo boost for me on my machine. Are you sure that you’ve tested it by pushing a CPU up to validate that it’s not going back over your base MHz?

    This disables it for me, and I see my CPU going from 4.5GHz max down to 3GHz max (checked with grep 'cpu MHz' /proc/cpuinfo)

    sudo systemctl start disable-turbo-boost

    Then, to re-enable turbo boost I just stop the disable service and it goes from 3GHz back up to 4.5GHz.

    sudo systemctl stop disable-turbo-boost

Leave a Reply

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