Fan speed control

Introduction
Most systems have fans to control the temperature of CPUs and other chips. Typically the speed of the fan or fans is controlled by the BIOS, but it may be possible to control the fan speed with userspace utilities. Reasons for wanting to deviate from BIOS controlled fans could be that the BIOS makes them spin too much (resulting in too much noise), or too slow (resulting in too high temperatures).

This article discusses two of those userspace utilities:
 * fancontrol, and
 * thinkfan

Controlling fan speed is not supported on all computers. The computer needs to have:
 * A BIOS that allows users to control the fan speed
 * A motherboard capable of regulating fan speeds
 * Fans that allow their speed to be controlled

Fans have 2, 3, or 4 wires:
 * 1) ground
 * 2) fan voltage
 * 3) tacho
 * 4) PWM

Fans with 2 or 3 wires may have voltage regulation: higher voltage (typically up to 12 Volt) results in higher rotation per minute (RPM). Fans with 4 wires are controlled through pulse width modulation (PWM), in theory a more efficient way of controlling the fan speed. The third wire provides feedback on the actual RPM of the fan.

Fancontrol
Fancontrol is a generic fan control script provided by package which can run as a system daemon. First install lm-sensors as described in lm_sensors. Make sure that any Super I/O chip is enabled in the kernel, and its module loaded.

Temperature measurement
Verify that temperatures are measured and that there are fans shown with the sensors command:

Note that not all sensors and fans may be connected and/or provide sensible values. In this case:
 * The system has only one fan; fan2 to fan6 are not connected
 * Temperature readings for AUXTIN0 to PCH_MCH_TEMP are not very likely, and are probably not connected
 * Temperatures reported by the the ACPI interface (acpitz-acpi-0) and the ISA adapter (coretemp-isa-0000) are more real.

Configuration
Execute pwmconfig as root to create the configuration file for fancontrol:

Answer all questions posed by pwmconfig. Note that pwmconfig also works for voltage controlled fans.

It is possible to manually fine tune the configuration file:

Useful parameters to tune are:
 * INTERVAL: the number of seconds between temperature samples
 * MINTEMP: the temperature at which the fan should start working
 * MAXTEMP: the temperature at which the fan should spin at maximum RPM

Start fancontrol as a service
Start fancontrol as a service, and enable the service for automatic start:

Thinkfan
Thinkfan is a fan controlling deamon provided by and is aimed specifically towards IBM/Lenovo Thinkpad laptops. It can read multiple sensors, but control only a single fan.

Kernel configuration
The kernel needs to have the Thinkpad ACPI driver configured:

This will create a module called thinkpad_acpi, which needs to be configured to allow for controlling a fan.

Edit or create as follows:

Most Thinkpads provide as a path to the fan device.

Manual fan control
It is possible to manually control the fan speed:

There are a few special values:
 * level auto: the fan RPM is controlled by the BIOS
 * level full-speed: the maximum speed while being monitored
 * level disengaged: even faster, where the controller does not monitor the fan speed.

Thinkfan software installation
Automatic speed control can be achieved through a package.

Review thinkfan's USE flags prior to installing it:

Install thinkfan as per normal:

Configuration
The configuration file of thinkfan is in. It requires manual configuration and supports a simple mode and a complex mode. Simple mode evaluates the highest temperature detected, complex mode allows configuration per sensor. The below example of the configuration file is based on simple mode:

The sensors to be considered can be found as follows:

The list of arrays show the fan speed in a range of 0 to 7, and the lower and higher temperature. This example can be read as:
 * level 0 (off) until the detected temperature exceeds 45 degrees centigrade
 * level 1 until the temperature goes below 43 degrees, or exceeds 50 degrees
 * level 2 until the temperature goes below 48 degrees, or exceeds 55 degrees
 * and so on

Thinkfan also takes commandline parameters, see thinkfan's man page for details. Take special note of the bias value, which will exaggerate or dampen a sudden increase or decrease between two temperature samples.

Testing
Test the behaviour of thinkfan as follows:

It may take a few cycles of configuration update and testing to find the optimum between all the different setting that are possible.

Start thinkfan as a service
Update as per the selected commandline parameters:

Start the thinkfan as a service and enable it as follows:

External resources

 * What is PWM and how does it work?
 * How to control fan speed