On my laptop Thinkpad T580, I would like to better control the fan speed; it’s too noisy!
Reading Time: 3 minutes
In Belgium, the weather is hot and I observe that my fan is really noisy. Normal, isn’t it? the temperature is really high (around 30° and 55° for the CPU)
However, I would like to better control the fan based on the different temperatures like we can do with the Windows application available for the laptop lenovo :https://support.lenovo.com/be/en/solutions/HT077046 but nothing available for Linux.
There is a solution for Ubuntu, a little complex but logic. You need two packages:
- lm-sensors: is a free and open-source application that provides tools and drivers for monitoring temperatures, voltage, and fans.
- thinkfan: Thinkfan is a simple, lightweight fan control program. Originally designeds pecifically for IBM/Lenovo Thinkpads, it now supports any kind of system via the sysfs hwmon interface (/sys/class/hwmon).
A few steps are required to control your fan based on the temperatures of the different zones.
Step 1: Install the required packages (Note: Distribution Lubuntu 18.04)
apt-get install lm-sensors apt-get install thinkfan apt-get install cpufrequtils
Step 2: check the sensors available on the laptop T580 by executing sensors-detect
> sensors-detectsensors-detect revision 6284 (2015-05-31 14:00:33 +0200)System: LENOVO 20L9S0GR00 [ThinkPad T580] (laptop)Kernel: 4.15.0-29-generic x86_64Processor: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz (6/142/10)This program will help you determine which kernel modules you needto load to use lm_sensors most effectively. It is generally safeand recommended to accept the default answers to all questions,unless you know what you're doing.Some south bridges, CPUs or memory controllers contain embedded sensors.Do you want to scan for them? This is totally safe. (YES/no):Silicon Integrated Systems SIS5595... NoVIA VT82C686 Integrated Sensors... NoVIA VT8231 Integrated Sensors... NoAMD K8 thermal sensors... NoAMD Family 10h thermal sensors... NoAMD Family 11h thermal sensors... NoAMD Family 12h and 14h thermal sensors... NoAMD Family 15h thermal sensors... NoAMD Family 16h thermal sensors... NoAMD Family 15h power sensors... NoAMD Family 16h power sensors... NoIntel digital thermal sensor... Success!(driver `coretemp')Intel AMB FB-DIMM thermal sensor... NoIntel 5500/5520/X58 thermal sensor... NoVIA C7 thermal sensor... NoVIA Nano thermal sensor... No....//a set of questions are asked, just use the standard answer by typing enterNow follows a summary of the probes I have just done.Just press ENTER to continue:Driver `coretemp':* Chip `Intel digital thermal sensor' (confidence: 9)To load everything that is needed, add this to /etc/modules:----cut here----Chip driverscoretemp----cut here----If you have some drivers built into your kernel, the list above willcontain too many modules. Skip the appropriate ones!Do you want to add these lines automatically to /etc/modules? (yes/NO)YES
In Green, the sensors type detected (Intel) with the related module (coretemp) which will be loaded at the start. You can check if the module is correctly added by opening the /etc/modules file.
Step 3: Configure the manual control of the Fan to enable Thinkfan to change its speed
Thinkfan is a program for controlling fans speed on IBM/Lenovo ThinkPads. It is written for Linux only. To enable Thinkfan to control the fan of the PC, you need that the Linux kernel has ‘thinkpad-acpi’ activated. For Linux 2.6.22 and above, you must add ‘fan_control=1’ as a module parameter to ‘thinkpad-acpi’. For example, in Debian Lenny (and Ubuntu 8.04), you must add the following line into “/etc/modprobe.d/thinkfan.conf”:
echo "options thinkpad_acpi fan_control=1" > /etc/modprobe.d/thinkpad_acpi.conf
Step 4: Configure Thinkfan
The heart of the configuration of the Thinkfan is the file /etc/thinkfan.conf. For its configuration, you need three elements:
- The location of the sensors to have their information
- The location of the fan to control its speed
- The description of the 7 steps of the fan
Here is the extract of the Thinkfan.conf file with the three important elements:
hwmon /sys/devices/platform/coretemp.0/hwmon/hwmon1/temp1_input hwmon /sys/devices/platform/coretemp.0/hwmon/hwmon1/temp2_input hwmon /sys/devices/platform/coretemp.0/hwmon/hwmon1/temp3_input hwmon /sys/devices/platform/coretemp.0/hwmon/hwmon1/temp4_input hwmon /sys/devices/platform/coretemp.0/hwmon/hwmon1/temp5_input tp_fan /proc/acpi/ibm/fan (0,0,54) (1,52,56) (2,54,58) (3,56,60) (4,58,63) (5,60,70) (6,66,79) (7,74,92) (127,85,32767)
There are three sections in this file :
- First section indicates where the input of the temperature can be found. You can see that this is the module coretemp which provides the program with the information. This is the INPUT
- Second section gives you the control of the fan. The fan has 7 speeds (0 = disabled – 2 = Low – 4= Medium – 7= Maximum – 127 = disengaged – auto = auto). This is the OUTPUT
- Third section defines the speed of the fan for each interval [min_CPU, max_CPU] based on according to the following configuration (Fan_speed,min_CPU,max_CPU):
- Fan_speed : fan level to be used.
- Min_CPU : the temperature at which to spin the fan down to the previous level.
- Max_CPU: the temperature at which to step up to the next level.
Attention point: The Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz is able to work until 100°C according to http://www.cpu-world.com/CPUs/Core_i7/Intel-Core%20i7%20i7-8550U.html. so, I decided to activate my Fan with a temperature of minimum 54°C by gradually incrementing it based on the temperature of the CPU
Step 5: Manually start Thinkfan to check if it works!
You need to firstly stop the service thinkfan and start thinkfan on the console (not daemon). This enables you to see, based on the actions you made, the impact on the CPU and the fan speed. This enables you to adapt the configuration file if required.
systemctl stop thinkfan thinkfan -n
and here is the result based on the actions I made, opening a xterm,a browser, add a tab,…
To stop Thinkfan in console mode a simple CTRL+C
Step 6: Start Thinkfan
systemctl start thinkfan
Here is the result:
Now, I have the control of the speed of my laptop’s fan based on the real temperature of the 10 zones. It’s of course possible to better tweak the configuration file by for example determining the thermal zones of the processor and activate the fan based on this information. Feel free to give comments or ask questions and I will try to answer you.
If you find this post valuable, Rate it ! This helps me to improve it. For comments, you need to register with your LinkedIn account.
When I write an article, I always give the references I used because I believe in intellectual property and I know how many times you need to write a valuable article.