0% found this document useful (0 votes)
45 views4 pages

Controlling Fanspeeds in Linux On PWM Motherboards

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 4

t jansso n.

dk

http://www.tjansso n.dk/?p=325

Controlling fanspeeds in Linux on PWM motherboards, Thinkpads and ASUS Eee PC


by Tho mas Jansso n Octo ber 31, 2008

Introduction In Windows I controlled the f anspeed on my stationary computer by using a ASUS program that read the temperatures. I wanted the same temperature/f anspeed scaling in Linux, so I decided to setup fancontrol, which is a small script that monitors temperatures and f anspeeds and sets the f an at the minimum required level to insure low noise levels. T he f ollowing should work on most Linux distributions and with most modern motherboards. For the record I did this on a Ubuntu 8.04 installation with a setup consisting of a ASUS P5W DH Deluxe Digital Home Series motherboard, Gigabyte Triton GZ XX1CA-SNS casing and a Core 2 Duo E6600 2.4 GHz with a Noctua NH-U12P CPU cooler, see (Hvilke elementer jeg valgte til min nye computer [tjansson.dk]) f or more details. Controlling the speed using PWM Pulse width modulation (PWM) can be used to control the f an speed on modern motherboards. My ASUS P5W DH is such a motherboard. T he PWM values goes f rom 0 to 255 and can be controlled quite easily:

root @bohr:~# cat /sys/class/hwmon/hwmon0/device/fan1_input 1054 root @bohr:~# echo "50" > /sys/class/hwmon/hwmon0/device/pwm1 root @bohr:~# cat /sys/class/hwmon/hwmon0/device/fan1_input 390 root @bohr:~# echo "255" > /sys/class/hwmon/hwmon0/device/pwm1 root @bohr:~# cat /sys/class/hwmon/hwmon0/device/fan1_input 1054

But this solution is a bit to basic. I wish to be able to do this automatically depending on the temperature. T his is where f ancontrol comes into the picture. fancontrol and the related pwmconfig is a part of the lm_sensors program which is quite easy to install under Ubuntu:

root @bohr:~# apt it ude inst all lm-sensors

T he f irst thing todo is see whether or not the lm_sensors detects anything:

t jansson@bohr:~$ sensors w83627dhg-isa-0290 Adapt er: ISA adapt er VCore: +1.47 V (min = +0.00 V, max = +1.74 V) in1: +12.09 V (min = +5.17 V, max = +3.80 V) ALARM AVCC: +3.25 V (min = +0.32 V, max = +0.51 V) ALARM 3VCC: +3.25 V (min = +2.21 V, max = +0.77 V) ALARM in4: +1.37 V (min = +0.51 V, max = +0.80 V) ALARM in5: +1.58 V (min = +0.34 V, max = +0.02 V) ALARM in6: +4.17 V (min = +3.30 V, max = +3.28 V) ALARM VSB: +3.25 V (min = +0.00 V, max = +0.56 V) ALARM VBAT: +3.23 V (min = +1.02 V, max = +0.00 V) ALARM Case Fan: 1054 RPM (min = 5273 RPM, div = 128) ALARM CPU Fan: 1054 RPM (min = 5273 RPM, div = 128) ALARM Aux Fan: 1506 RPM (min = 105 RPM, div = 128) fan4: 1318 RPM (min = 10546 RPM, div = 128) ALARM fan5: 0 RPM (min = 215 RPM, div = 128) ALARM Sys Temp: +49.0C (high = +92.0C, hyst = +32.0C) sensor = t hermist or CPU Temp: +47.0C (high = +80.0C, hyst = +75.0C) sensor = diode AUX Temp: +119.0C (high = +80.0C, hyst = +75.0C) ALARM sensor = t hermist or

which it clearly did in my case even though it has some f unny alarms. To setup f ancontrol the f irst thing to do is run pwmconf ig to f ind the relations between devices in /sys/class/hwmon/hwmon0/device/ and f anspeed. pwmconf ig is described as:

This program will search your sensors for pulse width modulation (pwm) controls, and test each one to see if it controls a fan on your motherboard.

To start the conf ig run

root @bohr:~# pwmcong

And remember to write the inf ormation to the f ile /etc/fancontrol when asked. T his is how my f ile looks (DO NOT COPY-PAST E. SYST EM SPECIFIC):

root @bohr:~# cat /et c/fancont rol INTERVAL=5 FCTEMPS=hwmon0/device/pwm1=hwmon0/device/t emp1_input hwmon0/device/pwm2=hwmon0/device/t emp2_input FCFANS=hwmon0/device/pwm1=hwmon0/device/fan1_input hwmon0/device/pwm2=hwmon0/device/fan2_input MINTEMP=hwmon0/device/pwm1=40 hwmon0/device/pwm2=40 MAXTEMP=hwmon0/device/pwm1=52 hwmon0/device/pwm2=60 MINSTART=hwmon0/device/pwm1=50 hwmon0/device/pwm2=50 MINSTOP=hwmon0/device/pwm1=45 hwmon0/device/pwm2=100

Running fancontrol on every reboot Now I have conf igured everything, so only thing lef t to do is to run f ancontrol. To start f ancontrol just write f ancontrol in the console as root user (or using sudo). f ancontrol will however stop when the console is closed or the computer is rebooted. T he solution to have f ancontrol running on every restart is to create a init.d script. T he f ollowing should be

entered in to a f ile called /etc/init.d/fancontrol

#!/bin/sh # # Fancont rol st art script . # set -e # Default s DAEMON=/usr/sbin/fancont rol PIDFILE=/var/run/fancont rol.pid PATH=/sbin:/bin:/usr/sbin:/usr/bin t est -f $DAEMON || exit 0 . /lib/lsb/init -funct ions case "$1" in st art ) log_begin_msg "St art ing fancont rol daemon..." st art -st op-daemon --st art -o -q -m -b -p $PIDFILE -x $DAEMON log_end_msg $? ;; st op) log_begin_msg "St opping fancont rol daemon..." st art -st op-daemon --st op -o -q -p $PIDFILE log_end_msg $? ;; force-reload|rest art ) sh $0 st op sh $0 st art ;; *) log_success_msg "Usage: /et c/init .d/fancont rol {st art |st op|rest art |force-reload}" log_success_msg " st art - st art s syst em-wide fancont rol service" log_success_msg " st op - st ops syst em-wide fancont rol service" log_success_msg " rest art , force-reload - st art s a new syst em-wide fancont rol service" exit 1 ;; esac exit 0

and then the script should be executable and added to rc.d:

root @bohr:~# chmod +x /et c/init .d/fancont rol root @bohr:~# updat e-rc.d fancont rol default s 99 01 Adding syst em st art up for /et c/init .d/fancont rol ... /et c/rc0.d/K01fancont rol -> ../init .d/fancont rol /et c/rc1.d/K01fancont rol -> ../init .d/fancont rol /et c/rc6.d/K01fancont rol -> ../init .d/fancont rol /et c/rc2.d/S99fancont rol -> ../init .d/fancont rol /et c/rc3.d/S99fancont rol -> ../init .d/fancont rol /et c/rc4.d/S99fancont rol -> ../init .d/fancont rol /et c/rc5.d/S99fancont rol -> ../init .d/fancont rol

Monitoring the temperatures Personally I use gkrellm, see image, to monitor the temperatures and f anspeeds but there are lots of programs out there, such as xsensors.

Special cases A f riend of my Kre H. Jensen made a special script f or controlling the ASUS Eee PC Howto reduce f an noise level on the eee pc 900 1000 1000h [hartvig.de] Howto reduce f an noise level on the eee pc 900 1000 1000h part ii [hartvig.de] For T hinkpad owners there is nice program called tpfand which I have written about on this page Server setup [tjansson.dk] under the section called Noisy fan. References Fan speed control [wiki.archlinux.org] HOWT O: Fancontrol [ubuntuf orums.org]

You might also like