Control CPU Fan Speed on Linux: A Practical Guide
In this article
You control CPU fan speed on Linux by installing and configuring fan control software such as fancontrol (from the lm-sensors package) or using BIOS/UEFI settings. The most common method is to use the fancontrol script, which reads temperature sensors and adjusts fan speeds via the kernel's PWM interface.
Why You Might Want to Control Fan Speed
Most desktop motherboards and many laptops automatically manage fan speed based on CPU temperature. However, automatic control isn't always optimal. Fans might spin too fast, creating unnecessary noise, or too slow, causing higher temperatures. Controlling fan speed manually lets you:
- Reduce noise for a quieter workstation or home server.
- Improve cooling for overclocked or heavily loaded CPUs.
- Extend fan lifespan by reducing wear from constant high speed.
- Balance temperature and acoustics to your preference.
How Fan Control Works on Linux
Modern Linux kernels expose hardware monitoring and fan control through the hwmon subsystem, typically under /sys/class/hwmon/. Temperature sensors (often from the CPU or motherboard) and fan controllers (PWM outputs) appear as files. The lm-sensors package provides tools like sensors to read temperatures and pwmconfig to detect fan control capabilities.
Fan speed is usually controlled by writing a value between 0 and 255 to a pwmN file, where 0 is off (or minimum) and 255 is full speed. Some systems support automatic mode via pwmN_enable (0 = off, 1 = manual, 2 = automatic). The fancontrol script reads a configuration file and continuously adjusts PWM outputs based on temperature thresholds.
Step-by-Step: Using fancontrol
Here's the typical workflow on a Debian/Ubuntu system (other distributions are similar):
- Install lm-sensors:
sudo apt install lm-sensors(or your package manager's equivalent). - Detect sensors: Run
sudo sensors-detectand answer YES to all questions. This loads kernel modules for your hardware. - Test readings: Run
sensorsto see current temperatures and fan speeds. Note the names of temperature inputs (e.g.,coretemp-isa-0000) and PWM outputs (e.g.,hwmon0/pwm1). - Generate config: Run
sudo pwmconfig. It will scan for PWM-capable fans and ask you to test each one. Follow the prompts; it will create/etc/fancontrol. - Edit config (optional): The generated file contains lines like
FCTEMPS=hwmon0/pwm1=hwmon0/temp1_inputandFCFANS=hwmon0/pwm1=hwmon0/fan1_input. You can adjust temperature thresholds and PWM values manually. - Start fancontrol: Run
sudo systemctl enable fancontrol && sudo systemctl start fancontrolto enable it at boot and start it now.
Choosing the Right Method for Your Hardware
Not all systems support software fan control. Here's what to consider:
- Desktop motherboards: Most have PWM fan headers and are compatible with fancontrol, but some (especially budget boards) may only control CPU fans, not case fans.
- Laptops: Many laptops have proprietary EC (embedded controller) firmware that overrides software control. Tools like
thinkpad_acpiormbpfan(for Macs) may work, but often you have no control. - GPUs: NVIDIA and AMD GPUs have their own fan control via
nvidia-settingsoramdgpukernel parameters, separate from CPU fans. - All-in-one liquid coolers: Some AIOs (like Corsair or NZXT) use USB interfaces; you may need vendor-specific tools like
liquidctl.
If pwmconfig doesn't detect any PWM-capable fans, your hardware likely doesn't expose fan control to the OS. In that case, use BIOS/UEFI settings instead.
Common Problems and Solutions
Even with a compatible system, you may run into issues:
- Fan speed stuck at 100%: Often caused by incorrect PWM polarity or a fan that doesn't support PWM. Try setting
pwmN_enableto 1 (manual) and writing a value directly to see if it responds. - fancontrol doesn't start at boot: Check the service status with
systemctl status fancontrol. The config file may reference paths that change between boots (e.g., hwmon0 vs hwmon1). UseDEVNAMElines in the config to match by device name instead of index. - System crashes or freezes: If you set PWM too low and the CPU overheats, the system may shut down. Always set a minimum safe PWM value (e.g., 50) and test under load.
- Fan spins but speed doesn't change: Some fans are voltage-controlled (3-pin) rather than PWM (4-pin). The kernel may not control them; you'd need a physical fan controller or a motherboard with voltage regulation.
Alternatives to fancontrol
If fancontrol doesn't work for you, consider these alternatives:
- BIOS/UEFI settings: Many motherboards offer fan curves in the firmware. This works even when the OS doesn't have control, but you must reboot to change settings.
- Thinkfan: A lightweight daemon designed for ThinkPad laptops, but it can work with any hwmon device. It uses a config file with temperature-to-speed mappings.
- NVIDIA GPU fan control: Use
nvidia-settingsto set fan speed manually, or use theCoolBitsoption to enable overclocking and fan control. - Liquidctl: For AIO coolers and some motherboards with USB connectivity, this tool can control fans and pumps.
- Manual hardware controller: A physical fan controller (like a bay-bus) gives you direct control without software, but requires hardware installation.
Safety and Best Practices
Controlling fan speed can affect system stability. Follow these guidelines:
- Never disable fans entirely unless you have an alternative cooling solution (like passive heatsinks or liquid cooling). Overheating can damage components.
- Set a minimum PWM value that keeps the fan spinning at a safe speed (typically 30-50% of max).
- Monitor temperatures after changing settings, especially under load. Use
sensorsor a tool likeglancesto verify temps stay within safe limits (usually below 85°C for modern CPUs, but check your CPU specs). - Test gradually: Change one setting at a time and stress-test with
stressorprime95to ensure stability. - Back up your config: Before editing
/etc/fancontrol, copy it so you can revert if something goes wrong.
Frequently Asked Questions
Is it safe to control fan speed on Linux?
Yes, as long as you maintain adequate cooling. The risk comes from setting fans too low, which can cause overheating. Always set a minimum speed and monitor temperatures.
Why doesn't pwmconfig detect my fans?
Your motherboard or laptop may not expose PWM control to the OS. Check if your fans are 4-pin PWM fans and if the kernel has a driver for your hardware. Some systems require additional kernel modules or a BIOS update.
Can I control fan speed on a laptop?
It depends. Many laptops have locked fan control due to firmware. Tools like thinkfan work on some ThinkPads, but often you can only control the CPU fan indirectly through power management settings (e.g., using cpupower to limit CPU frequency, which reduces heat).
What's the difference between PWM and voltage control?
PWM control sends a digital signal to the fan's fourth pin, allowing precise speed control. Voltage control (for 3-pin fans) adjusts the power supply voltage, which is less precise and may not work with all fans. Most modern motherboards support both, but check your fan's connector.
How do I make fancontrol start automatically?
Use systemd: sudo systemctl enable fancontrol. If you're using an older init system, add fancontrol to your startup scripts. Ensure the config file is valid and paths are stable across reboots.
Does controlling fan speed affect performance?
Not directly, but if your CPU gets too hot, it may throttle to reduce temperature, which lowers performance. Keeping temperatures in check with adequate fan speed avoids throttling.