Fan Control on Linux Servers

In a home server running 24/7, the cooling fan is typically the component most prone to wear and tear, and where issues tend to surface most visibly. Due to long-term operation, you may suddenly experience severe abnormal noise from the fan caused by a misaligned shaft or bearing degradation. For compact servers such as the one built in our previous article, “Introduction to a Mini PC Recording Server Built with ASRock Beebox + PT3“, higher fan rotation speeds further amplify this noise. While replacing the physical part is clearly the ultimate solution, arranging replacement parts usually takes a few days. Therefore, as an immediate stopgap measure until the replacement arrives, we can implement a method to control fan behavior directly from the Linux side and minimize unpleasant noise.

目次

Buying Time Until Hardware Replacement Through Technology

The purpose of this article is to use standard Linux (such as CentOS 7) toolsets to directly intervene with the hardware monitoring chip on the motherboard and manipulate fan speeds. By redefining a flexible fan curve on the OS side—independent of BIOS or UEFI settings—it becomes possible to avoid specific rotation ranges where abnormal noise occurs, or to completely stop the fan under low loads. The goal is to cover physical failures with software hacks, achieving both the continuation of system operation and a quiet living environment.

Defining the Balance Between Silence and Cooling

As a concrete control target, we set the fan output to a PWM value of 0 (complete stop) during idle times when the CPU temperature is relatively low. This reduces physical noise in regular use ranges to zero. On the other hand, to prevent thermal runaway as temperatures rise, we maintain a failsafe that forcibly cools the system at maximum output if the CPU temperature exceeds 70°C. Rather than simply silencing the noise, the goal of this interim measure is to draw a clear boundary between “stationary" and “cooling" based on thermometer readings.

The Barrier of Automatic Control and Identifying Control Ports

When attempting fan control in a Linux environment, the biggest challenges are “identifying the target for control" and “the intervention of hardware-based automatic control." On many motherboards, the chipset independently manages fan speeds and ignores casual write attempts from the OS. Additionally, because multiple devices and PWM ports exist under /sys/class/hwmon/, you need to track down which port is actually wired to the physical fan. Getting this wrong risks failing to cool areas that need it, causing fatal damage to the system.

Reconstructing the Fan Curve Using lm_sensors and sysfs

Below is the procedure for solving these issues and implementing fan control in a general-purpose Linux environment.

Installing and Scanning with lm_sensors

First, install the standard package used to retrieve and manipulate temperature and fan speeds.

yum install -y lm_sensors

After installation, identify the sensor chips on the motherboard using the following command.

sensors-detect

Answer “YES" to all prompts and save the configuration at the end to allow the kernel to recognize each sensor.

Identifying Control Ports and Changing Modes

In many environments, hardware-based automatic control is enabled by default. Check the status of each port with the following command.

cat /sys/class/hwmon/hwmon1/pwm[1-5]_enable

If the value is 5 (such as Smart Fan mode), manual operations will not be accepted. Write 1 to all ports to switch them to manual mode.

echo 1 > /sys/class/hwmon/hwmon1/pwm1_enable
echo 1 > /sys/class/hwmon/hwmon1/pwm2_enable
echo 1 > /sys/class/hwmon/hwmon1/pwm3_enable
echo 1 > /sys/class/hwmon/hwmon1/pwm4_enable
echo 1 > /sys/class/hwmon/hwmon1/pwm5_enable

Identifying the Target Fan (Live Verification)

In some cases, it may be unclear which PWM port is connected to the physical fan. Run the following commands in sequence to find the port where the fan stops (the noise disappears).

echo 0 > /sys/class/hwmon/hwmon1/pwm1
# ...
echo 0 > /sys/class/hwmon/hwmon1/pwm5

In our testing, the abnormal noise vanished the moment 0 was written to pwm2, allowing us to identify pwm2 as the control target. Be sure to return the other PWMXs to their original modes.

Analyzing the Default Fan Curve

Before changing settings, check the default control points (auto_point) held by the chipset. In our test environment, the following values were configured.

Control Point Temperature Threshold (temp) Output Value (PWM) Status Guide
Point 1 50,000 (50°C) 0 Stopped
Point 2 55,000 (55°C) 76 Low-speed rotation (noise occurs)
Point 3 65,000 (65°C) 204 Medium-speed rotation (noise occurs)
Point 4 70,000 (70°C) 229 High-speed rotation
Point 5 73,000 (73°C) 255 Maximum rotation

Rewriting the Fan Curve (auto_point)

To suppress abnormal noise, set the output of points corresponding to regular use ranges (e.g., 55°C to 65°C) to "0".
# Stop the fan at the 55°C and 65°C points
echo 0 > /sys/class/hwmon/hwmon1/pwm2_auto_point2_pwm
echo 0 > /sys/class/hwmon/hwmon1/pwm2_auto_point3_pwm

This allows you to logically create a “semi-fanless" state where the fan only spins under high load.

Conclusion

While the golden rule of maintenance is to “promptly replace broken parts," Linux’s powerful control mechanisms provide a clear answer to how to comfortably get through downtime until replacement, or how to eliminate unnecessary noise during low-load periods. The direct manipulation through the sysfs interface introduced here is a versatile hack applicable not only to compact servers like the BeeBox, but also to many Linux systems. Supplementing physical limitations with logical operations and tailoring tools to suit your exact needs—this is precisely the kind of enjoyment found at the intersection of “craftsmanship and technology" cherished here at Nando Kobo.