Fan control and hard drive temperature on Thecus N2100 with Debian Lenny

If you have installed a Debian lenny ( kernel 2.6.26-2-iop32x ) on your Thecus 2100 NAS device the fan is not automatically controlled by default and it is running on a full speed. The default value is 255 as specified in :

cat /sys/class/i2c-adapter/i2c-0/0-002e/pwm2

To change the default values use a echo command. For example to turn off the fan use:

echo 0 > /sys/class/i2c-adapter/i2c-0/0-002e/pwm2


if the pwm2 file did not produce the desired outcome you may try pwm1 instead.

The main reason to put a fan on lower RPM is to get rid of the noise. However, make sure that you check your hard drives temperature before you leave the fan turned off completely:

# apt-get install hddtemp

Not check your hard drive temperature with something like:

# hddtemp /dev/sd?
/dev/sda: SAMSUNG HD501LJ: 50°C
/dev/sdb: SAMSUNG HD501LJ: 50°C

For me, at the moment the best solution is to switch off a fan if the hard drive’s temperature is below working temperature. This is specified by the hard drive vendor. My SAMSUNG HD501LJ working temperature is from 0 – 60 C so I’m willing to take that risk to let it heat up to 57 C and then turn on the fan with some low value such as 40. If the hard drive temperature increases to the MAX level of 60 C then the fan will start to spin with a full power ( 255 ) and the system will beep 3 times to get me notified. Here is a very primitive bash script to do this job. The script is run by a cron every 5 minutes.


From some reason /sys/class/i2c-adapter/i2c-0/0-002e/pwm2 can regulate the fan and sometimes it is /sys/class/i2c-adapter/i2c-0/0-002e/pwm1 which need to be altered to change the fan speed. Because of this I’m resetting values of both files in the script below. First install beep and hddtemp if you have not done it previously:

# apt-get install beep hddtemp

Now create a script with a following code:


TEMP=$(/usr/sbin/hddtemp /dev/sdb | cut -d: -f3 | sed 's/..$//' | sed 's/ //')

if [ $TEMP -ge 60 ]; then
        beep -l 1000 -r 3 
        echo 255 > /sys/class/i2c-adapter/i2c-0/0-002e/pwm1
        echo 255 > /sys/class/i2c-adapter/i2c-0/0-002e/pwm2

elif [ $TEMP -ge 57 ]; then
        echo 40 > /sys/class/i2c-adapter/i2c-0/0-002e/pwm1
        echo 40 > /sys/class/i2c-adapter/i2c-0/0-002e/pwm2

        echo 0 > /sys/class/i2c-adapter/i2c-0/0-002e/pwm1
        echo 0 > /sys/class/i2c-adapter/i2c-0/0-002e/pwm2

Make the script executable open up a root’s cron file:

# crontab -e

and place a following line there to run the above script every 5 minutes:

*/5 * * * * /path/to/your/script/