Page 1 of 1

[Debian] Thinkfan Installation Guide + Configuration Tutorial

Posted: Sun Nov 15, 2015 8:40 pm
by Sense
Hi everyone. This community has been extremely helpful to me and I've decided to write a beginner friendly guide to installing and configuring thinkfan.

I've been running thinkfan on my T420 Debian 8 setup for about 2 months now, and it's been running great. Although this package is not required, I would highly recommend installing it because by default, the fan will be stuck at a fixed rate (3300 RPM) without setup. This means that your laptop might be improperly cooled, leading to either overheating or overcooling, wasting precious battery power.

I would like to remind everyone that although I've tested and done the research to make sure these settings are safe to use, I am NOT responsible for what happens to your computer should something go wrong. Improper configuration can definitely harm the hardware of your computer so please do take your time to understand what each step does and double check your inputs.

Let's get started!

0. Make sure you have root privileges by either typing $ sudo or log in as root:

Code: Select all

$ su 
1. Download and install the thinkfan package:

Code: Select all

$ sudo apt-get install thinkfan
2. Add the 'coretemp' kernel module to be loaded at boot time

Code: Select all

$ sudo sh -c 'echo coretemp >> /etc/modules'
If that looks cryptic to you, it's a very simple command to add 'coretemp' to the end of the file. You can use your favorite text editor to open 'modules' and add in 'coretemp' yourself if you prefer.

3. Since your changes won't take place until you restart your computer, let's manually load 'coretemp' this one time to continue with our configuration

Code: Select all

$ sudo modprobe coretemp
4. This is the most IMPORTANT step. You will be editing your fan speed parameters by defining upper bound and lower bound levels to trigger different fan speeds. There are several levels ranging from 0 to 7 and 127. 0 is when your fan is completely disabled, 1 is the slowest rotational speed and 7 is the highest. 127 is the maximum fan speed and it's there in case the rare chance that computer fails to cool even at level 7. The temperature is expressed in Celsius NOT Fahrenheit!

Format:

Code: Select all

