Temperature-based fan speed control for unRAID



Recommended Posts

... sounds interesting - I have it87 too - so I understand, I could easily control the (HD)fans via those pwm commands in a script (when HD fans are connected to a header that supports that)? How do I get the HD temperatures via script?

I have WD drives, that support temperature reading while spin down afaik.

 

Link to comment
  • Replies 56
  • Created
  • Last Reply

Top Posters In This Topic

How do I get the HD temperatures via script?

Try something like this as a starting point:

 

for i in /dev/[hs]d?

do

  hdparm -C $i 2>/dev/null | egrep "standby|unknown" >/dev/null

  if [ "$?" != 0 ]; then

    echo "=== $i ==="

    temp=`smartctl -d ata -A $i | grep -i temperature | sed 1q | awk '{ print $10 }'`

    if [ "$temp" != "" ]

    then

      if [ "$temp" -gt "40" ];then

        echo overtemp

      fi

    fi

    echo "-"${temp}"-"

  fi

done

 

Link to comment

Bubba, do you think it's possible to use a 4-pin splitter to control two (maybe three) fans with one PWM header?  Something like this:

http://www.newegg.com/Product/Product.aspx?Item=N82E16812123297

If you think that'd work, I'd be really interested in fan speed control for the 120mm fans by my hard drives.  I wouldn't care if they all ran at the same speed.

 

As an example, the fans could spin really slowly when all drives are spun down (or the fans could turn off completely).  Then when temps reach 30C they turn on slowly, when temps reach 35C they spin faster.

Link to comment

Bubba, do you think it's possible to use a 4-pin splitter to control two (maybe three) fans with one PWM header?  Something like this:

http://www.newegg.com/Product/Product.aspx?Item=N82E16812123297

If you think that'd work, I'd be really interested in fan speed control for the 120mm fans by my hard drives.  I wouldn't care if they all ran at the same speed.

 

As an example, the fans could spin really slowly when all drives are spun down (or the fans could turn off completely).  Then when temps reach 30C they turn on slowly, when temps reach 35C they spin faster.

 

afaik there are pwm fans that can be cascaded - it's only limited by the current the mb can supply on the pwm header. so depending on the fans, you can use several fans on one header and control them via a script - that's the way I plan to do...

Link to comment

Problem 1:

 

If you use a splitter on fan headers, you can mess up the speed reading, and can't detect fan failures.

Fix  is to clip the yellow lead, and get speed reading from only 1 fan... but then you can't detect a fan failure in the other fan.

 

Problem 2:

 

Multiple fans pull more juice... and can exceed the max current the mobo can provide.  Then the magic smoke can leak out.  So watch current ratings on fans and make SURE you don't exceed the mobo limit.

 

Problem 3:

 

Different fans will have different RPM and noise at the same PWM setting.  Solution is that if you do use splitters, split to two of the SAME model fan.

 

This is why I like the additional hardware options of the Matrix or the T-balancer... you have more fan headers and don't need splitters.

Link to comment

I'm working on an application in C that will be useful for temperature/fan scripts.

 

One thing it will do is return the maximum temp of drives.  And it has a built-in table of drive models (WD so far) that will return temperatures when spun down.  It does all the ioctl calls naively, so it does not use hdparm, smartctl, or shell out to call any other programs.  It is all self-contained, so it runs much faster then repetitive calls to smartctl.

 

I plan to expand it to other useful pieces of info that can be cumbersome to get, such as:

 

"unraid_info  max_drive_temp"    will return the temp of the hottest drive (ex.  "38")

"unraid_info  max_temp_disk"     will return the disk number of the hottest drive (ex.  "3")

 

"unraid_info  freespace"                will return the total freespace of the array in MB

"unraid_info  max_free"                will return the freespace of the drive with the most free in MB

"unraid_info  max_free_disk"        will return the disk number the drive with the most free (i.e. "3")

"unraid_info  max_free_path"       will return the mountpoint the drive with the most free (i.e. "/mnt/disk3")

"unraid_info  max_free_device"    will return the device of the drive with the most free (i.e. "/dev/sdc")

 

You get the idea.

 

Ultimately, I plan for it to work with a config file that described fan PWM settings for each fan port, and the associated temperatures that will drive changes in fan settings.

 

Once unRAID 5 is out, a web applet can be used to edit/maintain the configuration file in a nice user interface.

