# 安装工具(如未安装)
sudo apt install cpufrequtils # 或 cpupower(部分系统需安装linux-cpupower)
# 设置为性能模式(最高频率)
sudo cpufreq-set -g performance # 对所有CPU核心生效
# 或指定单个核心(如核心0)
sudo cpufreq-set -c 0 -g performance
验证:cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor,输出应为performance。方法一:通过systemd服务
创建服务文件:
sudo tee /etc/systemd/system/cpu-performance.service > /dev/null <<'EOF'
[Unit]
Description=Set CPU governor to performance
After=multi-user.target
[Service]
Type=oneshot
ExecStart=/bin/bash -c 'for f in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do echo performance > $f; done'
RemainAfterExit=true
[Install]
WantedBy=multi-user.target
EOF
启用服务:
sudo systemctl daemon-reload
sudo systemctl enable --now cpu-performance.service
方法二:修改GRUB配置(需重启)
sudo nano /etc/default/grub
# 在GRUB_CMDLINE_LINUX_DEFAULT中添加(Intel CPU)
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash intel_pstate=disable"
sudo update-grub
sudo reboot
适用于需彻底禁用内核自动变频的场景(如虚拟机环境)。
# 安装msr-tools
sudo apt install msr-tools
# 禁用Turbo Boost(降低功耗)
sudo modprobe msr
sudo wrmsr 0x1a0 0x4000850089
# 启用Turbo Boost(提升性能)
sudo wrmsr 0x1a0 0x850089
注意:修改前需确认CPU是否支持Turbo Boost,且可能影响稳定性。powersave)。cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
# 或使用工具
cpufreq-info # 显示详细频率信息
cpupower frequency-info # 更详细的频率策略和状态