在Arch Linux中调整部分联想主板风扇转速(ThinkServer TS540)

部分联想主板BIOS风扇控制只有 Intelligent Cooling Engine (ICE) 功能,无法手动修改风扇转速曲线。

我发现手上这块主板在进入系统后风扇就变成固定转速,而且 sensors 看不到转速,那第一步就是先安装驱动。通过 sensors-detect 得知控制器为IT8792E,从网上找到了可用的驱动:a1wong/it87 (github.com) 按照文档 make & make install 安装即可。

然后加载驱动,需要忽略资源冲突,强制设备id为IT8792E的0x8733:

modprobe it87 ignore_resource_conflict=1 force_id=0x8733

然后就能在 sensors 里看到风扇转速、电压了。

Linux中我们一般通过Hwmon来手动调整风扇转速,路径是 /sys/class/hwmon/hwmon* ,*是设备序号。

但是到了这里发现无论怎么调整参数,转速都不会变化,唯一有区别的就是 pwm1_enable 设置为手动模式 1 的时候,转速为2600RPM左右,自动模式 2 的时候转速为900RPM。这个问题无论是驱动还是BIOS造成的,都没法简单解决。但是这两个转速正好可以当成两档来控制,所以我写了个脚本监控CPU温度,到达临界温度后指定 pwm1_enable 模式来切换转速。

#!/bin/bash

sleep 3
modprobe it87 ignore_resource_conflict=1 force_id=0x8733
sleep 5

getPath() {  # $1 which path:  0 it8792  1 coretemp
    cd /sys/class/hwmon
    find=false
    for subdir in `ls`
    do
        cd $subdir
	nameVar=$(head -n 1 name)
        if [ $1 = 0 ]
        then 
            if [ $nameVar = "it8792" ]
            then
                find=true
                it8792_path=$(pwd)
        fi
        else
            if [ $nameVar = "coretemp" ]
            then
                find=true
                coretemp_path=$(pwd)
            fi
        fi
        
        if $find ;then 
            echo "Find path."
            break
        fi
        
        cd ..
    done
}

it8792_path=""
coretemp_path=""

getPath 0
echo $it8792_path
if [ -z $it8792_path ]; then
    exit
fi

getPath 1
echo $coretemp_path
if [ -z $coretemp_path ]; then
    exit
fi

cd $it8792_path
echo 2 > pwm1_enable

cd $coretemp_path
while true
do
    sleep 2
    temp=$(head -n 1 temp1_input)
    mode=$(head -n 1 $it8792_path/pwm1_enable)
    if (( $temp > 50000 ))
    then
        if [ $mode = "2" ]; then
            echo 1 > $it8792_path/pwm1_enable
        fi
    else
        if [ $mode = "1" ]; then
            echo 2 > $it8792_path/pwm1_enable
        fi
    fi
done

再把这个脚本注册到systemd开机自启就行了,先在 /usr/lib/systemd/system 下新建文件 It87FanControl.service,内容为

[Unit]
Description=It87FanControl

[Service]
ExecStart=/home/it87_fan.sh  #你的脚本路径

[Install]
WantedBy=multi-user.target

然后 systemctl enable It87FanControl.service 开启服务就可以了。这样就能够开机后自动加载驱动,并根据温度两档调整转速。

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注