Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Terramaster F4-424 Pro Fan Control

Featured Replies

I was really hoping for a nice GUI solution, but this one just works better, and I am very new to Unraid so I don't know how to make an app myself yet but the below is working flawlessly, so if you have the Terramaster F4-424 hardware, you may want to disable other fan controllers and give this a try. I hope this helps someone!

 

I tried Dynamix System Autofan with the IT87 driver installed. It worked, except for when my array went to standby mode/spun down: The fan stopped, which is bad in this NAS because it was roasting my NVME storage at 60+ degrees celcius without the fan being on. (With fan on low NVME stays in the 30s).

 

I uninstalled the autofan application and followed the instructions on this page:
Controlling Case Fans Based on Hard Drive Temperature – Kevin's Blog

 

Two minor changes i had to make:

I had to add 'bash' to this, and, changed to the name of the script:

# fan control - every 5 min */5 * * * * /boot/config/scripts/fan_control.sh 2>&1 | /usr/bin/logger -t fan_control

So that it looked like this:

# fan control - every 5 min */5 * * * * bash /boot/config/scripts/unraid_array_fan.sh 2>&1 | /usr/bin/logger -t fan_control

 

NOTE: When editing /boot/config/go i had to add an '&' at end of the line that was already in there. This allows the command to run in the background and move on to the next line. Ok, I don't know if I really had to do that, but it seemed like a good idea.

 

The script was not working with my nvme drive to detect its temperature, but my AI chat bot helped me put together this improved script for my need. This works with the four hard drive bays in this NAS plus the one NVME I have installed (if you have two NVMEs installed you may want to add that one to the "HD" list in the script). The beauty of this script is that it works flawlessly even when the spinning hard drives are active or on standby, and it doesn't wake them up. It keeps the fan running adequately to control the NVME temperature when the hard drives are hibernating :) 

 

#!/bin/bash
# Improved unraid_array_fan.sh

### USER CONFIGURATION ###

# List of drives to monitor
HD=(
  /dev/sdb
  /dev/sdc
  /dev/sdd
  /dev/sde
  /dev/nvme0n1
)

# Fan control settings
FAN_OFF_TEMP=25     # °C: fan off at or below
FAN_HIGH_TEMP=45    # °C: fan full speed at or above

# Fan PWM values (0–255)
FAN_OFF_PWM=0
FAN_LOW_PWM=25
FAN_START_PWM=100
FAN_HIGH_PWM=255

# Fan device path
ARRAY_FAN="/sys/class/hwmon/hwmon3/pwm3"

### END OF CONFIGURATION ###


### PROGRAM VARIABLES ###
HIGHEST_TEMP=0
OUTPUT=""
NUM_OF_DRIVES=${#HD[@]}

# Linear PWM calculation
NUM_STEPS=$((FAN_HIGH_TEMP - FAN_OFF_TEMP - 1))
PWM_INCREMENT=$(( (FAN_HIGH_PWM - FAN_LOW_PWM) / NUM_STEPS ))
OUTPUT+="Linear PWM Range: $FAN_LOW_PWM to $FAN_HIGH_PWM in $NUM_STEPS steps of $PWM_INCREMENT\n"


### MAIN LOOP: Get highest drive temperature ###
for DEVNAME in "${HD[@]}"
do
  CURRENT_TEMP=""
  SLEEPING=0

  if [[ "$DEVNAME" == *"nvme"* ]]; then
    # NVMe device
    CURRENT_TEMP=$(smartctl -A "$DEVNAME" | grep -i 'Temperature:' | head -n1 | awk '{print $2}')
  else
    # SATA device
    SLEEPING=$(hdparm -C "$DEVNAME" | grep -c standby)
    if [ "$SLEEPING" == "0" ]; then
      CURRENT_TEMP=$(smartctl -d ata -A "$DEVNAME" | grep -m 1 -i Temperature_Celsius | awk '{print $10}')
    fi
  fi

  # Process valid temperature readings
  if [ "$SLEEPING" == "0" ] && [ -n "$CURRENT_TEMP" ]; then
    OUTPUT+=" -- Drive $DEVNAME temp: $CURRENT_TEMP°C\n"
    if [ "$HIGHEST_TEMP" -lt "$CURRENT_TEMP" ]; then
      HIGHEST_TEMP=$CURRENT_TEMP
    fi
  fi
done

OUTPUT+="Highest drive temp: $HIGHEST_TEMP°C\n"


### FAN CONTROL ###

# Enable fan speed control if needed
if [ "$ARRAY_FAN" != "1" ]; then
  echo 1 > "${ARRAY_FAN}_enable" 2>/dev/null
fi

PREVIOUS_SPEED=$(cat "$ARRAY_FAN")

# Set fan speed based on highest temperature
if [ "$HIGHEST_TEMP" -le "$FAN_OFF_TEMP" ]; then
  echo $FAN_OFF_PWM > "$ARRAY_FAN"
  OUTPUT+="Setting fan PWM: $FAN_OFF_PWM (OFF)\n"
elif [ "$HIGHEST_TEMP" -ge "$FAN_HIGH_TEMP" ]; then
  echo $FAN_HIGH_PWM > "$ARRAY_FAN"
  OUTPUT+="Setting fan PWM: $FAN_HIGH_PWM (HIGH)\n"
else
  # Start fan if needed
  if [ "$PREVIOUS_SPEED" -lt "$FAN_START_PWM" ]; then
    echo $FAN_START_PWM > "$ARRAY_FAN"
    sleep 4
  fi
  # Linear PWM between OFF and HIGH
  FAN_LINEAR_PWM=$(( ((HIGHEST_TEMP - FAN_OFF_TEMP - 1) * PWM_INCREMENT) + FAN_LOW_PWM ))
  echo $FAN_LINEAR_PWM > "$ARRAY_FAN"
  OUTPUT+="Setting fan PWM: $FAN_LINEAR_PWM (LINEAR)\n"
fi

CURRENT_SPEED=$(cat "$ARRAY_FAN")

# Output result
if [ "$PREVIOUS_SPEED" -ne "$CURRENT_SPEED" ]; then
  echo "Fan speed changed."
  echo -e "$OUTPUT"
else
  echo "Fan speed unchanged. Highest temp: $HIGHEST_TEMP°C. Current PWM: $CURRENT_SPEED."
fi

 

I placed the above script into /boot/config/scripts/unraid_array_fan.sh.

 

When I used 'sensors-detect' on the command line, this NAS just shows me:

 

Quote

 

#----cut here----

# Chip drivers

modprobe coretemp

/usr/bin/sensors -s

#----cut here----

 

 

...so all i had to add into the /boot/config/go file was:

Quote

modprobe coretemp

 

I downloaded mycrontab.txt and saved it into /boot/config/scripts/mycrontab.txt:

# fan control - every 5 min */5 * * * * bash /boot/config/scripts/unraid_array_fan.sh 2>&1 | /usr/bin/logger -t fan_control

Then I added the following to /boot/config/go at the bottom:

# setup crontab crontab -l > /tmp/file echo '#' >> /tmp/file echo '# Start of Custom crontab entries' >> /tmp/file cat /boot/config/scripts/mycrontab.txt >> /tmp/file echo '# End of Custom crontab entries' >> /tmp/file crontab /tmp/file rm -f /tmp/file

 

I rebooted and monitored the log window in Unraid to confirm it was working every five minutes as expected.

 

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...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.