Controlling Sony Vaio Desktop Fans in Linux

I have an old 1.8GHz Sony Vaio Desktop that uses a software controlled fan. Sony apparently thought it would be wise to just do everything in software, and would require you to install a Windows service to control the fans. The service was apparently a hack because it doesn't monitor the system temperatures. This lead to all sorts of system stability problems when the computer started getting older.

I've recently built a new computer to replace this aging desktop. I didn't want to waste good hardware so I decided to turn the old Vaio into a linux server.

I installed CentOS (which took ages because the dvd drive was all messed up). During the install, I noticed that the fan was insanely loud. The power supply fan combined with the cpu fan created a horrid noise that could be heard 2 rooms away. A quick search on google confirmed that old Vaios exhibited this fan problem. A few posts noted using something called pwmconfig. A little more research showed that this was a smart fan control configuration script that comes with lm_sensors.

I spent a while messing around with pwmconfig. The script had a flaw in it (it used tempfile instead of mktemp). A quick edit fixed that problem. I eventually gave up messing with smart fan control because I figured I could just use a fixed fan speed (like the method Sony decided to use).

So here is how I did it:

Install lmsensors:
yum install lm_sensors

Detect sensors:
sensors-detect

Run pwmconfig to get fan statistics (note which pwm channel controls which fan):
pwmconfig

Write a script to force fan speeds:

# Makes fan silentish
echo "Setting fan speeds...."
echo "125" > /sys/bus/i2c/devices/9191-0290/pwm1 # cpu fan
echo "75" > /sys/bus/i2c/devices/9191-0290/pwm2 # ps fan

Add the script to autostart on boot (I use console only, hence runlevel 3):
ln -s /root/fanquiet.sh /etc/rc3.d/S99fanquiet

A quick reboot of the system and everything should be working. If it doesn't work at all (no fans changing speeds), then you may need to check your i2c devices path, and make sure the lmsensors service is running.