Installation and Configuration of fanctl for Fonz fun_plug

German version of this tutorial

This tutorial is deprecated and should only be used with fonz fun_plug 0.5!
Please check the tutorial page for updated tutorials on this topic!

The CH3SNAS, as well as other small nas devices, has a small fan at the back. This fan is necessary because the NAS can generate significant amounts of heat when one or two drives are used heavily.

CH3SNAS fan
CH3SNAS fan
Although the fan is speed-controlled through software provided by Conceptronic, the fan never switches off completely. Some people find this too noisy for quiet environments like bedrooms or even some offices. An obvious solution is to turn the CH3SNAS off entirely when it is not in use (e.g. at night), but this is very inconvenient and it gives problems when the CH3SNAS may be accessed occasionally by remote (Internet) users.

Thanks to the fun_plug, the user can change the fan control algorithm to reduce noise, save a bit of power and reduce wear on the fan itself.

Contents

  1. Replacing the default fan control software
    1. The standard fan control solution
    2. Using shell scripts versus using binaries
  2. Installation
    1. Installing fanctl
    2. Activating fanctl
  3. How fanctl works
    1. Warning!
    2. The graph
    3. Temperatures
    4. Fan speed
    5. Changing fanctl.conf
  4. Notes
    1. A CH3SNAS in a hot room
    2. Shut down on overheating
    3. Logging the temperature
    4. Deinstallation

Replacing the default fan control software

The standard fan control solution

By default, the fan is controlled by a program embedded within the CH3SNAS called fancontrol. This program adjusts the fan speed depending on the temperature measured inside the CH3SNAS.

Conceptronic also provides two other utilities which are helpful to control the fan:

  • temperature – shows the actual temperature (on some devices in Fahrenheit and on others in Celsius) by entering the command "temperature g 0"
  • fanspeed – returns the current fan speed when you enter "fanspeed g". It can also set a new fan speed by entering the command "fanspeed w YourFanSpeed" (where YourFanSpeed is the desired speed in Rotations Per Minute).

Using shell scripts versus using binaries

There are different ways to control the fan. In any case the new software needs to stop (“kill”) the built-in fancontrol program provided by Conceptronic before it takes over control.

One approach is to use the programs temperature and fanspeed within a simple bash script that repeatedly measures the temperature and adjusts the fan speed accordingly. Such a script can even choose to turn off the fan entirely below a certain temperature. But a script-based approach, which, compared to a compiled C program, uses more (valuable) memory and CPU cycles.

Fortunately Fonz, the author of fun_plug, has written a small and efficient binary program named fanctl. It controls the fan without relying on the temperature and fanspeed) programs and without using the bash shell. This efficiency is nice as the program is intended to run as long as the CH3SNAS is powered up. By default, fanctl adjusts the fan speed every 30 seconds if needed.

Installation

Installing fanctl

Uli has created a package to simplify installation of fanctl.

In this tutorial we assume that the fun_plug is already installed on the NAS and that you synchronized Uli’s repository (see here for instructions on how to do this). Afterwards install the package (see detailed instructions here):

funpkg -i /ffp/pkg/additional/ffp-misc/fanctl-*.tgz
cp /ffp/etc/examples/fanctl.conf /ffp/etc/fanctl.conf

The final steps copies default configuration settings to the appropriate directory.

Activating fanctl

Please make sure, that no other scripts than the original fancontroller are active! You can check this by:

ps aux|grep fan

This should show the following output (the process identification numbers will vary):

1431 root fancontrol
12620 root grep fan

