独立服务器 CPU 频率最大化配置指南
看看 CPU 现在混哪种模式
前提条件 系统:Linux(Debian、Ubuntu、Proxmox 等都行)
权限:root
CPU:支持动态调频(Intel Xeon、AMD EPYC / Ryzen 等)
governor
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
- powersave:节能小绵羊(频率锁低,省电但废武功)
- ondemand:按需加速(要用时才升频,可能反应慢半拍)
- performance:全程高能(我们要的就是它!💪)
确认内核到底用的哪种驱动(Intel / AMD)
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_driver
临时拉满性能
for cpu in /sys/devices/system/cpu/cpu[0-9]*; do
echo performance > $cpu/cpufreq/scaling_governor
done
重启后也保持高能
方案 A:最稳妥推荐
apt install cpufrequtils -y
echo 'GOVERNOR="performance"' >/etc/default/cpufrequtils
systemctl enable cpufrequtils
systemctl start cpufrequtils
方案 B:systemd 自定义服务
# /etc/systemd/system/cpu-performance.service
[Unit]
Description=Set CPU governor to performance
After=multi-user.target
[Service]
Type=oneshot
ExecStart=/bin/bash -c 'for cpu in /sys/devices/system/cpu/cpu[0-9]*; do echo performance > $cpu/cpufreq/scaling_governor; done'
[Install]
WantedBy=multi-user.target
systemctl daemon-reexec
systemctl daemon-reload
systemctl enable --now cpu-performance.service
