- Debian 8
- Configuration
- Enable the service
- Avoid overheating
- Ubuntu 11.10
Debian 8
While the fan behaves reasonably under Debian 8, I wanted to increase its usage as I often run short but CPU consuming processes. Thinkfan, originally created to solve the problem of unnecessary high fan consumption (see the section below about Ubuntu). It provides an easy way in general to control the fan level for given temperature ranges.
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 ( is 0-7, auto, disengaged, full-speed)
commands: enable, disable
commands: watchdog ( 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
The temperature can still rise significantly (> 90C) when intense CPU usage is required. First, you may want to clean the heat sink. If it does not help, or if to clean the fan you wish anyway to disassemble the machine, it is probably required also the replacement of the thermal paste. 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 not invasive and requires no purchase.Ubuntu 11.10
DISCLAIMER: while we keep this section for reference, we strongly discourage usage of Ubuntu, in particular those versions released between year 2012 and 2016 implementing spyware.After installing Ubuntu 11.10 on a Lenovo Thinkpad T420, the fan always run too much, even if there is a minimal CPU usage. The solution is installing the package
thinkfan
, and care attention to wisely configure the fan options.These steps solve the problem:
1. Install thinkfan package:
$ sudo apt-get install thinkfan
2. Add kernel module ‘coretemp’ to /etc/modules
$ sudo sh -c ‘echo coretemp >> /etc/modules’
3. Load kernel module ‘coretemp’
$ sudo modprobe coretemp
4. Add the following three sensor entries to /etc/thinkfan.conf just before the temperature levels:
sensor /sys/devices/platform/coretemp.0/temp1_input
sensor /sys/devices/platform/coretemp.0/temp2_input
sensor /sys/devices/platform/coretemp.0/temp3_input
sensor /sys/devices/virtual/hwmon/hwmon0/temp1_input
5. Add the following to /etc/modprobe.d/thinkfan.conf: ‘options thinkpad_acpi fan_control=1′
$ sudo sh -c ‘echo “options thinkpad_acpi fan_control=1″ >> /etc/modprobe.d/thinkfan.conf’
6. Reload kernel module ‘thinkpad_acpi’
$ sudo modprobe -r thinkpad_acpi
$ sudo modprobe thinkpad_acpi
7. Set START=”yes” in /etc/default/thinkfan
8. Start thinkfan:
$ sudo /etc/init.d/thinkfan start
9. Check whether it works
$ sudo cat /proc/acpi/ibm/fan
if level has a value between 0 and 7, and changes by times, your thinkfan daemon works.
10. Add
thinkfan
to startup applications.Ref: Putokaz, Debian forum and mailing list, thinkwiki, stackexchange