The Ubuntu 18.04 CPU Frequency Governor Fix

It’s different on Fedora. That uses a completely different script: (supposed to be in /etc/init.d/performance)

#! /bin/bash
#
# performance sets cpu governor
#
# chkconfig: 2345 10 90
#
# description: Set the CPU Frequency Scaling governor to "performance"
#
### BEGIN INIT INFO
# Provides: $performance
### END INIT INFO

PATH=/sbin:/usr/sbin:/bin:/usr/bin

case "$1" in
    start)
        for CPUFREQ in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
        do
                [ -f $CPUFREQ ] || continue
                echo -n performance > $CPUFREQ
        done
        ;;
    restart|reload|force-reload)
        echo "Error: argument '$1' not supported" >&2
        exit 3
        ;;
    stop)
        ;;
    *)
        echo "Usage: $0 start|stop" >&2
        exit 3
        ;;
esac

Then:

chmod +x /etc/init.d/performance
chkconfig performance on
service performance restart

The last one verifies it returns the error you wrote into the script and that it’s actually working.

( adapted from https://www.servernoobs.com/avoiding-cpu-speed-scaling-in-modern-linux-distributions-running-cpu-at-full-speed-tips/ )

1 Like