Fan control scripts
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!
NOTE!
Closed-loop fan control requires a thermal sensor sweep, which is an expensive operation. The firmware doesn't update the sensors more than once every 2s, so care should be taken not to waste resources by reading them too often.
|
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
This script works with any recent Linux kernel (2.6.14 and higher). It requires the ibm-acpi module to be loaded with the experimental=1 module parameter (e.g., # modprobe ibm_acpi experimental=1
).
In Linux 2.6.22 and higher you need to additionally pass fan_control=1 to the module thinkpad_acpi (e.g., # modprobe thinkpad-acpi experimental=1 fan_control=1
)
On Ubuntu > 10.04 or from kernel 2.6.32 onwards: To make the kernel module settings permanent and to make them be executed at boot run below command and reboot afterwards:
# sudo echo "options thinkpad_acpi experimental=1 fan_control=1" >/etc/modprobe.d/thinkpad_acpi.conf
The code lets you define a temperature range for each thermal sensor. The script computes the fan level needed by each sensor based on the configured range, and then sets the the actual fan level to the slowest that will satisfy all sensors (plus some hysteresis to avoid fluctiations). It also includes a workaround for the pulsing noise problem. The script provides an (optional) daemon mode and logging to syslog. The method of controlling fan speed is documented here.
The system hard disk temperature is monitored as well, using the hard disk's internal sensor. This works only on certain Hitachi disks and requires kernel >= 2.6.19-rc1 or the ide driver, since it uses a non-standard method for reading the temperature without causing a head unload or spinup.
The code:
Current options:
Usage: ./tp-fancontrol [OPTION]... Available options: -s N Shift up the min temperature thresholds by N degrees (positive for quieter, negative for cooler). Max temperature thresholds are not affected. -S N Shift up the max temperature thresholds by N degrees (positive for quieter, negative for cooler). DANGEROUS. -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
init script for the comprehensive script
This is optional. It assumes that the above tp-fancontrol script is saved at /usr/bin/tp-fancontrol.
- Init script: tp-fancontrol.init (download) (save as /etc/init.d/tp-fancontrol)
- Init script (Debian): tp-fancontrol.init.debian (download) (save as /etc/init.d/tp-fancontrol)
- Configuration file for init script: tp-fancontrol.conf (download) (save as /etc/tp-fancontrol.conf)
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 or a recent kernel (>=2.6.19).
tp-fancontrol-basic (download)
tp-fan: Automatic daemon with GTK+ GUI
Provides easy setup and monitoring through graphical GTK+ interface. Temperature thresholds can be set separately for each sensor since version 0.90.
At the moment packages are available for Ubuntu 8.04, 8.10, and 9.04. However, porting to other distributions or manual setup should be easy.
http://www.gambitchess.org/moin.py/tpfan
thinkfan: A minimalist fan control program
Written in C to use as little CPU power as possible. Configuration is done via a simple text file, by providing (FAN_LEVEL, LOWER_LIMIT, UPPER_LIMIT) tuples. Inspired by i8kfan. Requires thinkpad_acpi with fan_control=1. Just released version 0.7, which now allows a more fine-grained control over temperature limits.
- Download here: http://sourceforge.net/projects/thinkfan/
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
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:
- It catches various signals and turns the fan on before it quits.
- It turns off the fan under very strict conditions, leaving it on when unexpected errors occur.
Init scripts
Init script example
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)
Init script example for rh/fedora
Assume one of the above control scripts is /sbin/tp-fancontrold, copy the script to /etc/init.d/tp-fancontrol, then do
# chkconfig --add tp-fancontrol
This will add the init script to the default runlevel.
tp-fancontrol-fc.init (download)
You'd have to install also "kernel-module-ibm-acpi" package.
Other
tpfand
This little piece of python code is only there to speed up your fan in a T400 with an ATI card cause the fglrx driver does not control the fan speed which leads to overheating while gaming or do other graphic stuff with the ati chip. This script relies on the normal bios control of the fan. If the laptop gets to hot it will speed up the fan to max speed (somehow the bios does not do this ??!!) and re-enables the bios control on a certain temperature. This was only tested on a T400 with ATI chip. You can just run in in the background as root. It is very chatty and writes in a logfile in /tmp. It should work with any Thinkpad who has /proc/acpi/ibm/fan interface. tpfand
Tested on: T400 with Radeon HD 3400 Please test on other models with ATI chip.
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.
ThinkPad Fan Control GTK GUI tool
A GTK GUI program (packaged for Ubuntu Gutsy Gibbon 7.10) may also help.
For those using Ubuntu 8.10 and recent Thinkpad models (eg: X200), this is the fan control packages to use: sudo apt-get install tpfand tpfan-admin tpfand-profiles (The packages are part of the main ubuntu repository). It solves the problem of a constantly-on fan. I don't think there are yet profiles for those newer thinkpad models, but it's fairly easy to manually configure the right thresholds. For reference, this is the /etc/tpfand.conf I use for my X200:
enabled = True
override_profile = True
0. Sensor 0 = 0:0 50:3 58:5 67:8
1. Sensor 1 = 0:0 55:3 62:5 69:8
2. Sensor 2 = 0:255
3. Sensor 3 = 0:0 48:3 61:5 69:8
4. Sensor 4 = 0:0 43:3 50:8
5. Sensor 5 = 0:255
6. Sensor 6 = 0:0 40:8
7. Sensor 7 = 0:255
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 (see Problem with hot surfaces for implications), 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.
- Monitor the UltraBay disk temperature too.
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).