# System fan control

## dbezona

So I am hoping someone can help me with this, as it seems to be a somewhat obscure problem (many searches have turned up little).

I have a Sony Vaio desktop (not laptop) system - P4 1.7GHz

The issue is that without manual intervention, the system fans run at full blast under Linux - apparently the BIOS in most systems control this, but apparently not mine. (This didn't happen under Windows)

My solution, up until now, is using lm_sensors and a shell script to turn the fans down at boot time, and then GKrellm to monitor the temps, and run a couple of other scripts to turn up the fans if the temperatures exceed a certain point.  

It works fairly well, really, but I am just wondering if there is something missing here - I have been able to find so little reference to the issue in any of the searches I have done over the last few months, I just find it a bit odd.

Anyway, if anyone has any ideas on better ways to handle this, I would be grateful.

----------

## AlterEgo

Your solution is quite nice: good thinking  :Smile: 

but it is risky: what happens if gkrellm were to crash?

(be glad it's not an Atlon processor you've got: it would die very quickly).

I don't think there's something like speedfan for linux:

maybe you can talk the owner into giving access to the source code:

http://www.almico.com/speedfan.php

----------

## dbezona

 *AlterEgo wrote:*   

> Your solution is quite nice: good thinking 

 

Thanks  :Smile: 

 *Quote:*   

> but it is risky: what happens if gkrellm were to crash?
> 
> (be glad it's not an Atlon processor you've got: it would die very quickly).

 

That's really the main reason I am pursuing the question. Not so much that I worry about the system frying (it rarely gets hot enough to trigger even the warn level script, and has never hit the "OHMYGODITSONFIRE!!!" script), but it does require having GKrellm (or some other sensor monotoring app) running all of the time. 

Mostly I am curious as to why this isn't just handled either by the BIOS, or at the kernel level, since it seems like such a fundamental thing...

----------

## Malakin

 *Quote:*   

> (be glad it's not an Atlon processor you've got: it would die very quickly).

 

Most motherboards have thermal protection and P4's are putting out more heat then Athlons these days.

CPU thermal comparison:

http://www.anandtech.com/cpu/showdoc.html?i=1718&p=4

P4 3.06Ghz is 82 watts:

http://www17.tomshardware.com/cpu/20021114/p4_306ht-04.html

AMD XP3000+ is 74.3 watts

http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/26237.pdf

----------

## EvilTwinSkippy

I know it's been said before, but that's a damn cool solution to the problem. (Pardon the pun.)

I would like to point out that a lot of desktops these days are actually using laptop parts. (Hell some dell laptops are starting to use desktop parts, but I digress.)

About the only thing that I would suggest is dropping a watchdog script in your crontab. The watchdog script simply ps's to see if your monitor is working, and if it isn't rekick it. I use that for a tcl script that maintains my cluster of data center servers. The script syncronizes the passwords, downloads patches, and keeps the clocks in tune. Until I discovered ssh, I would have this script execute every hour.

Now, I was actually doing the opposite to what your script needs to do. Instead of restarting 

a stopped program, my script was killing a stuck one. Later on I adapted it to restart dead services.

----------

## hotcamus

In my case, a Compaq Presario laptop, the problem of having the fans running at full speed was an ACPI issue.

Now, with the 2.4.20 vanilla-kernel and its corresponding ACPI patch, the fans work well, as in windows.

----------

## dbezona

 *hotcamus wrote:*   

> In my case, a Compaq Presario laptop, the problem of having the fans running at full speed was an ACPI issue.
> 
> Now, with the 2.4.20 vanilla-kernel and its corresponding ACPI patch, the fans work well, as in windows.

 

Thanks for the suggestion - I recompiled with all of the ACPI stuff enabled, and unfortunately, it didn't work for my system <*sigh*>

----------

## AlterEgo

dbezona,

would you mind posting your fanspeed-control-script?

* curious *

----------

## dbezona

Hehe - sure. Actually, calling it a "script" is generous.

Basically, lm_sensors provides an interface to the various sensors chips within /proc - some of them are manually configurable, two of them (at least for my chip set) provide a method to control the fan speed, simply by changing the value like you would any plain text file.

So, here is my boot-time "script", which turns the fans to a very low speed:

```

echo 50 | cat > /proc/sys/dev/sensors/w83627hf-isa-0290/pwm1

echo 100 | cat > /proc/sys/dev/sensors/w83627hf-isa-0290/pwm2

```

The values can range from 0 to 255 - there really isn't that granular of control - I think most systems have 2 or 3 speeds, so just sort of generalize, and play with the values until the fans respond as you want them.

In my setup, GKrellm simply executes one of two other files that simply write different (higher) values to the pwmx interfaces based on the warning level for the temperature sensors (which is a function of the GKrellm sensors module). 

On my system, it idles around 38-40 degrees (C), and the comfortable maximum temp is around 60 degrees (although supposedly, it can go higher, but why push it?), So, I set my "warn" level to bump the fans up to about 50%, and if it gets over 60, I bump the fans up full (hasn't happened yet). 

Unfortunately, GKrellm doesn't allow for running a script when the warning recovers, so I have to manually run a lower-speed script once the system cools down, but it's a minor inconvenience.

----------

## pjp

You could have the script run a job after 5 minutes (or something) that turns them down.  If the warning comes again, they'd turn up again.  Something like that anyway.

----------

## dbezona

 *kanuslupus wrote:*   

> You could have the script run a job after 5 minutes (or something) that turns them down.  If the warning comes again, they'd turn up again.  Something like that anyway.

 

That's a very good idea indeed. Thanks!

----------