Link to comment

Problem 1:

 

If you use a splitter on fan headers, you can mess up the speed reading, and can't detect fan failures.

Fix  is to clip the yellow lead, and get speed reading from only 1 fan... but then you can't detect a fan failure in the other fan.

OK, I could deal with that.  My unRAID box isn't stuffed away in a closet, so I'd see one of the fans stop spinning (these fans are on the front of my Antec 900).  Plus, that would be no different than my current molex-only Antec TriCool fans...

Problem 2:

 

Multiple fans pull more juice... and can exceed the max current the mobo can provide.  Then the magic smoke can leak out.  So watch current ratings on fans and make SURE you don't exceed the mobo limit.

OK, that is definitely something to watch out for.  I'll peruse my mobo manual.

Problem 3:

 

Different fans will have different RPM and noise at the same PWM setting.  Solution is that if you do use splitters, split to two of the SAME model fan.

I'd make sure to do this.  I was planning on replacing the fans by my hard drives anyway.

This is why I like the additional hardware options of the Matrix or the T-balancer... you have more fan headers and don't need splitters.

Thinking about my scenario, I can certainly see the utility of something like the Matrix.  Is there any possibility of displaying drive temps, drive failures, etc on the screen?  IMHO $60 is a tad high for just a fan speed controller (although I might buy one anyway if there is promising progress in this thread).

Link to comment
Thinking about my scenario, I can certainly see the utility of something like the Matrix.  Is there any possibility of displaying drive temps, drive failures, etc on the screen?  IMHO $60 is a tad high for just a fan speed controller (although I might buy one anyway if there is promising progress in this thread).

 

Most definitely.  I have a prototype almost working now.  It's chewing-gum-and-duct-tape but it is a proof-of-concept.

 

In addition to writing to the Matrix Display, I'm going to write to /proc/unraid_info, so other apps (like FEMUR) can read the data.

 

 

Link to comment

jupilerman, try running "modprobe it87" first.

nope : no it87

Tower login: root
Password:
Linux 2.6.31.12-unRAID.
root@Tower:~# modprobe it87
FATAL: Module it87 not found.
root@Tower:~# ls -la /sys/devices/platform
total 0
drwxr-xr-x 6 root root    0 Mar 13 08:19 ./
drwxr-xr-x 8 root root    0 Mar 13 08:19 ../
drwxr-xr-x 5 root root    0 Mar 13 08:19 i8042/
drwxr-xr-x 4 root root    0 Mar 13 08:19 pcspkr/
drwxr-xr-x 2 root root    0 Mar 13 09:41 power/
drwxr-xr-x 4 root root    0 Mar 13 08:19 serial8250/
-rw-r--r-- 1 root root 4096 Mar 13 09:41 uevent
root@Tower:~# Linux 2.6.31.12-unRAID.

Link to comment

If this tool comes out and works well with unraid it would be nice to have more sensors compiled with the kernel. Hopefully Limetech will do that. I had to recompile the kernel to get the sensor for my board. Actually, sense the sensor options in the current kernel are enabled we should just be able to compile whatever extra modules are needed for other boards and install them as optional packages.

Link to comment

One issue to deal with is drives that report "bad" temperatures.  As several users have reported, some drives report temperatures that are way too low (even below ambient).  In such a case, the defaults may not be optimal.

 

I think the best way to handle this is in a configuration file, have a section for each drive (by serial number) like:

 

[WDC999999999]

MIN_FAN_TEMP=28

MAX_FAN_TEMP=40

READ_SMART_WHEN_IDLE=N

 

[sAMSUNG999999999]

MIN_FAN_TEMP=17

MAX_FAN_TEMP=29

READ_SMART_WHEN_IDLE=Y

 

In this case, the Samsung drive reads about 11 degrees too low.

 

So if the Samsung temp is 17 or below, the fan will be set to your specified minimum value (usually the highest speed where the sound of the fan is inaudible).  At 29 the fan speed will be set to the maximum.  Above 29, it will be set to the absolute max of 255.  In between 17 and 29, the fan speed will be set to an interpolated value between the min and max.

 

The WD drive will work the same way, but with a range of 28 to 40 instead of 17 to 29.

 

Comments?

Link to comment

