July 3, 2013

Stop laptop fans from working full speed on Linux after suspend!

 
After restoring most laptops that I work on fans start goind full speed after suspend and resume instead reularing speed as they usually do.
If you are afflicted with this bug then you are probably also very annoyed by this kernel bug...
 

There is a simple process to stop this behaviour. First let's see how many thermal/cooling_devices your system reports, so just do:
 
su -
ls -al /sys/class/thermal/cooling_device*
lrwxrwxrwx. 1 root root 0 Jul 1 11:14 /sys/class/thermal/cooling_device0
lrwxrwxrwx. 1 root root 0 Jul 1 11:14 /sys/class/thermal/cooling_device1
lrwxrwxrwx. 1 root root 0 Jul 1 11:14 /sys/class/thermal/cooling_device2
lrwxrwxrwx. 1 root root 0 Jul 1 11:14 /sys/class/thermal/cooling_device3

 
Some systems have 0-3, some 0-7 and others 0-15, so you need to use correct values in your final script.
 
Here is what you can do to for a quick fix, just issue this command:
 
for i in {0..7}; do echo 0 > /sys/class/thermal/cooling_device$i/cur_state; done
 
and to make things permanent you need to add a script for this:
 
cat > / etc/pm/sleep.d/fan_fix.sh < < EOF

!/bin/sh

case “$1″ in
thaw|resume)
for i in {0..7}; do echo 0 > /sys/class/thermal/cooling_device$i/cur_state; done
;;
*)
;;
esac
EOF
chmod +x / etc/pm/sleep.d/fan_fix.sh

 
Please notice leading space before "etc", and remove it.