Skip to content

Instantly share code, notes, and snippets.

@ajithrn
Forked from Yatoom/setup.md
Last active March 3, 2022 16:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ajithrn/05c00ba6f1766ceb04d1589938e921dd to your computer and use it in GitHub Desktop.
Save ajithrn/05c00ba6f1766ceb04d1589938e921dd to your computer and use it in GitHub Desktop.
Thinkfan configuration

Thinkfan setup

Note: I configured this thinkfan setup for my old Thinkpad w520 on Ubuntu 17.10.

1. Install necessary programs

Install lm-sensors and thinkfan.

sudo apt-get install lm-sensors thinkfan

2. Setup configuration

Find the temperature control devices with

find /sys/devices -type f -name "temp*_input"

Add them to /etc/thinkfan.conf, including (level, min_temperature, max_temperature):

hwmon /sys/devices/platform/coretemp.0/hwmon/hwmon3/temp3_input
hwmon /sys/devices/platform/coretemp.0/hwmon/hwmon3/temp4_input
hwmon /sys/devices/platform/coretemp.0/hwmon/hwmon3/temp5_input
hwmon /sys/devices/platform/coretemp.0/hwmon/hwmon3/temp1_input
hwmon /sys/devices/platform/coretemp.0/hwmon/hwmon3/temp2_input

(0,	0,	60)
(1,	60,	65)
(2,	65,	70)
(3,	70,	75)
(4,	75,	80)
(5,	80,	85)
(7,	85,	32767)

3. Enable fan control

echo "options thinkpad_acpi fan_control=1" | sudo tee /etc/modprobe.d/thinkpad_acpi.conf
modprobe thinkpad_acpi
  • You can check with lsmod if thinkfan_acpi is running
  • To reload a module you need to remove it with sudo modprobe -r <module>, but this is not always possible, so we might need a reboot here.

4. Testing and running

To test thinkfan, use:

thinkfan -n

And to run it, use:

sudo service thinkfan start

And to retrieve the status, use:

service thinkfan status

5. Running on startup

To make it run at startup, we need to edit /etc/modules and add the lines below, to make the modules thinkpad_acpi and coretemp load at boot time. The thinkpad_acpi has to be loaded before coretemp.

thinkpad_acpi
coretemp

Note that this may change the /sys/devices/platform/coretemp.0/hwmon/hwmon3/temp*_input paths (hwmon3 can become hwmon2 or vice versa), probably because of the order in which the modules are loaded or something. So, in the /etc/thinkfan.conf config, you might need to update these lines.

Furthermore, we need to enable the thinkfan service via systemctl.

sudo systemctl enable thinkfan.service
sensors:
- tpacpi: /proc/acpi/ibm/thermal
indices: [0, 1, 2]
fans:
- tpacpi: /proc/acpi/ibm/fan
levels:
- [0, 0, 41]
- [1, 38, 51]
- [2, 45, 56]
- [3, 51, 61]
- [4, 55, 64]
- [5, 60, 66]
- [6, 63, 68]
- [7, 65, 74]
- [126, 73, 90]
- [127, 88, 32767]
######################################################################
# thinkfan 0.7 example config file
# ================================
#
# ATTENTION: There is only very basic sanity checking on the configuration.
# That means you can set your temperature limits as insane as you like. You
# can do anything stupid, e.g. turn off your fan when your CPU reaches 70°C.
#
# That's why this program is called THINKfan: You gotta think for yourself.
#
######################################################################
#
# IBM/Lenovo Thinkpads (thinkpad_acpi, /proc/acpi/ibm)
# ====================================================
#
# IMPORTANT:
#
# To keep your HD from overheating, you have to specify a correction value for
# the sensor that has the HD's temperature. You need to do this because
# thinkfan uses only the highest temperature it can find in the system, and
# that'll most likely never be your HD, as most HDs are already out of spec
# when they reach 55 °C.
# Correction values are applied from left to right in the same order as the
# temperatures are read from the file.
#
# For example:
# tp_thermal /proc/acpi/ibm/thermal (0, 0, 10)
# will add a fixed value of 10 °C the 3rd value read from that file. Check out
# http://www.thinkwiki.org/wiki/Thermal_Sensors to find out how much you may
# want to add to certain temperatures.
# Syntax:
# (LEVEL, LOW, HIGH)
# LEVEL is the fan level to use (0-7 with thinkpad_acpi)
# LOW is the temperature at which to step down to the previous level
# HIGH is the temperature at which to step up to the next level
# All numbers are integers.
#
# I use this on my T61p:
#tp_fan /proc/acpi/ibm/fan
#hwmon /proc/acpi/ibm/thermal (0, 10, 15, 2, 10, 5, 0, 3, 0, 3)
#hwmon /sys/devices/virtual/hwmon/hwmon0/temp1_input
hwmon /sys/devices/platform/coretemp.0/hwmon/hwmon3/temp3_input
hwmon /sys/devices/platform/coretemp.0/hwmon/hwmon3/temp4_input
hwmon /sys/devices/platform/coretemp.0/hwmon/hwmon3/temp5_input
hwmon /sys/devices/platform/coretemp.0/hwmon/hwmon3/temp1_input
hwmon /sys/devices/platform/coretemp.0/hwmon/hwmon3/temp2_input
(0, 0, 60)
(1, 60, 65)
(2, 65, 70)
(3, 70, 75)
(4, 75, 80)
(5, 80, 85)
(7, 85, 32767)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment