Adjusting your fanspeed with trinity (lm_sensors, pwmconfig and fancontrol)

Modern CPU throttling technology like Intel’s SpeedStep or AMD’s Cool’n’Quiet are quite fancy. They not only reduce the CPU frequency and the core voltage, the mainboard also detects an idling, cool CPU and therefore reduces the fanspeed.
But what if the fanspeed is still to high while the CPU is doing nothing? Or maybe the fan doesn’t spin fast enough while your CPU is burning in a very small case.

1. Detecting sensors

Before you can read out any temperature values and change the fanspeed accordingly, you have to your operating system which sensors you are actually using.
Fortunately, there is a small program that does the job for you. sensors-detect comes with lm_sensors, so we make sure, the latest version of lm_sensors is installed

yum install lm_sensors

before we start sensors-detect

# sensors-detect 
Stopping lm_sensors:                                       [  OK  ]
# sensors-detect revision 5666 (2009-02-26 17:15:04 +0100)
# System: System manufacturer System Product Name
# Board: ASUSTeK Computer INC. M3N78-EM

This program will help you determine which kernel modules you need
to load to use lm_sensors most effectively. It is generally safe
and recommended to accept the default answers to all questions,
unless you know what you're doing.

Some south bridges, CPUs or memory controllers contain embedded sensors.
Do you want to scan for them? This is totally safe. (YES/no): 
Silicon Integrated Systems SIS5595...                       No
VIA VT82C686 Integrated Sensors...                          No
VIA VT8231 Integrated Sensors...                            No
AMD K8 thermal sensors...                                   No
AMD K10 thermal sensors...                                  Success!
    (driver `to-be-written')
Intel Core family thermal sensor...                         No
Intel AMB FB-DIMM thermal sensor...                         No
VIA C7 thermal and voltage sensors...                       No

Some Super I/O chips contain embedded sensors. We have to write to
standard I/O ports to probe them. This is usually safe.
Do you want to scan for Super I/O sensors? (YES/no): 
Probing for Super-I/O at 0x2e/0x2f
Trying family `National Semiconductor'...                   No
Trying family `SMSC'...                                     No
Trying family `VIA/Winbond/Fintek'...                       No
Trying family `ITE'...                                      Yes
Found `ITE IT8712F Super IO Sensors'                        Success!
    (address 0x290, driver `it87')
Probing for Super-I/O at 0x4e/0x4f
Trying family `National Semiconductor'...                   No
Trying family `SMSC'...                                     No
Trying family `VIA/Winbond/Fintek'...                       No
Trying family `ITE'...                                      No

Some systems (mainly servers) implement IPMI, a set of common interfaces
through which system health data may be retrieved, amongst other things.
We have to read from arbitrary I/O ports to probe for such interfaces.
This is normally safe. Do you want to scan for IPMI interfaces?
(YES/no): 
Probing for `IPMI BMC KCS' at 0xca0...                      No
Probing for `IPMI BMC SMIC' at 0xca8...                     No

Some hardware monitoring chips are accessible through the ISA I/O ports.
We have to write to arbitrary I/O ports to probe them. This is usually
safe though. Yes, you do have ISA I/O ports even if you do not have any
ISA slots! Do you want to scan the ISA I/O ports? (yes/NO): YES
Probing for `National Semiconductor LM78' at 0x290...       No
Probing for `National Semiconductor LM79' at 0x290...       No
Probing for `Winbond W83781D' at 0x290...                   No
Probing for `Winbond W83782D' at 0x290...                   No

Lastly, we can probe the I2C/SMBus adapters for connected hardware
monitoring devices. This is the most risky part, and while it works
reasonably well on most systems, it has been reported to cause trouble
on some systems.
Do you want to probe the I2C/SMBus adapters now? (YES/no): 
Found unknown SMBus adapter 10de:0752 at 0000:00:01.1.
Sorry, no supported PCI bus adapters found.
WARNING: All config files need .conf: /etc/modprobe.d/blacklist, it will be ignored in a future release.
Module i2c-dev loaded successfully.

Next adapter: SMBus nForce2 adapter at 0600 (i2c-0)
Do you want to scan it? (YES/no/selectively): 
Client found at address 0x50
Probing for `Analog Devices ADM1033'...                     No
Probing for `Analog Devices ADM1034'...                     No
Probing for `SPD EEPROM'...                                 Yes
    (confidence 8, not a hardware monitoring chip)
Probing for `EDID EEPROM'...                                No
Client found at address 0x51
Probing for `Analog Devices ADM1033'...                     No
Probing for `Analog Devices ADM1034'...                     No
Probing for `SPD EEPROM'...                                 Yes
    (confidence 8, not a hardware monitoring chip)

Next adapter: SMBus nForce2 adapter at 0700 (i2c-1)
Do you want to scan it? (YES/no/selectively): 
Client found at address 0x50
Probing for `Analog Devices ADM1033'...                     No
Probing for `Analog Devices ADM1034'...                     No
Probing for `SPD EEPROM'...                                 No
Probing for `EDID EEPROM'...                                No
Client found at address 0x51
Probing for `Analog Devices ADM1033'...                     No
Probing for `Analog Devices ADM1034'...                     No
Probing for `SPD EEPROM'...                                 No
Client found at address 0x52
Probing for `Analog Devices ADM1033'...                     No
Probing for `Analog Devices ADM1034'...                     No
Probing for `SPD EEPROM'...                                 No
Client found at address 0x53
Probing for `Analog Devices ADM1033'...                     No
Probing for `Analog Devices ADM1034'...                     No
Probing for `SPD EEPROM'...                                 No

Next adapter: NVIDIA i2c adapter  (i2c-2)
Do you want to scan it? (YES/no/selectively): 

Next adapter: NVIDIA i2c adapter  (i2c-3)
Do you want to scan it? (YES/no/selectively): 

Next adapter: NVIDIA i2c adapter  (i2c-4)
Do you want to scan it? (YES/no/selectively): 
Client found at address 0x50
Probing for `Analog Devices ADM1033'...                     No
Probing for `Analog Devices ADM1034'...                     No
Probing for `SPD EEPROM'...                                 No
Probing for `EDID EEPROM'...                                Yes
    (confidence 8, not a hardware monitoring chip)

Now follows a summary of the probes I have just done.
Just press ENTER to continue: 

Driver `it87':
  * ISA bus, address 0x290
    Chip `ITE IT8712F Super IO Sensors' (confidence: 9)

Driver `to-be-written':
  * Chip `AMD K10 thermal sensors' (confidence: 9)

Note: there is no driver for AMD K10 thermal sensors yet.
Check http://www.lm-sensors.org/wiki/Devices for updates.

Do you want to overwrite /etc/sysconfig/lm_sensors? (YES/no): 
Starting lm_sensors: loading module it87                   [  OK  ]
Unloading i2c-dev... OK

Pretty cool, huh? Make sure, the lm_sensors daemon gets started automatically

chkconfig lm_sensors on

2. Configuring sensors and fans

The fancontrol script can automatically respond to temperature changes of your system by changing fanspeeds. Basically, we have to map one temp-sensor to one fan controller. fancontrol‘s config-file can be easily manipulated with pwmconfig. The program is quite self-explaining; It can even create detailed correlation with gnuplot automatically.

If you later want to change some values manually, you can also edit /etc/fancontrol without pwmconfig using your favourite editor. See also fancontrol manpage.

3. Automatically starting fancontrol

Unfortunately there comes no init script with fancontrol in Fedora or CentOS. So we have to ensure, fancontrol gets started automatically during boot. The easiest way is to put fancontrol into rc.local

# echo 'fancontrol &' >> /etc/rc.local

Sending the process to background with a subsequent ampersand is crucial. Otherwise the boot process may hang.
You can of course write your own fancontrol init script if you want to do the full Sys V style init stuff.

Restart the computer and enjoy silence!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.