How to Enable CPU Frequency Scaling in Debian 12 Bookworm
Categories:
4 minute read
Introduction
CPU frequency scaling is a crucial feature that allows the processor to dynamically adjust its clock speed based on system demand. This optimizes power consumption and performance, making it especially useful for laptops and energy-efficient computing. In Debian 12 (Bookworm), CPU frequency scaling can be controlled using the CPUFreq subsystem, which allows users to adjust the CPU governor and set frequency limits.
This article will guide you through the steps to enable CPU frequency scaling in Debian 12 Bookworm, covering the necessary tools, configuration methods, and troubleshooting tips.
Prerequisites
Before proceeding, ensure that:
- You have Debian 12 Bookworm installed.
- You have administrative privileges (root or sudo access).
- Your system supports CPU frequency scaling (most modern CPUs do).
Step 1: Check CPU Scaling Support
First, confirm that your CPU supports frequency scaling. Open a terminal and run:
lscpu | grep "MHz"
This will display information about the current CPU speed. To check if the CPU scaling driver is available, use:
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
If this command outputs a list of available governors, your CPU supports scaling.
Step 2: Install CPU Frequency Utilities
Debian provides cpufrequtils and lm-sensors to manage CPU frequency scaling. Install them with:
sudo apt update
sudo apt install cpufrequtils lm-sensors
These utilities allow you to view and modify CPU scaling settings.
Step 3: Verify the Active CPU Scaling Driver
Check which CPU frequency driver is being used:
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_driver
Common drivers include:
- intel_pstate (for Intel CPUs)
- acpi-cpufreq (for AMD and other CPUs)
If no driver is listed, ensure that your kernel supports frequency scaling.
Step 4: Set CPU Scaling Governor
The CPU governor controls how the system adjusts CPU frequencies. Common governors include:
- performance – Runs the CPU at maximum speed.
- powersave – Uses the lowest frequency to save power.
- ondemand – Adjusts CPU speed dynamically based on load.
- conservative – Similar to ondemand but scales more gradually.
- schedutil – Uses kernel scheduling data to optimize scaling.
To check the current governor:
cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
To change the governor (e.g., to ondemand):
sudo cpufreq-set -g ondemand
To set the governor permanently, edit the configuration file:
sudo nano /etc/default/cpufrequtils
Modify or add the following line:
GOVERNOR="ondemand"
Save the file and restart the cpufrequtils service:
sudo systemctl restart cpufrequtils
Step 5: Adjust CPU Frequency Limits
To manually set CPU frequency limits, check the available frequencies:
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies
To set a specific frequency (e.g., 1.5GHz):
sudo cpufreq-set -f 1500000
To set minimum and maximum frequencies:
sudo cpufreq-set -d 800MHz -u 2.5GHz
Replace values with those supported by your CPU.
Step 6: Enable CPU Frequency Scaling at Boot
To ensure CPU scaling settings persist after reboot, add the following to /etc/rc.local (create the file if it doesn’t exist):
#!/bin/bash
cpufreq-set -g ondemand
exit 0
Then, make the script executable:
sudo chmod +x /etc/rc.local
Step 7: Monitor CPU Frequency Scaling
To monitor CPU frequencies dynamically, use:
watch -n 1 "cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq"
Alternatively, install and use cpufreq-info:
sudo apt install cpufrequtils
cpufreq-info
Troubleshooting
1. CPU Frequency Scaling Not Working
If scaling is not working, try the following:
Ensure the required kernel modules are loaded:
sudo modprobe acpi_cpufreq sudo modprobe intel_pstateCheck for conflicting power management tools (such as TLP or Laptop Mode Tools) that may override settings.
2. Changes Don’t Persist After Reboot
Ensure the
/etc/default/cpufrequtilsfile is correctly configured.Verify that the
cpufrequtilsservice is enabled:sudo systemctl enable cpufrequtils
3. Some Governors Are Missing
The intel_pstate driver supports only powersave and performance governors.
Use the
acpi-cpufreqdriver if you need more options:sudo modprobe acpi-cpufreq
Conclusion
Enabling CPU frequency scaling in Debian 12 Bookworm optimizes power usage and performance by dynamically adjusting CPU speeds. By installing cpufrequtils, selecting the appropriate governor, and setting frequency limits, you can fine-tune your system for efficiency or performance. Regular monitoring and adjustments ensure your settings remain optimal for your workload.
Following this guide, you should now have a working CPU frequency scaling setup in Debian 12. Happy computing!
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.