One issue to deal with is drives that report "bad" temperatures.  As several users have reported, some drives report temperatures that are way too low (even below ambient).  In such a case, the defaults may not be optimal.

 

I think the best way to handle this is in a configuration file, have a section for each drive (by serial number) like:

 

[WDC999999999]

MIN_FAN_TEMP=28

MAX_FAN_TEMP=40

READ_SMART_WHEN_IDLE=N

 

[sAMSUNG999999999]

MIN_FAN_TEMP=17

MAX_FAN_TEMP=29

READ_SMART_WHEN_IDLE=Y

 

In this case, the Samsung drive reads about 11 degrees too low.

 

So if the Samsung temp is 17 or below, the fan will be set to your specified minimum value (usually the highest speed where the sound of the fan is inaudible).  At 29 the fan speed will be set to the maximum.  Above 29, it will be set to the absolute max of 255.  In between 17 and 29, the fan speed will be set to an interpolated value between the min and max.

 

The WD drive will work the same way, but with a range of 28 to 40 instead of 17 to 29.

 

Comments?

I think that's a great way to work out varying hard drive temperatures.  I assume I could test the accuracy of the reported temperature value by placing a temperature sensor on the top of my hard drive?  I don't have any Samsung drives (which are known to have way-off temperatures), but I have noticed a bit of variance between my hard drives in the same position cooled by the same fan. (admittedly this could be perfectly normal, i.e. my WD Green drive runs cooler than my 7200rpm drives, but that makes sense)

Link to comment

[WDC999999999]

MIN_FAN_TEMP=28

MAX_FAN_TEMP=40

READ_SMART_WHEN_IDLE=N

That's a little confusing... If I can't read smart when that disk is idle, then when can I read smart?

Maybe this would be a little more intuitive....

READ_SMART_WHEN_SLEEP=Y  -- "It's OK to read smart when this disk is sleeping, that won't disturb this disk."

READ_SMART_WHEN_SLEEP=N  -- "Don't read smart when this disk is sleeping, as that would wake up this disk."

 

Link to comment

READ_SMART_WHEN_IDLE=Y means that the drive can return drive temps when it is idle, so you can read this drive's temp even if it is spun down

 

READ_SMART_WHEN_IDLE=N means if the drive is spun down, then DON'T try to read the temperature.

I think the confusing part is "IDLE" vs. "SLEEP"

 

To many, the distinction is "SPINNING" vs. "NOT_SPINNING" (or "SLEEPING")

 

Perhaps consider

READ_SMART_WHEN_NOT_SPINNING=Y/N

It is much more clear (at least to me) ;)

Link to comment
READ_SMART_WHEN_NOT_SPINNING=Y/N

 

That's fine with me!

 

I have the C code about done that does the ioctl functions for drive data and temps (unraid_info), and that will read/write to the Matrix display and the fan ports on the Matrix (unraid_fancontrol).  I'm going to modify it to also be able to use the mobo pwm ports.

 

Next step is to finalize the format of the config file, and write an application that will read/write the config file, with a user interface.  Needs to be able to test fan ports so the user can 1) ID which port is which on the mobo, and 2) decide what to set for low/hig fan PWMs.  Also need to test the drives to determine if they can return SMART data when they are spun down.  My C code has some basic smarts in this area which will work as a default, but it will be better for each user to be able to test each of his drives once, and store it in the config so it will be 100% accurate.

 

The config file will need info on fans.  Each fan will have a section like:

 

[FAN1]

FAN_NUMBER=1

FAN_NAME=Chassis Fan Header1

FAN_SPEED_PORT=/sys/devices/platform/it87.552/fan2_input

FAN_PWM_PORT=/sys/devices/platform/it87.552/pwm2

FAN_PWM_PORT_enable=/sys/devices/platform/it87.552/pwm2_enable

FAN_OFF_SPEED=50

FAN_LOW_SPEED=110

FAN_HIGH_SPEED=195

 

[FAN2]

FAN_NUMBER=2

FAN_NAME=Matrix Display Fan port 1

FAN_SPEED_PORT=MATRIX1

FAN_PWM_PORT=MATRIX1

FAN_PWM_PORT_enable=MATRIX1

FAN_OFF_SPEED=50

FAN_LOW_SPEED=110

FAN_HIGH_SPEED=195

 

 

Link to comment

Perhaps consider

READ_SMART_WHEN_NOT_SPINNING=Y/N

 

