August 1

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-detect
sensors-detect revision 6284 (2015-05-31 14:00:33 +0200)
System: LENOVO 20L9S0GR00 [ThinkPad T580] (laptop)
Kernel: 4.15.0-29-generic x86_64
Processor: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz (6/142/10)
This program will help you determine which kernel modules you need
to load to use lm_sensors most effectively. It is generally safe
and 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...                       No
VIA VT82C686 Integrated Sensors...                          No
VIA VT8231 Integrated Sensors...                            No
AMD K8 thermal sensors...                                   No
AMD Family 10h thermal sensors...                           No
AMD Family 11h thermal sensors...                           No
AMD Family 12h and 14h thermal sensors...                   No
AMD Family 15h thermal sensors...                           No
AMD Family 16h thermal sensors...                           No
AMD Family 15h power sensors...                             No
AMD Family 16h power sensors...                             No
Intel digital thermal sensor...                             Success!
    (driver `coretemp')
Intel AMB FB-DIMM thermal sensor...                         No
Intel 5500/5520/X58 thermal sensor...                       No
VIA C7 thermal sensor...                                    No
VIA Nano thermal sensor...                                  No
....
//a set of questions are asked, just use the standard answer by typing enter
Now 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 drivers
coretemp
----cut here----
If you have some drivers built into your kernel, the list above will
contain 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,…

thinkfan -n
sleeptime=5, tmax=54, last_tmax=53, biased_tmax=54 -> fan=”level 1″
sleeptime=5, tmax=52, last_tmax=53, biased_tmax=52 -> fan=”level 0″
sleeptime=5, tmax=54, last_tmax=53, biased_tmax=54 -> fan=”level 1″
sleeptime=5, tmax=52, last_tmax=53, biased_tmax=52 -> fan=”level 0″
sleeptime=2, tmax=61, last_tmax=52, biased_tmax=74 -> fan=”level 6″
sleeptime=5, tmax=53, last_tmax=61, biased_tmax=53 -> fan=”level 1″
sleeptime=5, tmax=52, last_tmax=53, biased_tmax=52 -> fan=”level 0″
sleeptime=2, tmax=73, last_tmax=52, biased_tmax=104 -> fan=”level 127″
sleeptime=5, tmax=61, last_tmax=73, biased_tmax=61 -> fan=”level 5″
sleeptime=5, tmax=55, last_tmax=61, biased_tmax=55 -> fan=”level 2″
sleeptime=5, tmax=54, last_tmax=55, biased_tmax=54 -> fan=”level 1″
sleeptime=5, tmax=52, last_tmax=53, biased_tmax=52 -> fan=”level 0″
sleeptime=5, tmax=54, last_tmax=53, biased_tmax=54 -> fan=”level 1″

To stop Thinkfan in console mode a simple CTRL+C

Step 6: Start Thinkfan


systemctl start thinkfan

Here is the result:

systemctl start thinkfan
systemctl status thinkfan
thinkfan.service -- simple and lightweight fan control program
Loaded: loaded (/lib/systemd/system/thinkfan.service; disabled; vendor preset
Active: active (running) since Wed 2018-08-01 10:23:27 CEST; 10s ago
Process: 12971 ExecStart=/usr/sbin/thinkfan $DAEMON_ARGS (code=exited, status=
Main PID: 12972 (thinkfan)
Tasks: 1 (limit: 4915)
CGroup: /system.slice/thinkfan.service
└─12972 /usr/sbin/thinkfan -q
Aug 01 10:23:27 ThinkPad-T580 systemd[1]: Starting simple and lightweight fan co
Aug 01 10:23:27 ThinkPad-T580 thinkfan[12971]: thinkfan 0.9.1 starting…
Aug 01 10:23:27 ThinkPad-T580 thinkfan[12971]: WARNING: You’re using simple temp
Aug 01 10:23:27 ThinkPad-T580 systemd[1]: Started simple and lightweight fan con
lines 1-13/13 (END)

Conclusion:

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.

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading...

References:

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.


Tags: , , , ,
Copyright 2018. All rights reserved.

Posted August 1, 2018 by DisruptIT in category "T580

5 COMMENTS :

  1. By ace333 apk on

    You have made some really good points there. I looked
    on the web to learn more about the issue and found most
    people will go along with your views on this web site.

    Reply
    1. By DisruptIT (Post author) on

      Hello Lukas,

      Thanks to reading my blogs.

      Could you check that this command is in : sudo echo “options thinkpad_acpi fan_control=1” | sudo tee /etc/modprobe.d/thinkfan.conf

      I would like to know if the thinkfan service is running … Thinkfan uses the sensors on your card to adapt the speed of the fan if the temperature increases.
      If this service is up, stop it and execute the command thinkfan on a prompt: thinkfan -n … Normally, thinkfan displays the statistics every 5 seconds…
      Start a browser for example and observe if the fan changes its speed. if this is not the case, you have a problem with the sensors, you don’t point to the right ones…
      if it works, this is a problem at the level of the service (maybe you don’t use the right configuration file)

      Come back to me with your answers, and we will progress in the troubleshooting.

      DisruptIT

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *