Difference between revisions of "Fan speed control"

From ArchWiki
Jump to: navigation, search
(added note and began to convert to third person but it's late and I'm tired)
(Splite section.)
(16 intermediate revisions by 7 users not shown)
Line 2: Line 2:
 
[[it:Fan Speed Control]]
 
[[it:Fan Speed Control]]
 
[[ru:Fan Speed Control]]
 
[[ru:Fan Speed Control]]
Controlling the speed (and sound!) of your CPU fan is easy!
+
{{Article summary start}}
 +
{{Article summary text|Fancontrol, part of {{Pkg|lm_sensors}}, can be used to control the speed and sound of CPU/case fans.  This article covers configuration/setup of the utility}}
 +
{{Article summary heading|Related}}
 +
{{Article summary wiki|Lm_sensors}}
 +
{{Article summary end}}
 +
== Sensor driver ==
 +
Support for newer motherboards may not yet be in the Linux kernel.  Check the official [http://www.lm-sensors.org/wiki/Devices lm-sensors devices] table to see if experimental drivers are available for such motherboards.
  
=== Before beginning ===
+
It is recommended not to use lm_sensors.service to load the needed modules for fancontrolInstead, manually place them in {{ic|/etc/modules-load.d/load_these.conf}} since the order in which these modules are loaded dictate the order in which the needed symlinks for hwmon get createdIn other words, using the lm_sensors.service causes inconsistencies boot-to-boot which will render the configuration file for fan control worthless for a consistency point of view.
Support for newer motherboards may not yet be in the linux kernelCheck the official [http://www.lm-sensors.org/wiki/Devices lm-sensors devices] table to see if experimental drivers are available for such motherboardsAt the time this statement was written for example, support for the Asus P8Z77 series of motherboards was not mainlined, yet the {{AUR|nct677x-git}} package was available in the [[AUR]].
+
 
 +
For more, see this thread: https://bbs.archlinux.org/viewtopic.php?pid=1251766
  
 
=== lm-sensors ===
 
=== lm-sensors ===
 
{{Warning|This may ruin your hardware! A CPU fan is needed to cool your CPU and in this HOWTO, your CPU fan will be turned off for a couple of seconds. If you are not comfortable with doing this, then do ''not'' do this!}}
 
 
 
Set up [[Lm_sensors|lm_sensors]].
 
Set up [[Lm_sensors|lm_sensors]].
  
<pre>$ sensors
+
{{bc|1=$ sensors
 
coretemp-isa-0000
 
coretemp-isa-0000
 
Adapter: ISA adapter
 
Adapter: ISA adapter
 
Core 0:      +29.0°C  (high = +76.0°C, crit = +100.0°C)   
 
Core 0:      +29.0°C  (high = +76.0°C, crit = +100.0°C)   
  
coretemp-isa-0001
+
[...]
Adapter: ISA adapter
+
Core 1:      +29.0°C  (high = +76.0°C, crit = +100.0°C) 
+
 
+
coretemp-isa-0002
+
Adapter: ISA adapter
+
Core 2:      +31.0°C  (high = +76.0°C, crit = +100.0°C) 
+
 
+
coretemp-isa-0003
+
Adapter: ISA adapter
+
Core 3:      +29.0°C  (high = +76.0°C, crit = +100.0°C) 
+
  
 
it8718-isa-0290
 
it8718-isa-0290
Line 40: Line 34:
 
temp1:      +37.5°C  (low  = +129.5°C, high = +129.5°C)  sensor = thermistor
 
temp1:      +37.5°C  (low  = +129.5°C, high = +129.5°C)  sensor = thermistor
 
temp2:      +25.0°C  (low  = +127.0°C, high = +127.0°C)  sensor = thermal diode
 
temp2:      +25.0°C  (low  = +127.0°C, high = +127.0°C)  sensor = thermal diode
</pre>
+
}}
  
 
If the output does not display an RPM value for the CPU fan, one may need to increase the fan divisor. If fan speed is shown and higher than 0, skip the next step.
 
If the output does not display an RPM value for the CPU fan, one may need to increase the fan divisor. If fan speed is shown and higher than 0, skip the next step.
  
 
====Increasing fan_div====
 
====Increasing fan_div====
 +
The first line of the sensors output is the chipset used by the motherboard for readings of temperatures and voltages.
  
The first line of the sensors output is the chipset your motherboard uses to read the speeds, temperatures, and voltages.
+
Edit {{ic|/etc/sensors.d/sensors.conf}} and look up the exact chipset. A few chipset names are similar, so make sure the one to edit is correct. Add the line {{ic|set fanX_div 4}} near the start of the chipset config, replacing X with the number of CPU fans in the target system.
 
+
Create your libsensors configuration file by copying the default libsensors' configuration file to {{ic|/etc/sensors.d/}}
+
# cp /etc/sensors3.conf /etc/sensors.d/sensors.conf
+
 
+
Edit {{ic|/etc/sensors.d/sensors.conf}} and look up your exact chipset. A few chipset names are similar, so make sure the one you are editing is yours. Add the line 'set fanX_div 4' near the start of your chipset config, replacing X with the number of CPU fans your system has.
+
  
 
Save the file, and run as root:
 
Save the file, and run as root:
Line 59: Line 49:
 
Run sensors again and check if there is an RPM readout. If not, increase the divisor to 8, 16 or 32. YMMV!
 
Run sensors again and check if there is an RPM readout. If not, increase the divisor to 8, 16 or 32. YMMV!
  
=== pwmconfig ===
+
== Configuration ==
  
 
{{Note|Advanced users may want to skip this section and write {{ic|/etc/fancontrol}} on their own, which also saves them from hearing all of the fans at full speed.}}
 
{{Note|Advanced users may want to skip this section and write {{ic|/etc/fancontrol}} on their own, which also saves them from hearing all of the fans at full speed.}}
  
Once you have lm sensors properly configured, run {{Ic|pwmconfig}} to test and configure speed control of your fans.
+
Once sensors is properly configured, run {{Ic|pwmconfig}} to test and configure speed control.  Follow the instructions in {{Ic|pwmconfig}} to set up basic speeds.  The default configuration options should create a new file, {{ic|/etc/fancontrol}}.
  
Follow the instructions in {{Ic|pwmconfig}} to set up basic speeds.
+
=== Tweaking ===
  
The default configuration options should create a new file, {{ic|/etc/fancontrol}}.
+
{{Warning|Some of the steps outlined below describe how to tweak fan speeds. Before doing this be sure to have a low CPU load.}}
  
==== Tweaking ====
+
{{Note|On several systems, the included script may report errors as it trys to calibrate fans to the respective PWM.  Users may safely ignore these errors. The problem is that the script does not wait long enough before ramping up or down the PWM.}}
  
{{Warning|Some of the steps outlined below describe how to tweak fan speeds. Before doing this be sure you have low CPU load and are comfortable playing around. If at any time during tweaking you notice the CPU temperature start to rise dramatically, do a {{Ic|echo "255" > /sys/class/hwmon/hwmon0/device/pwm1}} to spin up the fan all the way until things cool down. Basically, you should know what you are doing before altering the configuration file.}}
+
Users wishing more more control may need to tweak the generated configuration. Here is a sample configuration file:
 
+
{{Note|On several systems, the included script may report errors as it trys to calibrate your fan to the PWM. You may safely ignore these errors. The problem is that the script does not wait long enough before ramping up or down the PWM.}}
+
 
+
If you want more control, you will probably need to tweak the generated configuration. Here is a sample configuration file:
+
 
  INTERVAL=10
 
  INTERVAL=10
 
  DEVPATH=hwmon0=devices/platform/coretemp.0 hwmon2=devices/platform/w83627ehf.656
 
  DEVPATH=hwmon0=devices/platform/coretemp.0 hwmon2=devices/platform/w83627ehf.656
Line 88: Line 74:
 
* '''INTERVAL''': how often the daemon should poll CPU temps and adjust fan speeds. INTERVAL is in seconds.
 
* '''INTERVAL''': how often the daemon should poll CPU temps and adjust fan speeds. INTERVAL is in seconds.
  
The rest of the configuration file is split into (at least) two values per configuration option. Each configuration option first points to a PWM device which is written to which sets the fan speed.  The second "field" is the actual value to set. This allows you to monitor and control multiple fans and temperatures (if your PC supports it).
+
The rest of the configuration file is split into (at least) two values per configuration option. Each configuration option first points to a PWM device which is written to which sets the fan speed.  The second "field" is the actual value to set. This allows monitoring and controlling multiple fans and temperatures.
  
* '''FCTEMPS''': The temperature input device to read for cpu temperature.  The above example corresponds to {{Ic|/sys/class/hwmon/hwmon0/device/temp1_input}}.
+
* '''FCTEMPS''': The temperature input device to read for CPU temperature.  The above example corresponds to {{Ic|/sys/class/hwmon/hwmon0/device/temp1_input}}.
 
* '''FCFANS''': The current fan speed, which can be read (like the temperature) in {{Ic|/sys/class/hwmon/hwmon0/device/fan1_input}}
 
* '''FCFANS''': The current fan speed, which can be read (like the temperature) in {{Ic|/sys/class/hwmon/hwmon0/device/fan1_input}}
 
* '''MINTEMP''': The temperature (&deg;C) at which to '''SHUT OFF''' the CPU fan.  Efficient CPUs often will not need a fan while idling. Be sure to set this to a temperature that ''you know is safe''. Setting this to 0 is not recommended and may ruin your hardware!
 
* '''MINTEMP''': The temperature (&deg;C) at which to '''SHUT OFF''' the CPU fan.  Efficient CPUs often will not need a fan while idling. Be sure to set this to a temperature that ''you know is safe''. Setting this to 0 is not recommended and may ruin your hardware!
Line 104: Line 90:
 
  cat /sys/class/hwmon/<hwmon-device>/device/name | sed -e 's/[[:space:]=]/_/g'
 
  cat /sys/class/hwmon/<hwmon-device>/device/name | sed -e 's/[[:space:]=]/_/g'
  
=== fancontrol ===
+
{{Tip|Use '''MAXPWM''' and '''MINPWM''' options that limit fan speed range. See {{Ic|man fancontrol}} for details.}}
 +
 
 +
== fancontrol ==
  
 
Try to run fancontrol:
 
Try to run fancontrol:
  /usr/sbin/fancontrol
+
  # /usr/bin/fancontrol
 
+
It should start up and you will probably hear your CPU fan spin down.
+
 
+
If fancontrol is working, you may want to start up {{ic|fancontrol}} at boot via {{ic|/etc/[[rc.conf]]}}.
+
 
+
''Most of this HOWTO is from the [[http://ubuntuforums.org/ Ubuntu forums]] and the [[http://ubuntuguide.org/ Ubuntu guide]].''
+
 
+
{{Note|For Dell Latitude/Inspiron laptops, you may want to use {{Pkg|i8kutils}}/{{Pkg|i8kmon}}. Note that these two packages do ''not'' work on the Inspiron 1764.}}
+
 
+
=== Simple Bash script to fine tune fan speed ===
+
Run this as root if you would like to see how various pwm values translate into fan RPM. As you can see, this script assumes that you have fancontrol running and disables it for you, then re-enables it when you are finished.
+
 
+
<pre>
+
#!/bin/bash
+
clear
+
 
+
#################################################
+
# change the following lines to match your system
+
#################################################
+
pwmcontrol=/sys/class/hwmon/hwmon4/device/pwm1
+
fanrpmread=/sys/class/hwmon/hwmon4/device/fan1_input
+
 
+
# do not edit below this line
+
#################################################
+
log=`pwd`/fandata.log
+
echo "PWM,RPM" > $log
+
 
+
echo "This script will set your PWM to values from full power down to 0 decreasing in"
+
echo "approx 5 % steps and pausing 10 sec between steps to allow the fan RPM to catch"
+
echo "up to the new settings.  Data are logged to ${log}"
+
echo "which can be used to generate a graph or use as-is."
+
 
+
collectdata() {
+
array=( 255 242 230 217 204 191 178 165 152 139 126 113 100 87 74 48 22 0 )
+
for item in ${array[*]}
+
do
+
echo $item > $pwmcontrol
+
sleep 10s
+
rpm=`cat ${fanrpmread}`
+
echo $item,$rpm >> $log
+
echo "PWM: ${item} RPM: ${rpm}"
+
done
+
}
+
  
/etc/rc.d/fancontrol stop
+
A properly configured setup will not error out and will take control of system fans.  Users should hear system fans slowing shortly after executing this command.
echo "1" > ${pwmcontrol}_enable
+
  
collectdata
+
{{Note|For Dell Latitude/Inspiron laptops, {{Pkg|i8kutils}}/{{Pkg|i8kmon}} are available. Note that these two packages do ''not'' work on the Inspiron 1764.}}
  
echo "0" > ${pwmcontrol}_enable
+
To make fancontrol start automatically on every boot as a service run:
/etc/rc.d/fancontrol start
+
# systemctl enable fancontrol
</pre>
+
# systemctl start fancontrol

Revision as of 10:42, 19 October 2013

Template:Article summary start Template:Article summary text Template:Article summary heading Template:Article summary wiki Template:Article summary end

Sensor driver

Support for newer motherboards may not yet be in the Linux kernel. Check the official lm-sensors devices table to see if experimental drivers are available for such motherboards.

It is recommended not to use lm_sensors.service to load the needed modules for fancontrol. Instead, manually place them in /etc/modules-load.d/load_these.conf since the order in which these modules are loaded dictate the order in which the needed symlinks for hwmon get created. In other words, using the lm_sensors.service causes inconsistencies boot-to-boot which will render the configuration file for fan control worthless for a consistency point of view.

For more, see this thread: https://bbs.archlinux.org/viewtopic.php?pid=1251766

lm-sensors

Set up lm_sensors.

$ sensors
coretemp-isa-0000
Adapter: ISA adapter
Core 0:      +29.0°C  (high = +76.0°C, crit = +100.0°C)  

[...]

it8718-isa-0290
Adapter: ISA adapter
Vcc:         +1.14 V  (min =  +0.00 V, max =  +4.08 V)   
VTT:         +2.08 V  (min =  +0.00 V, max =  +4.08 V)   
+3.3V:       +3.33 V  (min =  +0.00 V, max =  +4.08 V)   
NB Vcore:    +0.03 V  (min =  +0.00 V, max =  +4.08 V)   
VDRAM:       +2.13 V  (min =  +0.00 V, max =  +4.08 V)   
fan1:        690 RPM  (min =   10 RPM)
temp1:       +37.5°C  (low  = +129.5°C, high = +129.5°C)  sensor = thermistor
temp2:       +25.0°C  (low  = +127.0°C, high = +127.0°C)  sensor = thermal diode

If the output does not display an RPM value for the CPU fan, one may need to increase the fan divisor. If fan speed is shown and higher than 0, skip the next step.

Increasing fan_div

The first line of the sensors output is the chipset used by the motherboard for readings of temperatures and voltages.

Edit /etc/sensors.d/sensors.conf and look up the exact chipset. A few chipset names are similar, so make sure the one to edit is correct. Add the line set fanX_div 4 near the start of the chipset config, replacing X with the number of CPU fans in the target system.

Save the file, and run as root:

# sensors -s

which will reload the sensors.conf's set variables. Run sensors again and check if there is an RPM readout. If not, increase the divisor to 8, 16 or 32. YMMV!

Configuration

Note: Advanced users may want to skip this section and write /etc/fancontrol on their own, which also saves them from hearing all of the fans at full speed.

Once sensors is properly configured, run pwmconfig to test and configure speed control. Follow the instructions in pwmconfig to set up basic speeds. The default configuration options should create a new file, /etc/fancontrol.

Tweaking

Warning: Some of the steps outlined below describe how to tweak fan speeds. Before doing this be sure to have a low CPU load.
Note: On several systems, the included script may report errors as it trys to calibrate fans to the respective PWM. Users may safely ignore these errors. The problem is that the script does not wait long enough before ramping up or down the PWM.

Users wishing more more control may need to tweak the generated configuration. Here is a sample configuration file:

INTERVAL=10
DEVPATH=hwmon0=devices/platform/coretemp.0 hwmon2=devices/platform/w83627ehf.656
DEVNAME=hwmon0=coretemp hwmon2=w83627dhg
FCTEMPS=hwmon0/device/pwm1=hwmon0/device/temp1_input
FCFANS= hwmon0/device/pwm1=hwmon0/device/fan1_input
MINTEMP=hwmon0/device/pwm1=20
MAXTEMP=hwmon0/device/pwm1=55
MINSTART=hwmon0/device/pwm1=150
MINSTOP=hwmon0/device/pwm1=105
  • INTERVAL: how often the daemon should poll CPU temps and adjust fan speeds. INTERVAL is in seconds.

The rest of the configuration file is split into (at least) two values per configuration option. Each configuration option first points to a PWM device which is written to which sets the fan speed. The second "field" is the actual value to set. This allows monitoring and controlling multiple fans and temperatures.

  • FCTEMPS: The temperature input device to read for CPU temperature. The above example corresponds to /sys/class/hwmon/hwmon0/device/temp1_input.
  • FCFANS: The current fan speed, which can be read (like the temperature) in /sys/class/hwmon/hwmon0/device/fan1_input
  • MINTEMP: The temperature (°C) at which to SHUT OFF the CPU fan. Efficient CPUs often will not need a fan while idling. Be sure to set this to a temperature that you know is safe. Setting this to 0 is not recommended and may ruin your hardware!
  • MAXTEMP: The temperature (°C) at which to spin the fan at its MAXIMUM speed. This should be probably be set to perhaps 10 or 20 degrees (°C) below your CPU's critical/shutdown temperature. Setting it closer to MINTEMP will result in higher fan speeds overall.
  • MINSTOP: The PWM value at which your fan stops spinning. Each fan is a little different. Power tweakers can echo different values (between 0 and 255) to /sys/class/hwmon/hwmon0/device/pwm1 and then watch the CPU fan. When the CPU fan stops, use this value.
  • MINSTART: The PWM value at which your fan starts to spin again. This is often a higher value than MINSTOP as more voltage is required to overcome inertia.

There are also two settings fancontrol needs to verify the configuration file is still up to date. The lines start with the setting name and a equality sign, followed by groups of hwmon-class-device=setting, seperated by spaces. You need to specify each setting for each hwmon class device you use anywhere in the config, or fancontrol will not work.

  • DEVPATH: Sets the physical device. You can determine this by executing the command
readlink -f /sys/class/hwmon/<hwmon-device>/device | sed -e 's/^\/sys\///'
  • DEVNAME: Sets the name of the device. Try
cat /sys/class/hwmon/<hwmon-device>/device/name | sed -e 's/[[:space:]=]/_/g'
Tip: Use MAXPWM and MINPWM options that limit fan speed range. See man fancontrol for details.

fancontrol

Try to run fancontrol:

# /usr/bin/fancontrol

A properly configured setup will not error out and will take control of system fans. Users should hear system fans slowing shortly after executing this command.

Note: For Dell Latitude/Inspiron laptops, i8kutils/i8kmon are available. Note that these two packages do not work on the Inspiron 1764.

To make fancontrol start automatically on every boot as a service run:

# systemctl enable fancontrol
# systemctl start fancontrol