First, I prefer to avoid double negatives when possible.  (Give positive meanings to your variables).

 

Second, READ_SMART_WHEN_NOT_SPINNING=N  is the same as CAN_READ_SMART_WHEN_SLEEP=N  and means: No, don't read SMART if this disk is asleep, because doing so will wake up this particular disk, and that is not desirable. Only the second form is more clear.

 

Link to comment

How about:  READ_SMART_WHEN_SPUN_DOWN=Y/N

 

Note this parameter is not a statement of the drive's capability... it is an instruction to the application (that is set after testing a drive, but that can be overridden -- you COULD set the config to read SMART from a drive when spun down, knowing that it will cause the drive to spin up)

Link to comment

How about:  READ_SMART_WHEN_SPUN_DOWN=Y/N

 

Note this parameter is not a statement of the drive's capability... it is an instruction to the application (that is set after testing a drive, but that can be overridden -- you COULD set the config to read SMART from a drive when spun down, knowing that it will cause the drive to spin up)

Of all the proposed names, that makes the most sense to me.  No double negatives, and it's fairly obvious that you're talking about whether reading SMART data will spin up the drive or not.

 

Since this seems to be making some fairly good progress, do you know where I can get a Matrix display for relatively cheap? ($60 was mentioned before, are there any places that offer the displays for less than this?)  I'm in the US, so a seller that ships to the US is necessary.

Link to comment

Matrix Orbital has the LK202-24-USB on sale for about $60:

 

http://www.matrixorbital.com/p69/LK202-24-USB/product_info.html

 

Any of the Matrix Orbital models with fan connectors should work.

Alright, so it looks like I'll be able to control: 3 3-pin fans and 1 4-pin fan, as well as having a status display.  Combined with the two controllable PWM (4-pin) fan headers on my ITE87-chipset motherboard, I can control 6 fans total.  Nice!

 

What is the likelihood of getting this to work?:

Our new USB units come with the capability to connect up to a 6 by 4 matrix style keypad.

I'd use this for a standard 5-way Dpad (up, down, left, right, select) to select options on the screen.  Or, if that would be too much work, possibly have a button to start/stop the array, shut down the server (should pop up a warning telling the user to stop the array first, or this could call the clean powerdown script), start a parity check, switch views, etc.  Thoughts?

Link to comment

Whoa there.... where are 4-pin fans coming in the picture?

 

2-pin or 3-pin fans can be controlled by PWM.... the only difference is 2-pin fans have no way to rad their RPM.  4-pin fans use the 4th line for speed control (although theoretically they could also be used on a 2-pin or 3-pin header and controlled by PWM)

 

The Matrix display only controls three 3-pin (or 2-pin) fans.... that's all.

 

Have you confirmed you have PWM control on any fan headers on your mobo?

 

Yes, it is a lot of work to code for the keypad buttons.... that's a complete different kettle of fish, and involves polling for input, which is another order of complexity.  I might get that working, but don't count on it.

Link to comment

2-pin or 3-pin fans can be controlled by PWM.... the only difference is 2-pin fans have no way to rad their RPM.  4-pin fans use the 4th line for speed control (although theoretically they could also be used on a 2-pin or 3-pin header and controlled by PWM)

 

The Matrix display only controls three 3-pin (or 2-pin) fans.... that's all.

I was just going on a picture I looked at on the Matrix Orbital website.  Looking back, the four pin header is probably USB. :-[  EDIT: Looked it up in the manual.  That's for powering the display...

LK202-24-USBBack.jpg

Have you confirmed you have PWM control on any fan headers on your mobo?

Yes.  I have two 4-pin PWM headers on my mobo and one 4-pin PWM fan.  So I tried the handful of commands you posted (a few posts back) on one of the headers, shut my computer down, moved the fan to the other header, and tried on the second header.  It was working perfectly.  I'd tell it a certain PWM value and I'd see the fan speed up, slow down, or stop (if it was too low of a value).

Yes, it is a lot of work to code for the keypad buttons.... that's a complete different kettle of fish, and involves polling for input, which is another order of complexity.  I might get that working, but don't count on it.

That's what I thought, but I figured I'd throw the idea out there in case it wasn't as hard as I imagined.  (I've taken a few C classes myself, eventually I'll take a whole bunch - I'm a Computer Science major :))

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.