Scheduled maintenance — back soon.

~/blog/fan-runs-full-speed-resume-suspend

Fan runs at full speed after resume

9 Mar 2015

cat:linux

tags:#fan#resume#speed

OK, let's suppose you have a PC (laptop/desktop) which runs the GNU Linux. Normally when you just step out to drink a coffee or smth. you suspend it in memory then you wake it up via resume. What to do if the fan runs at full speed after resume from suspend? Well, remember, you are on Linux. It means you are the boss! You control it and not vice-versa (see Windows). First make sure you check the following:

  • the lm-sensors package is installed (lm_sensors is a free open source software-tool for Linux that provides tools and drivers for monitoring temperatures, voltage, humidity and fans).

  • the pm-utils package is installed (pm-utils is a suspend and powerstate setting framework).

We assume that these two are installed/configured properly. Check the sensors temperature by running the sensors command:

~ # sensors
acpitz-virtual-0
Adapter: Virtual device
temp1:        +47.0C  (crit = +110.0C)
temp2:        +25.4C  (crit = +110.0C)
temp3:        +100.0C (crit = +110.0C)
temp4:        +51.0C  (crit = +110.0C)

coretemp-isa-0000
Adapter: ISA adapter
Core 0:       +45.0C  (high = +105.0C, crit = +105.0C)
Core 1:       +48.0C  (high = +105.0C, crit = +105.0C)

As you can see the third sensor temperature indicates 100 degrees which I'm sure it's just hogwash. These sensors have an interface in /sys/class/thermal/cooling_deviceX where X is a number. I don't know which sensor binds what but I will detect it by trial and error. We will run the following command for X between 0 and the last cooling_device shown in the above folder:

echo "0" > /sys/class/thermal/cooling_deviceX/cur_state; # X should be a number >= 0

At some point the fan stops (you will notice because the average dB in the room will lower). That is your cooling device! Now let's program the system to run this statement each time the system resumes from the suspend. With other words we will create create a hook on the pm-utils resume event which will reset the cooler. All the built-in hooks are already present in /usr/lib/pm-utils/sleep.d/ folder. We will add our new hook (which is nothing but a bash/sh script) to that folder. Just create a file called /usr/lib/pm-utils/sleep.d/60fan with the following content:

#!/bin/bash
case $1 in
   thaw|resume)
       echo "Fixing fan speed"
       echo "0" > /sys/class/thermal/cooling_device0/cur_state
   ;;
esac

Make sure it has eXecute bit on so after creating that file run the following command:

chmod +x /usr/lib/pm-utils/sleep.d/60fan

Put your laptop on suspend then resume it. The fan should run at its lowest speed. If not then just replicate the following line (within our 60fan file):

echo "0" > /sys/class/thermal/cooling_device0/cur_state

for all X between 0 and the latest cooling device. That's all folks!

Comments

No comments yet

Be the first to leave a comment.

Leave a comment

Name and email required · moderated before publish · plain text only