Introduction

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...

License

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

Project Location

The latest version of fan-ctrl can be found here.

This project is hosted on SourceForge:

SourceForge logo

Installation

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.

Running fan-ctrl

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:

Startup

On a Debian system, after editing /etc/default/fan-ctrl and enabling it, use "/etc/init.d/fan-ctrl start" to run fan-ctrl.

Command line options

-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

Stopping fan-ctrl

Use "killall fan-ctrl" to stop fan-ctrl. On a Debian system, use
/etc/init.d/fan-ctrl stop

Suspend and Hibernate

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.