Take a look at our
ThinkPads.com HOME PAGE
For those who might want to contribute to the blog, start here: Editors Alley Topic
Then contact Bill with a Private Message

[Debian] Thinkfan Installation Guide + Configuration Tutorial

Linux on ThinkPads
Post Reply
Message
Author
Sense
Posts: 38
Joined: Sun Aug 16, 2015 2:12 pm
Location: San Diego, California

[Debian] Thinkfan Installation Guide + Configuration Tutorial

#1 Post by Sense » Sun Nov 15, 2015 8:40 pm

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.
Thinkpad:
T420 i7-2620M 2.70Ghz 16Gb RAM 500Gb NVIDIA NVS 4200M and Intel HD Graphics 1600x900
SL500 Core 2 Duo T6570 2.1GHz 4Gb RAM 250Gb NVIDIA G105M (dead screen)

kony
Sophomore Member
Posts: 230
Joined: Wed Aug 28, 2013 4:18 pm
Location: Poland

Re: [Debian] Thinkfan Installation Guide + Configuration Tutorial

#2 Post by kony » Sun Nov 15, 2015 11:53 pm

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?
My T430 with GTX 560 Ti (Now with GTX 670)
T430: i5-3320m, 8 GB, SSD + HDD, 1600x900.

Sense
Posts: 38
Joined: Sun Aug 16, 2015 2:12 pm
Location: San Diego, California

Re: [Debian] Thinkfan Installation Guide + Configuration Tutorial

#3 Post by Sense » Mon Nov 16, 2015 1:17 am

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
Thinkpad:
T420 i7-2620M 2.70Ghz 16Gb RAM 500Gb NVIDIA NVS 4200M and Intel HD Graphics 1600x900
SL500 Core 2 Duo T6570 2.1GHz 4Gb RAM 250Gb NVIDIA G105M (dead screen)

fatpolomanjr
Sophomore Member
Posts: 187
Joined: Wed Aug 11, 2010 2:11 pm
Location: Moreno Valley, CA USA
Contact:

Re: [Debian] Thinkfan Installation Guide + Configuration Tutorial

#4 Post by fatpolomanjr » Tue Nov 17, 2015 1:57 pm

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)
T70 | 15" UXGA LED with RealBlackStuff LED-Cable-Mod | i7-7700HQ | Windows 10
X62 | 12.1" SXGA+ Xiphmont LED | i7-5500U | Xubuntu / Windows 10
T61F | 14.1" SXGA+ Xiphmont LED | T9500 | Windows 10

Post Reply
  • Similar Topics
    Replies
    Views
    Last post

Return to “Linux Questions”

Who is online

Users browsing this forum: No registered users and 8 guests