The default fan control is annoying, Thinkfan is a simple, lightweight fan control program.

vmatare/thinkfan- The minimalist fan control program

Setup Thinkfan

Install Thinkfan and lm-sensors

sudo apt install lm-sensors thinkfan

Read the doc

$ man thinkfan.conf

Check thermal devices

hwmon-style

$ find /sys/devices -type f -name "temp*_input"
/sys/devices/platform/thinkpad_hwmon/hwmon/hwmon4/temp6_input
/sys/devices/platform/thinkpad_hwmon/hwmon/hwmon4/temp3_input
/sys/devices/platform/thinkpad_hwmon/hwmon/hwmon4/temp7_input
/sys/devices/platform/thinkpad_hwmon/hwmon/hwmon4/temp4_input
/sys/devices/platform/thinkpad_hwmon/hwmon/hwmon4/temp8_input
/sys/devices/platform/thinkpad_hwmon/hwmon/hwmon4/temp1_input
/sys/devices/platform/thinkpad_hwmon/hwmon/hwmon4/temp5_input
/sys/devices/platform/thinkpad_hwmon/hwmon/hwmon4/temp2_input
/sys/devices/platform/coretemp.0/hwmon/hwmon5/temp6_input
/sys/devices/platform/coretemp.0/hwmon/hwmon5/temp13_input
/sys/devices/platform/coretemp.0/hwmon/hwmon5/temp3_input
/sys/devices/platform/coretemp.0/hwmon/hwmon5/temp10_input
/sys/devices/platform/coretemp.0/hwmon/hwmon5/temp7_input
/sys/devices/platform/coretemp.0/hwmon/hwmon5/temp4_input
/sys/devices/platform/coretemp.0/hwmon/hwmon5/temp11_input
/sys/devices/platform/coretemp.0/hwmon/hwmon5/temp8_input
/sys/devices/platform/coretemp.0/hwmon/hwmon5/temp1_input
/sys/devices/platform/coretemp.0/hwmon/hwmon5/temp5_input
/sys/devices/platform/coretemp.0/hwmon/hwmon5/temp12_input
/sys/devices/platform/coretemp.0/hwmon/hwmon5/temp9_input
/sys/devices/platform/coretemp.0/hwmon/hwmon5/temp2_input
/sys/devices/pci0000:00/0000:00:06.0/0000:02:00.0/nvme/nvme0/hwmon3/temp1_input
/sys/devices/pci0000:00/0000:00:06.0/0000:02:00.0/nvme/nvme0/hwmon3/temp2_input
/sys/devices/virtual/thermal/thermal_zone0/hwmon1/temp1_input
/sys/devices/virtual/thermal/thermal_zone9/hwmon6/temp1_input

/proc/acpi/ibm/thermal

$ cat /proc/acpi/ibm/thermal
temperatures:   49 -128 40 0 39 39 45 -128

Configure Thinkfan

edit /etc/thinkfan.conf

# temperatures should be read from
sensors:
  - tpacpi: /proc/acpi/ibm/thermal
    # A YAML list [ X1, X2, ... ] that specifies which sensors
    # e.g. `temperatures:   41 -128 42 0 37 38 41 -128`
    indices: [0, 2]

# which fan should be used
# Both hwmon-style PWM controls and /proc/acpi/ibm/fan can be used.
#  fans:
#   - hwmon: hwmon-path
#     name: hwmon-name
#     indices: index-list
#
# or a tpacpi fan:
#
# fans:
#   - tpacpi: /proc/acpi/ibm/fan

fans:
  - tpacpi: /proc/acpi/ibm/fan

# Maps temperatures to fan speeds
levels:
  # [fan-speed, lower-bound, upper-bound ]
  - [0, 0, 45]
  - [1, 45, 55]
  - [2, 55, 60]
  - [3, 60, 70]
  - [level auto, 70, 85]
  - [level disengaged, 85, 255]

Service configuration

Kernel config

$ sudo vi /etc/modprobe.d/thinkpad.conf
# add 
options thinkpad_acpi fan_control=1

Service config

