Fancontrol
Typical lm_sensors output. | |
Repository | github.com /lm-sensors/lm-sensors |
---|---|
Written in | C |
Operating system | Linux |
Included with | lm_sensors |
Type | System fan control |
License | GNU General Public License |
Website | hwmon.wiki.kernel.org |
fancontrol is a simple bash script that lets you control your fans on Linux machines. It is part of the lm_sensors package. It is not very easy or strait-forward to setup but it does work really well once you've got it working on your machine.
The Setup[edit]
The lm_sensors package comes with a tool called pwmconfig
that will try to make any PWM-enabled system fan spin up to it's maximum so you can identify it. It will let you write a configuration file to /etc/fancontrol
once that's done.
That configuration file could look like:
# Configuration file generated by pwmconfig, changes will be lost
#
INTERVAL=10
DEVPATH= hwmon1=devices/pci0000:00/0000:00:18.3 hwmon2=devices/platform/it87.552
DEVNAME= hwmon1=k10temp hwmon2=it8720
FCTEMPS= hwmon2/pwm1=hwmon1/temp1_input
FCFANS= hwmon2/pwm1=hwmon2/fan1_input
MINTEMP= hwmon2/pwm1=20
MAXTEMP= hwmon2/pwm1=70
MINSTART=hwmon2/pwm1=90
MINSTOP= hwmon2/pwm1=88
# Must be lower than minstop/minstart
MINPWM= hwmon2/pwm1=86
MAXPWM=255
The Configuration file generated by pwmconfig, changes will be lost comment can safely be ignored, changes will only be lost if you re-run pwmconfig
and ask it to re-write that configuration file.
One worth-while trick is to add a line that says AVERAGE=
to the fancontrol configuration file.
It has to list a sensor and a value like 3 or 4. Using the above example, that would look like:
AVERAGE=hwmon2/pwm1=4
AVERAGE
is useful if you have a machine with temperature sensors that report values all over the place (40, 50, 42, 52, etc). Taking the average of several values makes the fan spin at a more constant rate at low or medium load if the reported temperature jumps around a lot at those values.
You can see what hwmon
devices are present on a machine with:
ls /sys/devices/*/*/hwmon/
And you can list the available PWM controls for fans with:
ls /sys/devices/*/*/hwmon/*/pwm?
That fans are listed does not mean a) there's any fan connected or b) that the PWM interface actually works for controlling any fans. This is why the pwmconfig
setup utility will stop fans and then ramp them up to full speed during the configuration process: It lets you hear and see what fans can be controlled.
Configuring fancontrol
for a machine with many fans can be kind of troublesome. Here's an example of what you can do if you have a bit of patience:
INTERVAL=10
DEVPATH= hwmon0=devices/pci0000:00/0000:00:03.1/0000:07:00.0 hwmon1=devices/pci0000:00/0000:00:18.3 hwmon2=devices/platform/it87.2624
DEVNAME= hwmon0=amdgpu hwmon1=k10temp hwmon2=it8686
# For kernel 5.7+, temp1 with 5.6, temp2 with 5.7
FCTEMPS= hwmon0/pwm1=hwmon0/temp1_input hwmon2/pwm1=hwmon1/temp2_input hwmon2/pwm5=hwmon1/temp1_input hwmon2/pwm2=hwmon2/temp5_input hwmon2/pwm4=hwmon0/temp1_input hwmon2/pwm3=hwmon2/temp5_input
FCFANS= hwmon0/pwm1=hwmon0/fan1_input hwmon2/pwm1=hwmon2/fan1_input hwmon2/pwm5=hwmon2/fan5_input hwmon2/pwm2=hwmon2/fan2_input hwmon2/pwm4=hwmon2/fan4_input hwmon2/pwm3=hwmon2/fan3_input
###############################################################################################################
# SYS1 SYS3 SYS2
# GPU fans CPU fan 1 CPU fan 2 Rear Casefan Bottom Casefan Front top fan
# temp by GPU temp by CPU temp by CPU temp by vrm-mos temp by GPU temp by vrm-mos
MINTEMP= hwmon0/pwm1=54 hwmon2/pwm1=54 hwmon2/pwm5=54 hwmon2/pwm2=58 hwmon2/pwm4=54 hwmon2/pwm3=58
MAXTEMP= hwmon0/pwm1=66 hwmon2/pwm1=60 hwmon2/pwm5=56 hwmon2/pwm2=64 hwmon2/pwm4=64 hwmon2/pwm3=64
MINSTART=hwmon0/pwm1=50 hwmon2/pwm1=63 hwmon2/pwm5=63 hwmon2/pwm2=60 hwmon2/pwm4=60 hwmon2/pwm3=80
###############################################################################################################
# 78 128 80
MINSTOP= hwmon0/pwm1=70 hwmon2/pwm1=80 hwmon2/pwm5=80 hwmon2/pwm2=110 hwmon2/pwm4=80 hwmon2/pwm3=100
MINPWM= hwmon0/pwm1=70 hwmon2/pwm1=80 hwmon2/pwm5=80 hwmon2/pwm2=110 hwmon2/pwm4=80 hwmon2/pwm3=100
MAXPWM= hwmon0/pwm1=250 hwmon2/pwm1=200 hwmon2/pwm5=170 hwmon2/pwm2=190 hwmon2/pwm4=220 hwmon2/pwm3=255
AVERAGE= hwmon0/pwm1=4 hwmon2/pwm1=4 hwmon2/pwm5=4 hwmon2/pwm2=4 hwmon2/pwm4=4 hwmon2/pwm3=4
Notice that in the above example the front and rear case fans are controlled by the VRM temperatures, not the CPU temperature. And the bottom case fan, and the GPU fan, are both controlled by the GPU temperature. Configuring a setup like that takes a bit of patience. It may be worth it since you only have to do it once.
Requirements[edit]
Here's where it gets ugly very quickly: fancontrol is a simple bash script. It is completely incapable of talking to any hardware that's not setup by the kernels hwmon sub-system. You will, therefore, need a kernel module capable of talking to the actual hardware interfaces on the motherboard. This will, sadly, in many cases require a out-of-kernel module. Most modern AMD AM4 motherboards require a out-of-kernel version of the it87
module.
fancontrol
is not a separate package. It is a part of the lm_sensors
package, that is what you need to install to get the /usr/sbin/fancontrol
script and the fancontrol.service
systemd service file.
Ugly Pitfalls To Be Aware Of[edit]
fancontrol
version 0.71 (and any earlier version) will just die if something else puts a write lock on any of the fans it controls. That's actually a big deal and a pretty serious problem worth being aware of. CoreCtrl does that. CoreCtrl will only try to control the GPU fan, so this is only a problem if you use fancontrol
to control the GPU fan or you're using the GPU temperature sensor to control other fans. It is a big problem if that's the case. Consider this:
- Your machine is idle.
fancontrol
controls the CPU fan, the case fans and the GPU fan.- You start something like CoreCtrl and it kills
fancontrol
, leaving the CPU fan and the case fines stock at manual, not auto, at a low RPM. - Now you launch a game. CoreCtrl will ramp up the GPU fan speed, since it controls that, but the rest of the fans, including the CPU fan, are stuck at the speed they were at when
fancontrol
died.
You can probably see why that would be a problem.. The simple solution is to not use any other software that tries to control your fans if you use fancontrol
.
Enable comment auto-refresher