fan-ctrl is a little daemon that controls the speed of one or more system or CPU fans. It does so by monitoring temperature inputs and selecting a fan speed from an array of available speeds based on a set of temperature thresholds.
Why thresholds instead of smooth speed control? Because my CPU fan has a few resonance frequencies which make it "sing". Unfortunately, one of those resonance frequencies is right at the idle operating temperature when using the BIOS automatic control, or lmsensors' fancontrol without tweaking. On top of that, it's less annoying to have the fan change speed in steps using a hysteresis of a few degrees to minimize the chance of the fan speed jumping up and down, possibly going through resonance points again and again.
A word of caution: If this program screws up, the parameters are set incorrectly or the OS crashes badly, the fan speed might be too low and the CPU might overheat. Modern CPUs should be able to deal with this, starting to throttle and eventually resetting the system or going offline, but there might still be damage.
You have been warned...
fan-ctrl is not public domain software. It's copyrighted by myself, Christian Mueller, according to the terms of the GNU General Public License (GPL). Please see the file LICENSE for additional information.
Copyright (c) Christian Mueller 2009
The latest version of fan-ctrl can be found here.
This project is hosted on SourceForge:
There's no release tar file at this point. Please download the source code with CVS using the following commands:
The compile process is rather simple, thus there's no automake or configure script at this point, just a makefile for Linux.
In order to run fan-ctrl, you first have to figure out the best parameters for the fan(s) you're trying to control. I'm assuming a CPU fan for the rest of this README, namely a Thermaltake TR2 R1, and a Gigabyte GA-MA790GP-DS4H mainboard which has the CPU fan on pwm1 and the CPU temperature on temp2_input.
Steps to get the required parameters:
Once everything is working, you should be able to run "sensors" and get both the CPU temperature and the CPU fan speed. Try running
while true; do false; done
in a terminal window to generate some CPU load to see the CPU temperature and/or the CPU fan speed going up (and down once you press Ctrl+C)
echo 1 >pwmX_enable
echo 255 >pwmX
echo 180 >pwm1 (assuming "1" is your fan)
If the temperature goes up beyond 60°C, quickly type "echo 255 >pwm1" to prevent damage. Or pull the plug ;)
fan-ctrl -p /sys/bus/i2c/devices/9191-0228 -f pwm1 -t temp2_input \ -s 0:142,40:176,50:196,55:226,60:255 -h 5
0 - 39°C -> 142 40 - 49°C -> 176 50 - 54°C -> 196 55 - 59°C -> 224 60°C+ -> 255 (max)
On a Debian system, after editing /etc/default/fan-ctrl and enabling it, use "/etc/init.d/fan-ctrl start" to run fan-ctrl.
-d | Print debugging messages to stdout; fan-ctrl will not deamonize and run in the foreground |
-n <interval> | Update interval. This defines the interval used by fan-ctrl to update the fan speed. Default is 10s |
-p <base_path> | Base path for fan control output and temperature input contol files. Can be set multiple times and affects only the following -f and -t options. Default is an empty string. |
-f <pwm_out> | The PWM (Pulse Width Modulation) control file used to set the fan speed. This option defines a new fan to be controlled. In other words, multiple "-f" options allow defining multiple fans to be controlled. |
-f <temp_in> | The temperature input file to be used for controlling the fan specified with "-f" |
-s <temp:speed,...> | An array of temperature/speed values to be used by fan-ctrl. Temperature and speed are separated by a colon (:), pairs are seperated by commas (,) |
-h <hysteresis> | The hysteresis to be used when temperatures are falling. In other words, don't reduce the fan speed until the temperature has dropped "-h" degrees below the threshold for the fan speed. This prevents fan speeds from jumping up and down until the temperature and fan speed finally stabilize. |
Example:
fan-ctrl -p /sys/bus/i2c/devices/9191-0228 -f pwm1 -t temp2_input \ -s 0:142,40:176,50:196,55:226,60:255 -h 5
/etc/init.d/fan-ctrl stop
It's a good idea to stop fan-ctrl when suspending or hibernating (add a 1s sleep to the suspend/hibernate script to give fan-ctrl a chance to ramp up the fans) and re-enabling fan-ctrl once the system resumes. This way, the fan speed will be set to maximum before going into suspend/hibernate and fan-ctrl will only resume its work after the resume operation has completed successfully.
If anything fails during those operations, the fans will be either at maximum speed or BIOS-controlled.