$ sudo systemctl enable thinkfan.service
[sudo] password for sam: 
Synchronizing state of thinkfan.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable thinkfan
Created symlink /etc/systemd/system/multi-user.target.wants/thinkfan.service → /lib/systemd/system/thinkfan.service.
Created symlink /etc/systemd/system/sleep.target.wants/thinkfan-sleep.service → /lib/systemd/system/thinkfan-sleep.service.
Created symlink /etc/systemd/system/sleep.target.wants/thinkfan-wakeup.service → /lib/systemd/system/thinkfan-wakeup.service.

Debug tools

check fan speed

$ cat /proc/acpi/ibm/fan 
status:         disabled
speed:          1684
level:          0
commands:       level <level> (<level> is 0-7, auto, disengaged, full-speed)
commands:       enable, disable
commands:       watchdog <timeout> (<timeout> is 0 (off), 1-120 (seconds))

# set fan level
$ echo level 4 | sudo tee /proc/acpi/ibm/fan
level 4

check thermal

$ cat /proc/acpi/ibm/thermal 
temperatures:   49 -128 40 0 39 40 45 -128

check service status

$ sudo service thinkfan status
● thinkfan.service - Thinkfan, the minimalist fan control program
     Loaded: loaded (/lib/systemd/system/thinkfan.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2023-08-17 14:48:56 CST; 11min ago
    Process: 4015 ExecStart=/usr/sbin/thinkfan $THINKFAN_ARGS $DAEMON_ARGS (code=exited, status=0/SUCCESS)
   Main PID: 4016 (thinkfan)
      Tasks: 1 (limit: 38062)
     Memory: 600.0K
        CPU: 132ms
     CGroup: /system.slice/thinkfan.service
             └─4016 /usr/sbin/thinkfan -q

Aug 17 14:48:56 sam-ThinkPad-T14 systemd[1]: Starting Thinkfan, the minimalist fan control program...
Aug 17 14:48:56 sam-ThinkPad-T14 systemd[1]: Started Thinkfan, the minimalist fan control program.
Aug 17 14:48:56 sam-ThinkPad-T14 thinkfan[4016]: Temperatures(bias): 48(0), 39(0) -> level 0

Troubleshooting

ThinkPad T430: thinkfan: “ERROR: Module thinkpad_acpi doesn’t seem to support fan_control”

$ sudo service thinkfan status 
○ thinkfan.service - Thinkfan, the minimalist fan control program
     Loaded: loaded (/lib/systemd/system/thinkfan.service; enabled; vendor preset: enabled)
     Active: inactive (dead)
sam@sam-ThinkPad-T14:~$ sudo service thinkfan start
Job for thinkfan.service failed because the control process exited with error code.
See "systemctl status thinkfan.service" and "journalctl -xeu thinkfan.service" for details.

sam@sam-ThinkPad-T14:~$ sudo systemctl status thinkfan.service
× thinkfan.service - Thinkfan, the minimalist fan control program
     Loaded: loaded (/lib/systemd/system/thinkfan.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Thu 2023-08-17 14:26:44 CST; 17s ago
    Process: 4457 ExecStart=/usr/sbin/thinkfan $THINKFAN_ARGS $DAEMON_ARGS (code=exited, status=1/FAILURE)
        CPU: 2ms

Aug 17 14:26:44 sam-ThinkPad-T14 systemd[1]: Starting Thinkfan, the minimalist fan control program...
Aug 17 14:26:44 sam-ThinkPad-T14 thinkfan[4457]: ERROR: ~TpFanDriver: Resetting fan control in /proc/acpi/ibm/fan: Invalid argument
Aug 17 14:26:44 sam-ThinkPad-T14 thinkfan[4457]: ERROR: Module thinkpad_acpi doesn't seem to support fan_control
Aug 17 14:26:44 sam-ThinkPad-T14 systemd[1]: thinkfan.service: Control process exited, code=exited, status=1/FAILURE
Aug 17 14:26:44 sam-ThinkPad-T14 systemd[1]: thinkfan.service: Failed with result 'exit-code'.
Aug 17 14:26:44 sam-ThinkPad-T14 systemd[1]: Failed to start Thinkfan, the minimalist fan control program.

don’t forget to configure kernel

$ sudo vi /etc/modprobe.d/thinkpad.conf
# add 
options thinkpad_acpi fan_control=1

Reference