环境:玩客云 N1 Armbian

问题:玩客云刷了 Armbian 之后跑 Docker 挂 BT 下载 平均一天死机一次

结论:硬件配置太低,强刷 Armbian 高内核版本 CPU 持续高主频导致温度高于 45 长时间就死机了

解决办法:1. 花钱买无线通断器

                   1. 买 USB 小风扇降温

                   3.CPU 降频,慢就慢点,我不差你这点时间,温度低了再给我升上去

思路:  主要用到调整 CPU 的的命令 cpufreq-set ,写个脚本每 5 秒钟看下温度,高于 45 就降频,  低 于 41 就升频

副作用:下载速度时快时慢,无所谓了,不死机就行

步骤:

  1. 写脚本,动态调整主频

vi /usr/sbin/cpu-control.sh

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/sh 

while true
do
set -- $(cat /sys/class/thermal/thermal_zone0/temp \
/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)
TEMP=$1
GOVERNOR=$2

if [ "$TEMP" -le 42000 ] && [ "$GOVERNOR" = "ondemand" ]; then
cpufreq-set -d 400m -u 1200m
fi

if [ "$TEMP" -ge 45000 ] && [ "$GOVERNOR" = "ondemand" ]; then
cpufreq-set -d 400m -u 600m
fi

sleep 5
done

运行一下,看看效果,拷贝个大文件到玩客云上,可以明显看到温度超过 45 后 降到 600,温度也下来了

 写成服务,开机运行

vi /etc/systemd/system/cpu-control.service

1
2
3
4
5
6
7
8
9
10
11
[Unit]
Description=CPU Governor Control by Temperature

[Service]
Type=simple
ExecStart=/bin/sh /usr/sbin/cpu-control.sh

[Install]
WantedBy=multi-user.target

 

拷贝文件,启动看看效果