掌握硬體溫度與效能狀態,是 Linux 系統管理與效能調校的基礎。本文整合命令列工具、圖形化介面與核心調節機制,提供一站式硬體監控解決方案。
# 需先執行 sensors-detect 並載入對應核心模組
sensors
# 或直接讀取 sysfs
cat /sys/class/thermal/thermal_zone*/temp
/proc/cpuinfo 僅顯示處理器型號與旗標,不含溫度資訊。
cpufreq-info
輸出包含:當前頻率、最小/最大頻率、可用調節器、當前調節器。
# 針對特定核心 (c = 核心編號)
sudo cpufreq-set -c 0 -f 2.00GHz # 設定固定頻率 (需支援 userspace 調節器)
sudo cpufreq-set -c 0 -g performance # 切換至效能模式
sudo cpufreq-set -c 0 -g powersave # 切換至省電模式
sudo cpufreq-set -c 0 -g ondemand # 切換至隨需調節 (預設推薦)
sudo cpufreq-set -c 0 -g conservative # 保守模式 (平滑調節)
五大調節器特性對照:
| 調節器 | 行為 | 適用場景 |
|---|---|---|
| performance | 固定最高頻率 | 高效能運算、基準測試 |
| powersave | 固定最低頻率 | 電池供電、低負載待機 |
| ondemand | 有負載即衝頂,閒置即降頻 | 桌面/伺服器通用 (預設) |
| conservative | 平滑漸進調節 | 筆電、噪音敏感環境 |
| userspace | 完全由使用者空間程式控制 | 自訂調節邏輯 (如 thermald) |
# 偵測並自動產生模組載入設定
sudo sensors-detect
# 查看已載入模組
cat /etc/modules
sudo apt-get install hddtemp
sudo hddtemp /dev/sda
安裝 tp-fancontrol (或 thinkfan) 可根據 GPU/CPU 溫度自動調整風扇轉速,實現主動散熱管理:
# 範例 thinkfan 配置 /etc/thinkfan.conf
tp_fan /proc/acpi/ibm/fan
tp_thermal /proc/acpi/ibm/thermal
(0, 0, 40)
(1, 38, 45)
(2, 44, 55)
(3, 52, 65)
(4, 60, 70)
(5, 68, 77)
(7, 74, 90)
現代發版建議安裝 thermald (Intel Thermal Daemon) 或 power-profiles-daemon,由系統服務自動根據熱力策略調整 CPU 頻率、風扇與裝置電源狀態,無需手動干預。
lm-sensors + sensors-applet 建立基礎監控視覺化。collectd + Graphite/Prometheus 進行歷史趨勢分析與告警。thermald + tlp 獲得最佳續航與散熱平衡。