Difference between revisions of "Fan control scripts"

From ThinkWiki
Jump to: navigation, search
(Init script example for gentoo: Moved to Code)
(Comprehensive <tt>bash</tt> script with fine control over fan speed: cleanup)
Line 14: Line 14:
  
 
This scripts uses a different temperature range for each [[thermal sensors|thermal sensor]], since they have different specs and thermal systems. For each sensor, a fan level is chosen based on the minimum and maximum temperatures configured for that sensor; then the actual fan level is set to the slowest that will satisfy all sensors. There are also some hysteresis features - see the script for the details. The method of controlling fan speed is documented [[How to control fan speed|here]].
 
This scripts uses a different temperature range for each [[thermal sensors|thermal sensor]], since they have different specs and thermal systems. For each sensor, a fan level is chosen based on the minimum and maximum temperatures configured for that sensor; then the actual fan level is set to the slowest that will satisfy all sensors. There are also some hysteresis features - see the script for the details. The method of controlling fan speed is documented [[How to control fan speed|here]].
 +
 +
* {{CodeRef|tp-fancontrol}}
  
 
Current options:
 
Current options:
Line 29: Line 31:
 
   -u    tell already-running daemon that the system is being suspended
 
   -u    tell already-running daemon that the system is being suspended
 
   -p    pid file location for daemon mode, default: $PID_FILE
 
   -p    pid file location for daemon mode, default: $PID_FILE
{{WARN|The list of temperature ranges used below is much more liberal than the rules used by the embedded controller firmware, and is derived mostly from anecdotal evidence, hunches and wishful thinking. It is also model-specific - see [[thermal sensors]].}}
+
{{WARN|The list of temperature ranges used in this script is much more liberal than the rules used by the embedded controller firmware, and is derived mostly from anecdotal evidence, hunches and wishful thinking. It is also model-specific - see [[thermal sensors]].}}
 
 
The script: {{CodeRef|tp-fancontrol}}
 
  
 
====init script for the comprehensive script====
 
====init script for the comprehensive script====
  
The following init script (tested on {{Debian}}) allows you to configure some options using a config file. It requires to move the above <tt>tp-fancontrol</tt> script to {{path|/usr/bin/tp-fancontrol}}, but that can be changed easily.
+
This is optional. It assumes that the above <tt>tp-fancontrol</tt> script is saved at {{path|/usr/bin/tp-fancontrol}}.
 
+
* Init script: {{CodeRef|tp-fancontrol.init}} (save as {{path|/etc/init.d/tp-fancontrol}})
* Init script: {{CodeRef|tp-fancontrol.init}} (save as {{path|/etc/init.d/tp-fancontrol}}
+
* Configuration file for init script: {{CodeRef|tp-fancontrol.conf}} (save as {{path|/etc/tp-fancontrol.conf}})
* Configuration file: {{CodeRef|tp-fancontrol.conf}} (save as {{path|/etc/tp-fancontrol.conf}})
 
  
 
===Simple <tt>bash</tt> script with fine control over fan speed (requires kernel patch)===
 
===Simple <tt>bash</tt> script with fine control over fan speed (requires kernel patch)===

Revision as of 22:32, 26 July 2006

This page provides several scripts for controlling the ThinkPad's system fan according the its thermal sensors (overriding the embedded controller), in order to reduce fan noise and decrease power consumption.

ATTENTION!
These scripts rely on undocumented hardware features and override nominal hardware behavior. They may thus cause arbitrary damage to your laptop or data. Watch your temperatures!

Variable speed control scripts

The following scripts sets the fan speed according to the system's thermal sensors. In addition, they include a hack for preventing the annoying fan pulsing that occurs on some systems. Note that the fan levels, thresholds and anti-pulsing hacks are system-specific, so you may need to adjust them.

Comprehensive bash script with fine control over fan speed

The following requires only ibm-acpi 0.11 or higher (e.g., as found in kernel 2.6.14 and higher) with the experimental=1 module parameter. It supports (optional) daemon mode and logging to syslog.

This scripts uses a different temperature range for each thermal sensor, since they have different specs and thermal systems. For each sensor, a fan level is chosen based on the minimum and maximum temperatures configured for that sensor; then the actual fan level is set to the slowest that will satisfy all sensors. There are also some hysteresis features - see the script for the details. The method of controlling fan speed is documented here.

Current options:

Usage: ./tp-fancontrol [OPTION]...

Available options:
  -s N   shift up temperature thresholds by N degrees
         (positive for quieter, negative for cooler)
  -t     test mode
  -q     quiet mode
  -d     daemon mode, go into background (implies -q)
  -l     log to syslog
  -k     kill already-running daemon
  -u     tell already-running daemon that the system is being suspended
  -p     pid file location for daemon mode, default: $PID_FILE
ATTENTION!
The list of temperature ranges used in this script is much more liberal than the rules used by the embedded controller firmware, and is derived mostly from anecdotal evidence, hunches and wishful thinking. It is also model-specific - see thermal sensors.

init script for the comprehensive script

This is optional. It assumes that the above tp-fancontrol script is saved at /usr/bin/tp-fancontrol.

Simple bash script with fine control over fan speed (requires kernel patch)

The following is a simpler patch (without extra features like daemon mode and logging). It requires the patch for controlling fan speed.

tp-fancontrol-basic (download)

Fan enable/disable scripts

The following scripts were written before it was known how to control the fan speed, so they only toggle between fan disabled and default (noisy) fan behavior. In some models, they also do not monitor all available thermal sensors.

sh script example

fan-enable-basic (download)

sh script with more features

fan-enable-extended (download)

sh script with extra safety functionality

ibm_acpi usually works well. But to rely on it completely, this script provides some extra safety functionality:

  1. It catches various signals and turns the fan on before it quits.
  2. It turns off the fan under very strict conditions, leaving it on when unexpected errors occur.

fan-enable-safe (download)

Init scripts

Init script example

fan-enable.init (download)

Init script example for gentoo

Assume one of the above control scripts is /usr/sbin/ibm-fancontrold, for gentoo use the following init script in /etc/init.d/ibm-fancontrol. Copy the script to /etc/init.d/ibm-fancontrol, then do

# rc-update add ibm-fancontrol default

This will add the init script to the default runlevel.

ibm-fancontrol.init (download)

Other

fanctrld

fanctrld is a daemon (written in C) that controls the Thinkpad's fan. The basic approach is to monitor both temperature and fan speed. The fan is enabled when a certain temperature is exceeded, and disabled when the BIOS slows down the fan below a certain speed.

Ideas for improvement

  • Use the HDAPS sensor to automatically lower the temperature thresholds when the laptop is moving. Prolonged movement usually happens when the laptop is on the user's lap (so better keep temperatures down), or when in a moving vehicle where fan noise is typically overshadowed by vehicle noise.
  • Use a PID controller feedback loop instead of simple thresholds.

See also

  • How to control fan speed
  • Shimodax's ThinkPad fan control tool for a Windows offers functionality similar to these scripts; see the forum discussion at thinkpads.com.
  • Yury Polyanskiy has a kernel patch for automatic fan control in kernelspace (only enable/disable based on maximum temperature).