(fan_level_#,           lower_bound_temp,          upper_bound_temp)
Example:
(0, 0, 42)
(1, 40, 48)
(2, 46, 53)
...

The above example turns the fan on when the temperature reaches 43 Celsius. As level 1 fan cools your computer down, when it reaches below 40, say 39, it will switch to fan_level_0, turning the fan off completely. If you are doing lots of processing, the temperature will rise and if it goes above 48, fan_level_2 is activated and so forth!

5. Now that you understand how thinkfan works, let's make some edits. Open up your thinkfan.conf with your favorite editor. I will use gedit in this example:

Code: Select all

$ gedit /etc/thinkfan.conf
Add the following line to the configuration file to allow thinkfan to read from your sensors:

Code: Select all

hwmon /sys/devices/virtual/thermal/thermal_zone0/temp
You can make your own lower and upper bound but if you want to use my configuration (which is based on another user's T420 setup) here it is:

Code: Select all

hwmon /sys/devices/virtual/thermal/thermal_zone0/temp

(0,	0,	42)
(1,	40,	47)
(2,	45,	52)
(3,	50,	57)
(4,	55,	62)
(5,	60,	67)
(6,	65,	72)
(7,	70,	77)
(127,	75,	32767)
6. Enable fan control to modprobe.d by adding the following lines. This file did not exist for me so go ahead and create it if you need to.

Code: Select all

$ touch /etc/modprobe.d/thinkfan.conf
$ sudo sh -c 'echo "options thinkpad_acpi fan_control=1" >> /etc/modprobe.d/thinkfan.conf'
7. Reload kernel module 'thinkpad_acpi' and finish setting up thinkfan with auto startup at boot

Code: Select all

$ sudo modprobe -r thinkpad_acpi
$ sudo modprobe thinkpad_acpi
Make sure to set START="yes" here:

Code: Select all

$ sudo gedit /etc/default/thinkfan
8. Either restart or start thinkfan manually:

Code: Select all

$ sudo /etc/init.d/thinkfan start
9. Final check to make sure everything is running correctly!
To see the current fan speed, level, and status information, type:

Code: Select all

$ sudo cat /proc/acpi/ibm/fan
To see current coretemp, type:

Code: Select all

$ sensors
If your temperatures aren't showing up, you may have to detect sensors and add them.
Run the following command and keep pressing ENTER or type YES when the the choice offer is capitalized and NO when the choice is capitalized. I would just press ENTER because that will select the default options automatically.

Code: Select all

$ sensors-detect
You can also check to make sure the thinkfan service is running the background by typing:

Code: Select all

$ systemctl status thinkfan.service
10. Congratulations! Now you know everything you need to install, troubleshoot, and optimize your fan control settings. If you have any questions, please do not PM me. Just post here so other's can view it too, and I will do my best to answer you as timely as I can. Thanks.

Re: [Debian] Thinkfan Installation Guide + Configuration Tutorial

Posted: Sun Nov 15, 2015 11:53 pm
by kony
Sense wrote:by default, the fan will be stuck at a fixed rate (3300 RPM) without setup. This means that your laptop might be improperly cooled, leading to either overheating or overcooling, wasting precious battery power.
I cannot be certain, as I use T430, not T420, and Linux Mint instead of vanilla Debian, but on my laptop it certainly is not true (and I would assume T420 and T430 share basically the same hardware, just like Mint operates on the same software as Debian, being based on it). When I dumped Linux Mint 15 Xfce (on which I used thinkfan) and installed LM17 KDE, I decided not to install thinkfan as the default settings seem fine to me - the laptop is both silent and cool when not under heavy stress, and is well cooled when needed to be (like when I'm playing games), hence thinkfan seems redunant to me.

However, I am not certain what controls it - BIOS, OS, or DE. It's just fine as it is. I always thought it's rather BIOS controlled unless overridden by OS. Could somebody explain it to me? Why the OP has issues when I do not?

Re: [Debian] Thinkfan Installation Guide + Configuration Tutorial

Posted: Mon Nov 16, 2015 1:17 am
by Sense
kony wrote: I cannot be certain, as I use T430, not T420, and Linux Mint instead of vanilla Debian, but on my laptop it certainly is not true (and I would assume T420 and T430 share basically the same hardware, just like Mint operates on the same software as Debian, being based on it). When I dumped Linux Mint 15 Xfce (on which I used thinkfan) and installed LM17 KDE, I decided not to install thinkfan as the default settings seem fine to me - the laptop is both silent and cool when not under heavy stress, and is well cooled when needed to be (like when I'm playing games), hence thinkfan seems redunant to me.

However, I am not certain what controls it - BIOS, OS, or DE. It's just fine as it is. I always thought it's rather BIOS controlled unless overridden by OS. Could somebody explain it to me? Why the OP has issues when I do not?
Debian is straight barebones, you have to configure everything. In fact the whole OS is only about 600mb if you choose to not install a GUI. Linux Mint comes with packages that ensure hardware compatibility. Linux Mint 17 is actually based on Ubuntu 14.04. The Debian version is completely separate and is called LMDE 2 Betsy.

Because Ubuntu provides out-of-the-box compatibility including fan control, I would assume Linux Mint works the same way by using its pre-configured packages to manage hardware settings.

As long as you can verify that fan speeds are changing, that's good sign! You can still use $ sensors to check periodically to visually confirm the rotational speed is changing. But from what I've read, looks like there's nothing you need to worry about!

Additional reading:
http://arstechnica.com/gadgets/2014/06/ ... certainty/
http://www.linuxmint.com/download_lmde.php

Re: [Debian] Thinkfan Installation Guide + Configuration Tutorial

Posted: Tue Nov 17, 2015 1:57 pm
by fatpolomanjr
This is a good guide. I found a similar thread in the Ubuntu forums when I was configuring Thinkfan in Xubuntu. Some issues I had were thinkfan not starting up because the sensors were wrong. So for my T61 I had to comment some out in the thinkfan settings file and add some in.

EDIT: just noticed the $sensors-detect command listed in the original post to fix this same issue. Below is an alternative.

If you find thinkfan is not running for some reason, you can debug it a little:

============== Alternative to sensors-detect

Testing/Debugging Thinkfan:

sudo thinkfan stop

sudo thinkfan -n

## the second command will show any kind of startup error. In my case, some of the sensors were not needed, and the log showed which ones I should delete in the config file.

**Find your sensors using the command.

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

In the config file '/etc/thinkfan.conf', add the word 'sensor' in front of them like:

sensor /sys/devices/platform/coretemp.0/temp1_input
sensor /sys/devices/platform/coretemp.2/temp1_input
sensor /sys/devices/virtual/hwmon/hwmon0/temp1_input

SOME OF THE SENSORS YOU FIND MIGHT NOT BE NEEDED, AND THINKFAN WILL REFUSE TO START UP.

==============

I also had to really tweak the fan levels to balance the heat from little to no fan use and the noise from excessive fan use. I'm sure every thinkpad will be different, but for a 4:3, 14" T61 with T9300 cpu, these thresholds worked really well for me:

(0, 0, 70)
(1, 60, 70)
(3, 68, 77)
(5, 76, 82)
(7, 80, 32767)

Re: [Debian] Thinkfan Installation Guide + Configuration Tutorial

Posted: Fri Mar 20, 2020 4:41 pm
by Paul Unger
How does one back out of this???

I was trying to set this up on my X250 running a build based on Ubuntu 18. There was no /etc/modprobe.d/thinkfan.conf file, so, following the instructions in step 6, I created it--which took some doing...; permissions denied, etc. I guess I should have taken the clue. :roll:

Anyway, things started going awry when I ran step 7... Temps shot up to 80*, and System Monitor showed csd-power (Cinnamon Settings Daemon-power) was gobbling up RAM at an alarming rate. I shut down as soon as I could...

Tips on how to undo what I've done? Is it a matter of changing:
  • hwmon /sys/devices/virtual/thermal/thermal_zone0/temp
in /etc/thinkfan.conf to something like:
  • sensor /sys/devices/platform/coretemp.0/temp1_input
    sensor /sys/devices/platform/coretemp.2/temp1_input
    sensor /sys/devices/virtual/hwmon/hwmon0/temp1_input
like fatpolomanjr suggested? I've seen lists like that elsewhere, but when I run: $ sensors, I get a list of about ten, and I don't know which ones to include / exclude.

Any help much appreciated!

Re: [Debian] Thinkfan Installation Guide + Configuration Tutorial

Posted: Fri Mar 20, 2020 8:00 pm
by Paul Unger
Restarted and things settled down. <phew!>

It doesn't seem like 'thinkfan' is controlling things, though... Well, it's hard to tell--things seem so random. Fan speeds don't seem to correspond to reported temperatures, though my fan actually does stop from time to time, which it never did before. :?: What controlled the fan before I installed thinkfan? Could the two be clashing?

Here's what I have in /etc/thinkfan.conf:

Code: Select all

hwmon /sys/devices/platform/coretemp.0/hwmon/hwmon7/temp3_input
hwmon /sys/devices/platform/coretemp.0/hwmon/hwmon7/temp1_input
hwmon /sys/devices/platform/coretemp.0/hwmon/hwmon7/temp2_input
hwmon /sys/devices/virtual/thermal/thermal_zone2/hwmon6/temp1_input
hwmon /sys/devices/virtual/thermal/thermal_zone0/hwmon1/temp1_input
hwmon /sys/devices/virtual/thermal/thermal_zone1/hwmon4/temp1_input

(0,	0,	55)
(1,	52,	60)
(3,	58,	70)
(5,	68,	82)
(7,	80,	32767)
Here's some pertinent(?) output from the terminal:

Code: Select all

:~$ sensors
coretemp-isa-0000
Adapter: ISA adapter
Package id 0:  +52.0°C  (high = +105.0°C, crit = +105.0°C)
Core 0:        +52.0°C  (high = +105.0°C, crit = +105.0°C)
Core 1:        +51.0°C  (high = +105.0°C, crit = +105.0°C)

thinkpad-isa-0000
Adapter: ISA adapter
fan1:        2471 RPM
temp1:        +52.0°C  
temp2:         +0.0°C  
temp3:         +0.0°C  
temp4:         +0.0°C  
temp5:         +0.0°C  
temp6:         +0.0°C  
temp7:         +0.0°C  
temp8:         +0.0°C  
and:

Code: Select all

:~$ find /sys/devices -type f -name "temp*_input"
/sys/devices/platform/thinkpad_hwmon/hwmon/hwmon5/temp6_input
/sys/devices/platform/thinkpad_hwmon/hwmon/hwmon5/temp3_input
/sys/devices/platform/thinkpad_hwmon/hwmon/hwmon5/temp7_input
/sys/devices/platform/thinkpad_hwmon/hwmon/hwmon5/temp4_input
/sys/devices/platform/thinkpad_hwmon/hwmon/hwmon5/temp8_input
/sys/devices/platform/thinkpad_hwmon/hwmon/hwmon5/temp1_input
/sys/devices/platform/thinkpad_hwmon/hwmon/hwmon5/temp5_input
/sys/devices/platform/thinkpad_hwmon/hwmon/hwmon5/temp2_input
/sys/devices/platform/coretemp.0/hwmon/hwmon7/temp3_input
/sys/devices/platform/coretemp.0/hwmon/hwmon7/temp1_input
/sys/devices/platform/coretemp.0/hwmon/hwmon7/temp2_input
/sys/devices/virtual/thermal/thermal_zone2/hwmon6/temp1_input
/sys/devices/virtual/thermal/thermal_zone0/hwmon1/temp1_input
/sys/devices/virtual/thermal/thermal_zone1/hwmon4/temp1_input
Any hints which hwmons I should have in /etc/thinkfan.conf? I had all of them in to begin with, but cut the /hwmon5/ group out and it didn't change anything--so I left them out.

Advice appreciated!