These are all the running processes (ps) which were filtered (grep) on whether they include the text fan somewhere in their name. Despite appearances, [http://en.wikipedia.org/wiki/Ps_(Unix)#Options aux] is not a command or name, but 3 separate options for ps with a missing “-” this time.

Now test the first run of the fanctl script by entering the following command on the command line:

sh /ffp/start/fanctl.sh start

After entering the above command, the fan will run with a audible noise for a few seconds. You can check the correct opertion of fanctl now:

ps aux|grep fan

This should show the following output (again the PID numbers will vary):

12628 root     /ffp/sbin/fanctl /ffp/etc/fanctl.conf
12635 root     grep fan

This shows that the fancontrol process disappeared and was replaced by the fanctl process (with its configuration file).

As the last step, you can activate the daemon permanently:

chmod a+x /ffp/start/fanctl.sh

How fanctl works

To understand or to adjust the behaviour of fanctl, you may want to inspect its configuration file /ffp/etc/fanctl.conf. If you use the nanoeditor:

nano /ffp/etc/fanctl.conf

Under normal circumstances the defaults should be fine.

Warning!

Do not change these values unless you completely understand the consequences.
Overheated hard drives can lead to data loss or early drive failure. So if you want to change the settings in the configuration file, please study the following documentation carefully and test any modifications you make carefully.

The graph

The graph (by Uli) explains how the program adjusts the fan speed. It assumes the default settings (which you won’t change unless you need to and know what you are doing – right?). Room temperature is typically about 20 degrees Celcius (68 degrees Fahrenheit).

Fanctl adjusts the fan speed depending on the measured temperature
Fanctl adjusts the fan speed depending on the measured temperature

When you boot the CH3SNAS, but hardly use the drives the temperature should increase a few degrees, but stay well below 40 degrees. In that case, the fan follows the blue line: it stays off because there is no real need to cool the CN3SNAS yet. However, when you use the drives a lot, the temperature can rise above 40 degrees. Especially if the room temperature also happens to be hot. This causes the fan to switch on. The fan speed (in RPM) follows the curved slope (part of a parabolic curve). The maximum fan speed is limited by default to 6300 RPM (called pwm_hi). Like the original software, there is a actually a safety threshold as well: above 51 degrees, the CN3SNAS is turned off. The latter shouldn’t normally happen unless something goes very wrong (like a broken drive, or operating your CH3SNAS in the sauna).

Now assume that the CH3SNAS has become relatively hot (say 45 degrees Celcius), but the drives now enter a period of infrequent access. This causes the drive motors to automatically shut down, reducing heat production and causing the temperature to drop. Every 30 seconds, a drop in temperature will cause the fan to slow down. When the temperature drops below 40 degrees (called temp_hi) the fan speed stabilizes for a while. When the temperature then drops below 37 degrees (called temp_lo), the fan is turned off.

Note that turning the fan on and off occur at different temperatures. This is called (hysteresis). This reduces the chance that at some temperature the fan repeatedly runs for 30 seconds, then turns off for 30 seconds, and then turns on again.

Temperatures

If you want to change the temperatures (e.g. if the fan never switches off completely (NAS too warm) or you want to cool it down to a certain level), there are various values in the script for configuring these. All values have to be set in Celsius*1000! E.g. 40Β°C would be 40000

There are four different values:

  • temp_stop: If the temperature decreases below this value, the fan is set to the speed, which is configured as the variable pwm_stop (normally this will be zero and thus stops the fan). If the temperature rises about this temperature, nothing happens (hysteresis). Default is 37 degrees Celcius.
  • temp_lo: If the temperature rises above this temperature, pwm_start will be set for one second (Starts the fan). After this, the fan speed will be adjusted somewhere beween pwm_lo and pwm_hi – depending on the measured temperature. If the temperature drops below this temperature, the fan runs at pwm_lo (hysteresis). Default is 40 degrees Celcius.
  • temp_hi: If the temperature rises above this value, pwm_hi is set as fan speed. Default is 50 degrees Celcius.
  • temp_crit: If the temperature rises above this value, the CH3SNAS is shut down to prevent damage. Default is 51 degrees Celcius. Be extra careful with this value.

Fan speed

If you want to change the fan speed (e.g. if you think, the fan turns too slowly or if you want the fan to idle and not to stop), there are various values in the script for configuring these.

  • pwm_stop: This is the speed which is set below temp_stop. If set to zero, the fan will halt. It may not be a good idea to use really low non-zero values here (difficult to run the fan smoothly at these speeds).
  • pwm_start: This is the speed which is set for one second if pwm_stop was set and the temperature rises above temp_lo again. (Default: 3200 rpm)
  • pwm_lo: This is the speed which is set at temp_lo. (Default: 2700 rpm)
  • pwm_hi: This is the speed which is set at temp_hi. (Default: 6300 rpm)

Between pwm_lo and pwm_hi the fan speed will be interpolated according to the following formula:

RPM = (pwm_hi - pwm_lo) * (temp - temp_lo) / (temp_hi - temp_lo) * (temp - temp_lo) / (temp_hi - temp_lo) + pwm_lo

Changing fanctl.conf

Again, editing fanctl.conf should be done with care. Just editing the file will not cause the new values to be used immediately because the running program reads the file once when it starts. One safe way to reload a modified /ffp/etc/fanctl.conf file is to simply reboot the CH3SNAS. When the program is started, it will load the modified /ffp/etc/fanctl.conf file. Another way is to use

cd /ffp/start
sh fanctl.sh status
sh fanctl.sh restart
sh fanctl.sh status

The sh fanctl.sh retart stops and restarts the fan. Actually between the stop and the restart, fancontrol is briefly run.

Notes

A CH3SNAS in a hot room

According to the graph, if you put the CH3SNAS in a very hot environment (e.g. 38 degrees Celcius), the fan will turn on – even when the hard disks are not being used. Turning the fan on wouldn’t help lower the device temperature: it will only get the device temperature closer to room temperature. Currently the software cannot distinguigh this condition (but this obviously also applies to the default fancontrol software which never turns the fan off).

Shut down on overheating

In exceptional conditions, the CH3SNAS will shut down if it ever reaches temp_crit (typically 51′ Celcius). When it shuts down, it will create a file named OVERHEAT in the root directory. By checking for this file and its creation or modification time, you can get confirmation about the cause of the shutdown.

See the file /ffp/etc/fanctl.conf for more details how this works.

Logging the temperature

From an E-mail exchange with fonz (this hasn’t been tested):

PeterH> Other features might be more fun (e.g. log of temperature?).

That’s pretty easy. Just change /ffp/start/fanctl.sh and replace

/ffp/sbin/fanctl $fanctl_config >/dev/null 2>/dev/null </dev/null &

with

/ffp/sbin/fanctl $fanctl_config >/mnt/HD_a2/fan.log 2>&1 </dev/null &

You can plot nice graphs from the log file using gnuplot:

gnuplot> set timefmt "%Y-%m-%d %H:%M:%S"
gnuplot> set xdata time
gnuplot> plot '< grep fan /path/to/fan.log' u 1:4 w st, '' u 1:8 w st

Deinstallation

If you deinstall fanctl using

funpkg -r /ffp/pkg/additional/fanctl-2-1.tgz

and reboot your CH3SNAS, you will find using

ps aux|grep fan

that the original fancontrol appication automatically reappears. This is because fanctl is activated via a script (/ffp/start/fanctl.sh) that stops the default fancontrol process before starting the fanctl program.

This implies that deinstalling funplug and rebooting will also return fan behaviour back to the default behavior and default mechanisms provided by Conceptronic.

47 thoughts on “Installation and Configuration of fanctl for Fonz fun_plug”

  1. Beautiful documentation, thank you πŸ™‚

    I wish you hadn’t mentioned gnuplot, it got me quite excited, but it looks like there’s not an ffp version of this.

    1. Hello Tom,

      i’ve compiled gnuplot, you can find it in my repository. Perhaps you could tell me if it works?

      Thanks,
      -Uli

      1. Sorry Uli
        I seem to have given up using this device for the time being, but I haven’t forgotten your kindness in case I need to try later.
        Tom

  2. What could be the problem when the default fancontrol application isn`t working good.

    The temperature is always 0 Celsius and 32 Fahrenheit. Even, I can`t control the fan.

  3. I installed this functl but still my fan don’t stop even if temperature is 32 degrees in Celsius. In system log i found
    fan can’t stop, check it please
    Maybe this is some hardware problem, but how can i check it ?

  4. Hi!

    I have a DNS-320 device, and i installed fun_plug on it.
    Everything works well, with little modifications, but i can’t use fanctl.

    In debug mode i see this:

    DNS-323 kernel mode
    2011-01-11 21:46:31 temp: 0 fan: 0 pwm: 0
    2011-01-11 21:47:01 temp: 0 fan: 0 pwm: 0
    2011-01-11 21:47:31 temp: 0 fan: 0 pwm: 0

    The only thing, what i changed in fanctl.sh is the d-link supplied daemon name: fan_control

    If you need more information of the dns320, just ask it πŸ™‚

    1. Hi,

      i have a DNS-320 myself but fanctl is definitely not working yet. I will search for another way to control the fan, probably scriptbased. Until then, leave the internal fan_control active.

      Regards,
      Uli

      1. Any updates for fanctl for the DNS-320 ?
        hoping to quiet down the fan when my harddisks are idling.

      2. So I’m trying to implement a script for controlling the fan on my DNS-320.
        tried to use the “temperature g 0” command.
        but the output keeps giving me the same output –

        ———————————————————–
        root@dlink-F966FA:/usr/local/modules/sbin# temperature g 0
        temperature: system temperature = 0
        ———————————————————–

        looking at the help for the temperature binary shows:
        —————————————————————————
        root@dlink-F966FA:/usr/local/modules/sbin# temperature h
        temperature – query and set the temperature sensor

        Usage: temperature [function]

        Functions:
        h – show this help
        w [1,2] degree – set temperature degree in register 1:Thyst 2:Tos
        g [0~2] – get temperature in register 0:temperature 1:Thyst 2:Tos
        root@dlink-F966FA:/usr/local/modules/sbin#
        ————————————————————————

        any ideas ? or have the temperature command stopped working for DNS-320 as well.

      3. Hi,

        for dns-320 there was a typo in fanctl.sh

        Please replace:

        # Kill the old fan controller
        PID=$(/bin/pidof fancontrol)
        if [ -n “$PID” ]
        with

        # Kill the old fan controller
        PID=$(/bin/pidof fan_control)
        if [ -n “$PID” ]

        After that the old process will be killed and it will work.

        Apparently they changed the name

        regards
        Lars

  5. Same fan-issue here in a DNS320.
    Where is located the sensor or the “cpu” ?
    Can i low it using a heat spreeder on it?

    1. No one answered here, but in another place someone used a ramsink and didn’t help nothing.
      Here is the warning.

    1. Hi,
      They should go to standby as the Tool is copied to the internal memory before it’s executed.
      Cheers
      Uli

  6. I exactly followed this tutorial and had autoreboot with OVERHEAT-file after first copy operation in a result. HW C1, FW 1.09. HDD WD Caviar Green WD20EARS (single). What can be a reason of issue?

    Note: during installation fan didn’t run “with a audible noise for a few seconds”, but fanctl process was croped up (including after NAS reboot).

      1. Correct it is not compatible. I will add this at the top of this post. I already have a working solution available, which i’m currently testing on my NAS. As this is a critical functionality i’d like to test it for a while before publishing it too quickly.

        Cheers,
        Uli

    1. There is a way, i already have a solution available. But i didn’t publish it yet as is wanted to test the tool for a while first.

      Cheers
      Uli

  7. The noise of my DNS-320 drives me crazy too. What if I just pull the fan off and make it run fully fanless? Has anyone tried that?
    I guess I will do, I cannot stand that noise anymore πŸ™‚

    1. As you could see, Uli is trying a fan control, of course is mainly about the noise…

      Making it fully fanless is not a good idea as you could see it get’s very hot, especially if not in design position.
      If at least has the top off, maybe; if completely closed, NO, don’t think so.

      But hey, it’s your equipment :))

      1. I gave it a try yesterday, got rid of the top, killed the fan_control process, typed in “fanspeed s” and started to enjoy the silence πŸ™‚
        Then copied over a few hundreds of GB worth of data, streamed 2 movies to my wdtv live. Not a single noise, good πŸ™‚ and it reported 51 celsius, HDDs 48 celsius. Okay, didnt want to raise the limits so then gave some rest to the baby at night.
        The little noisy bastard is still working.. πŸ™‚

  8. Uli,

    I appreciate all the the tweaking and testing that you do. You have said that you have a working solution for the fan issue. It has been in the testing phase for approximately two months. Can you tell us how close it is to being released?

    Thanks

    1. Rob,

      the solution is already live, but i think there is no article here yet. For the time being, you can see the commands for installing it (in the CODE-Sections) in my german article.

      Cheers,
      Uli

      1. Hi,

        Could someone write english article for installing fan control to DNS-320. I can translate german article with google translate but I’m afraid it changes something critical.

        Thanks.

        1. Hi,

          Have you already tried fan control on DNS-320? Any progress in this? Please share info with us. Thanks a lot.

  9. Hi

    is there a way to disable the fan_control logs because my logs list is always full after a day ? I just want to keep the other logs (login,…)

    Thank you ! Cheers

  10. I have installed fanctl on DNS-343 and now I see these lines in the log:

    dns323_read_fan: Operation not supported
    dns323_write_fan: Operation not supported
    2012-02-01 09:34:03 temp: 36000 fan: 0 pwm: 0

    Can someone explain what this means?

  11. I’m getting rather annoyed with the fan noise from my NSA310, but unfortunately I’ve already installed FFP 0.7 for other reasons… is there any hope of someone creating a fanctl for FFP 0.7?

    Thx

  12. Hi,

    I have found solution for my DNS-320. Fanctl doesn’t work in my device and there isn’t temperature binary to find out device’s temperature.

    I create a solution using uwfancontrol package and presented CGI script to get temperature.

    REMEMBER THAT IT IS YOUR OWN RESPONSIBILITY TO USING THIS SCRIPT AND IN WORST CASE YOU CAN DAMAGE YOUR DEVICE! I decided to share it because manufactured fan is very anoying and i want to find any solution.

    At firts place install uwfancontrol package (you can use many tutorials on this website.

    And then replace content of /ffp/var/opt/uwfancontrol/uwfancontrol.sh to:

    #!/bin/sh
    PATH=/usr/bin:/bin:/usr/sbin:/sbin
    # This is a DNS-320/325 or alike
    BINARYNAME=fan_control

    # Kill the old fan controller
    PID=$(/bin/pidof $BINARYNAME)
    if [ -n "$PID" ]; then
    /bin/kill -9 $PID
    fi
    ## Settings for the Temperatures
    # Fan stops below TSTOP
    TSTOP=45

    # Fan is set to low below TLOW and higher than TSTOP
    TLOW=51

    # NAS shutdown at that temperature
    TSHUTDOWN=60

    ## Find out current temperature
    T=`REQUEST_METHOD=GET QUERY_STRING="cmd=cgi_get_status" /var/www/cgi-bin/status_mgr.cgi 2>/dev/null | grep temperature | grep -o ":[0-9]\+" | grep -o "[0-9]\+"`

    # Default fan speed is "high", something can go bad
    NEWVAL="h"
    if [ $T -lt $TLOW ]; then
    NEWVAL="l"
    fi
    if [ $T -lt $TSTOP ]; then
    NEWVAL="s"
    fi
    echo "`date` temp=$T fanspeed=$NEWVAL" >> /mnt/HD/HD_a2/fan.log
    if [ $T -gt $TSHUTDOWN ]; then
    # NAS is overheated, initiate shutdown
    /bin/touch /tmp/shutdown
    else
    # Set fan to new speed
    /usr/sbin/fanspeed $NEWVAL &> /dev/null
    fi

    I’m really RECOMENDING you to test script in console before use. It’s tested on my own DNS-320 (fw ver. 2.02) only.

    FYI: script also create a log file in root of your filesystem

  13. Hi, can you give me help to install uwfancontrol?

    I did this steps:

    funpkg -i /ffp/pkg/additional/ffp-misc/uwfancontrol*.tgz

    //i have replace text in uwfancontrol.sh

    cat uwfancontrol.txt > /ffp/var/opt/uwfancontrol/uwfancontrol.sh

    but funcontrol is still running and I can’t see uwfancontrol

    root@Closet:/mnt/HD/HD_a2/ffp/start# ps aux|grep fan
    1593 root fan_control 0 c
    4108 root grep fan

    What I did wrong?

    1. Hi,

      I’m still confused what script is O.K. for my DNS-320. Which script #1″uli:fanctl1-2-arm-1txz”
      or
      #2 “uli:uwfancontrol-1.3-arm-1.txz”
      is able to work on my DNS-320 (and work better than the D-Link one? Any help is appreciated.

  14. but whers gnuplot?
    i use fun plug 0.7
    fancontrol is ok
    but tplot don’t have gnuplot
    some times ago, Uli said to search in his repo … I haven’t fond any gnuplot package

Leave a Reply

Your email address will not be published. Required fields are marked *