要将 Debian 系统中所有 CPU 核心的频率调整到最大,可以使用以下方法
分类:分享
方法 1:使用 cpufrequtils
工具
- 安装
cpufrequtils
(如果尚未安装):sudo apt update sudo apt install cpufrequtils
- 将所有核心的调节器设置为
performance
:
performance
调节器会将 CPU 频率锁定在最大频率。sudo cpufreq-set -r -g performance
其中:
-r
:递归应用到所有 CPU 核心。-g performance
:将调节器设置为performance
。
- 验证设置:
运行以下命令查看当前频率和调节器:cpufreq-info
或者:
grep -E "MHz|governor" /proc/cpuinfo
方法 2:直接通过 sysfs
接口
- 查看当前最大频率:
cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq
这会显示 CPU 支持的最大频率(单位:kHz)。
- 将所有核心的调节器设置为
performance
:echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
- 验证设置:
cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governorcat /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq
方法 3:使用 tlp
电源管理工具
如果你已经安装了 tlp
,可以通过以下方式强制 CPU 运行在最大频率:
- 编辑
tlp
配置文件:sudo nano /etc/tlp.conf
- 找到并修改以下参数:
CPU_SCALING_GOVERNOR_ON_AC=performance CPU_SCALING_GOVERNOR_ON_BAT=performance
- 重启
tlp
服务:sudo systemctl restart tlp
方法 4:使用 systemd
服务(开机自动设置)
- 创建
systemd
服务文件:sudo nano /etc/systemd/system/set-max-cpu-freq.service
- 添加以下内容:
[Unit] Description=Set CPU to Maximum Frequency [Service] Type=oneshot ExecStart=/bin/bash -c "echo performance | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor" [Install] WantedBy=multi-user.target
- 启用并启动服务:
sudo systemctl enable set-max-cpu-freq.service sudo systemctl start set-max-cpu-freq.service
方法 5:使用 gnome-cpu-freq
(适用于 GNOME 桌面环境)
- 安装
gnome-cpu-freq
:sudo apt install gnome-cpu-freq
- 打开
gnome-cpu-freq
:
在 GNOME 应用程序菜单中搜索 "CPU Power Manager" 或 "CPU Frequency Selector"。 - 将所有核心的调节器设置为
Performance
:
在图形界面中选择Performance
模式。
验证所有核心是否运行在最大频率
运行以下命令查看当前频率:
watch -n 1 "grep 'MHz' /proc/cpuinfo"
或者:
cpufreq-info
确保所有核心的频率接近或等于最大频率。