How to Use pwmconfig for Linux Fan Speed Control

The pwmconfig script is an interactive configuration utility bundled with the lm-sensors software package that enables automated fan speed control on Linux systems. This article explains the primary function of pwmconfig, how it tests hardware to correlate system cooling fans with pulse-width modulation (PWM) outputs and temperature sensors, and how it outputs the necessary configuration file used by the background fancontrol daemon to dynamically adjust fan speeds.

What is the pwmconfig Script?

In the Linux environment, low-level hardware monitoring is typically managed by the lm-sensors framework via the sysfs filesystem (located at /sys/class/hwmon/). While modern hardware often allows the operating system to regulate fan speeds via Pulse Width Modulation (PWM), manually identifying which PWM control corresponds to which physical fan and which temperature sensor is difficult.

The pwmconfig script automates this discovery process. It acts as an interactive setup wizard that tests your system's fan controllers, helps you associate specific fans with specific motherboard or CPU temperature inputs, and defines thermal thresholds.

Core Functions of pwmconfig

The pwmconfig script performs several automated diagnostic and configuration tasks:

  1. Detection of PWM Controls and Fans: The script scans the system for supported hardware monitoring chips that expose PWM outputs (usually named pwm1, pwm2, etc.) and fan tachometers (named fan1_input, fan2_input, etc.).
  2. Correlation Testing: To determine which PWM output controls which fan, pwmconfig cycles through each PWM channel, systematically changing the duty cycle value (from 255 down to 0). It monitors the tachometer readings to observe which fan slows down or stops when a specific PWM value is altered.
  3. Threshold Calibration: The script helps determine the minimum PWM value required to spin up each fan from a dead stop, as well as the minimum speed at which the fan can reliably run without stalling.
  4. Sensor-to-Fan Mapping: Once fans and controllers are paired, the script prompts the user to link each fan to a specific temperature sensor (such as CPU core, GPU, or motherboard ambient sensors).
  5. Configuration Generation: After establishing the desired temperature ranges (minimum and maximum operating temperatures), pwmconfig compiles these parameters into a structured configuration file, typically saved to /etc/fancontrol.

Relationship with the fancontrol Daemon

It is important to note that pwmconfig does not actively regulate fan speeds in real time. It is solely a configuration generation tool.

Once pwmconfig has written /etc/fancontrol, the ongoing task of dynamic fan speed regulation falls to fancontrol, a background daemon. When enabled as a systemd service, fancontrol reads the configuration generated by pwmconfig, monitors system temperatures continuously, and dynamically adjusts the PWM duty cycles according to the thermal curves defined during setup.

Prerequisites and Safety Considerations

To execute pwmconfig, the system must already have hardware monitoring drivers loaded. Users typically must run sensors-detect first to ensure the kernel recognizes the onboard monitoring chips.

Because pwmconfig temporarily stops fans during its diagnostic cycle to correlate controllers with tachometers, it should be executed with root privileges (sudo pwmconfig) when the system is idle. Stopping cooling fans during intensive workloads can lead to rapid thermal buildup. If a system lacks compatible driver support for its hardware monitoring chip, pwmconfig will notify the user that no PWM-capable sensors were detected.