While the fan behaves reasonably under Debian 8, it may be useful to increase its usage when running often short but CPU consuming processes. Thinkfan was originally created to solve the problem of unnecessary  high fan consumption. It provides an easy way in general to control the fan level for given temperature ranges.

Contents

  1. Configuration
  2. Enable the service
  3. Avoid overheating
  4. Automatic configuration

Configuration

Install the packages
# apt-get install thinkfan lm-sensors
I encountered an error during installation, which is a known bug. This happens because it tries to load the service before it is properly configured. This error does not prevent the following steps for a proper configuration.
Setting up thinkfan (0.9.2-1) ... Job for thinkfan.service
failed. See 'systemctl status thinkfan.service' and 'journalctl>
-xn' for details. invoke-rc.d: initscript thinkfan, action
"start" failed. dpkg: error processing package thinkfan
(--configure): subprocess installed post-installation script
returned error exit status 1 Errors were encountered while
processing: thinkfan E: Sub-process /usr/bin/dpkg returned an
error code (1)

Scan the system (answer all the default options)
# sensors-detect
Search for thermal sensors
$ find /sys/devices -type f -name "temp*_input"
My output looks like:
/sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/hwmon/hwmon3/temp1_input
/sys/devices/virtual/hwmon/hwmon0/temp1_input
/sys/devices/platform/coretemp.0/hwmon/hwmon2/temp3_input
/sys/devices/platform/coretemp.0/hwmon/hwmon2/temp1_input
/sys/devices/platform/coretemp.0/hwmon/hwmon2/temp2_input

Add the devices to the file
/etc/thinkfan.conf
appending 'hwmon' to each line (in my case I excluded the first line of the previous output), so that the file would look something like this:
hwmon /sys/devices/virtual/hwmon/hwmon0/temp1_input
hwmon /sys/devices/platform/coretemp.0/hwmon/hwmon2/temp3_input
hwmon /sys/devices/platform/coretemp.0/hwmon/hwmon2/temp1_input
hwmon /sys/devices/platform/coretemp.0/hwmon/hwmon2/temp2_input

(0,    0,    55)
(1,    48,    60)
(2,    50,    61)
(3,    52,    63)
(4,    56,    65)
(5,    59,    66)
(7,    63,    32767)

The numbers correspond to:
(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.

For more informations see the comments in the template configuration file
/usr/share/doc/thinkfan/examples/thinkfan.conf.simple

Enable the service

Enable the kernel module:
# modprobe thinkpad_acpi fan_control=1
Now that the module parameter fan_control=1 has been given to thinkpad-acpi, the fan levels can be set manually, e.g.:
echo level 4 | sudo tee /proc/acpi/ibm/fan
where the level can be set to an integer between 0 (no fan) 7 (high fan level). Note that level 7 (about 4500 rpm) does not correspond to the maximum speed reachable by the fan. It is possible to increase further the fan usage manually by setting the level to 'disengaged' (about 5500rpm)
echo level disengaged | sudo tee /proc/acpi/ibm/fan
and return back to automatic mode as
echo level auto | sudo tee /proc/acpi/ibm/fan
It is however preferable and more safe to start an automatic service, such as thinkfan, to control the fan level given certain temperature ranges.

Start the thinkfan service:
# systemctl start thinkfan.service
In no error appears, the service should be enabled. The following should inform you that thinkfan is active
$ systemctl status thinkfan.service
You can also check the fan level
$ cat /proc/acpi/ibm/fan
status:        enabled
speed:        1985
level:        1
commands:    level (level is 0-7, auto, disengaged, full-speed)
commands:    enable, disable
commands:    watchdog (timeout is 0 (off), 1-120 (seconds))
where ' level' is set between 0-7. If instead of being set to a number it is set to 'auto', then probably thinkfan is not active.

or using the command
$ sensors
Finally, load the module at boot:
# echo "options thinkpad_acpi fan_control=1" | sudo tee /etc/modprobe.d/thinkpad_acpi.conf and enable the service at boot
# systemctl enable thinkfan.service

Avoid overheating

If the temperature rises significantly (> 80C) when intense CPU usage is required, an hardware problem is likely.

First, you may want to clean the fan without diassembling the heat sink, e.g., aspiring the dust with a vacuum cleaner from the fan air input grid (remeber that an air fan is supposed to circulate the worm air, rather than directly cooling the CPU).

If it does not help, or if you wish anyway to disassemble the machine to clean the fan, the replacement of the thermal paste is probably required. Check your hardware maintenance manual to see how to disassemble the heatsink. Other unofficial sources (e.g. videos) may also be useful, but the official manual should be consulted, since this is a potentially dangerous procedure (even if easy).

Apart from mechanical solutions, it is also possible to force a reduced CPU usage. E.g., it may be required that CPUs are loaded only up to 80% of their capacities:
# echo 80 > /sys/devices/system/cpu/intel_pstate/max_perf_pct
A systemd script to set automatically the CPU levels at boot can be downloaded from here. Of course, this is not the optimal long term fix, but it is a simple and not invasive temporary remedy.

Automatic configuration

As described above, Thinkfan systemd service can be loaded at boot. However, hwmon devices location can change. See also the associated bug report. This causes Thinkfan service to fail.

The configure_thinkfan script available at this URL automatically retrieves the hwmon sensors and modifies accordingly an existing /etc/thinkfan.conf configuration file.

The script will be executed with root permissions. It is important to understand the security implications: unprivileged attackers may temper with the script to gain root access.




Ref: Putokaz, Debian forum and mailing list, thinkwiki, stackexchange

Back to top