Skip to content

Instantly share code, notes, and snippets.

@Kerryliu
Last active January 27, 2026 14:15
Show Gist options
  • Select an option

  • Save Kerryliu/c380bb6b3b69be5671105fc23e19b7e8 to your computer and use it in GitHub Desktop.

Select an option

Save Kerryliu/c380bb6b3b69be5671105fc23e19b7e8 to your computer and use it in GitHub Desktop.
TrueNAS UGREEN DXP4800 Plus Status LED Guide

UGREEN DXP4800 Plus TrueNAS Status LED Guide

20240609_035951642_iOS

The following is a quick guide on getting basic status LED functionality working with TrueNAS running on the UGREEN DXP4800 Plus. Theoretically, it should work on all models (with some small revisions to the script), but I only have a DXP4800 Plus. :)

This guide is for cron job that runs a script to update the LEDs every couple minutes, but I'm sure the following can be modified for blinky LEDs as well.

Steps:

  1. Manually build or download the ugreen_leds_cli tool from https://github.com/miskcoo/ugreen_dx4600_leds_controller.
  2. Plop it somewhere on your NAS (E.g. a dataset).
  3. In the same dataset, create your .sh script that controls the LEDs. At the bottom of this gist is my modified version of meyergru's.
  4. Make the script executable: chmod +X your-script.sh.
    • You may also need to make ugreen_leds_cli executable as well.
  5. In TrueNas, navigate over to System SettingsAdvanced
  6. Under Init/Shutdown Scripts Create the following to load the i2c-dev module on boot:
    • Description: Enable i2c-dev
    • Type: Command
    • Command: modprobe i2c-dev
    • When: Pre Init
  7. Under Cron Jobs we then create a task to run every x minutes:
    • Description: Update Status LEDS
    • Command: /mnt/path/to/your/script.sh
    • Run as User: root
    • Schedule: */5 * * * * (or however often you desire)
  8. Reboot and wait a bit for your cron job to run.

Sources:

Example script:

#! /bin/bash

#set -x

SCRIPTPATH=$(dirname "$0")
echo $SCRIPTPATH

devices=(p n x x x x)
map=(power netdev disk1 disk2 disk3 disk4)

# Check network status
gw=$(ip route | awk '/default/ { print $3 }')
if ping -q -c 1 -W 1 $gw >/dev/null; then
    devices[1]=u
fi

# Map sdX1 to hardware device
declare -A hwmap
echo "Mapping devices..."
while read line; do
    MAP=($line)
    device=${MAP[0]}
    hctl=${MAP[1]}
    partitions=$(lsblk -l -o NAME | grep "^${device}[0-9]\+$")
    for part in $partitions; do
        hwmap[$part]=${hctl:0:1}
        echo "Mapped $part to ${hctl:0:1}"
    done
done <<< "$(lsblk -S -o NAME,HCTL | tail -n +2)"

# Print the hwmap for verification
echo "Hardware mapping (hwmap):"
for key in "${!hwmap[@]}"; do
    echo "$key: ${hwmap[$key]}"
done

# Check status of zpool disks
echo "Checking zpool status..."
while read line; do
    DEV=($line)
    partition=${DEV[0]}
    echo "Processing $partition with status ${DEV[1]}"
    if [[ -n "${hwmap[$partition]}" ]]; then
        index=$((${hwmap[$partition]} + 2))
        echo "Device $partition maps to index $index"
        if [ ${DEV[1]} = "ONLINE" ]; then
            devices[$index]=o
        else
            devices[$index]=f
        fi
    else
        echo "Warning: No mapping found for $partition"
    fi
done <<< "$(zpool status -L | grep -E '^\s+sd[a-h][0-9]')"

# Output the final device statuses
echo "Final device statuses:"
for i in "${!devices[@]}"; do
    echo "$i: ${devices[$i]}"
    case "${devices[$i]}" in
        p)
            "$SCRIPTPATH/ugreen_leds_cli" ${map[$i]} -color 255 255 255 -on -brightness 64
            ;;
        u)
            "$SCRIPTPATH/ugreen_leds_cli" ${map[$i]} -color 255 255 255 -on -brightness 64
            ;;
        o)
            "$SCRIPTPATH/ugreen_leds_cli" ${map[$i]} -color 0 255 0 -on -brightness 64
            ;;
        f)
            "$SCRIPTPATH/ugreen_leds_cli" ${map[$i]} -color 255 0 0 -blink 400 600 -brightness 64
            ;;
        *)
            "$SCRIPTPATH/ugreen_leds_cli" ${map[$i]} -off
            ;;
    esac
done
@daibaron
Copy link

daibaron commented Jan 11, 2026

HI @S2ciOnur
I've reviewed everything but no luck so far.

Any chance to generate a version working with Truenas Scale 25.10.1?

the CLI in combination with a cronjob still works for me

Hi, got my DXP4800P, and I'm very new at Truenas- 25.10.1 and not sure of the updated procedure since this version

- sudo chmod +X your-script.sh = operation not permitted ( not working since 25.10.x)
- can't chmod "ugreen_leds_cli" as well
Edit = Chmod +X is now OK = I moved the files outside an SMB share in the Dataset root so the ACL related to SMB won't apply.
Dataset is : /mnt/[name]

  • I don't understand how to make the change to the /sbin/zpool

Would you be kind enough to make a step-by-step tutorial ?

Best regards

Still asking for help, I will edit once the NAS is working with LED support

@LeslieFH
Copy link

LeslieFH commented Jan 11, 2026

I'm getting the "unexpected status 0x57f" error even when I moved the scripts to the Data pool, they have the correct permissions but don't work :-\

First I tried to run them off the apps pool which is a partition split off the boot SSD but technically not the boot pool and that didn't work either

(Edit: it finally works, and out of the apps pool, I managed to run the scripts using sudo ./script.sh because previously I was trying to run them from root using sudo su )

@daibaron
Copy link

daibaron commented Jan 13, 2026

Any guidance ?

I don't understand how to make the change to the /sbin/zpool in the script or else ?

Can someone be kind enough to make a step-by-step tutorial for Truenas 25.10.1 and a DXP4800+

Best regards

@S2ciOnur
Copy link

S2ciOnur commented Jan 22, 2026

@LeslieFH @daibaron

I'm on TrueNAS 25.10.1 on my DXP4800 plus myself, and it works. I'm extremely tired of this topic. Here’s a FINAL, FINAL step-by-step guide.
Hopefully, this will settle the matter once and for all.

  • Download the CLI:
    https://github.com/miskcoo/ugreen_leds_controller/releases/download/v0.3/ugreen_leds_cli

  • Place the CLI in a folder on your NAS. (For me, it's on the m.2 SSD, which serves as storage for applications) NOT on the Boot SSD!
    /mnt/SSD/ix-applications/setup/DXP_4800LED/HERE!

  • Grant the CLI the necessary permissions (just do chmod 777), give it everything. Everyone can do anything with this CLI. It doesn’t bother anyone!

  • Create a led.sh file with nano and copy and paste this junk into it:


#set -x

SCRIPTPATH=$(dirname "$0")
echo $SCRIPTPATH

devices=(p n x x x x)
map=(power netdev disk1 disk2 disk3 disk4)

# Check network status
gw=$(ip route | awk '/default/ { print $3 }')
if ping -q -c 1 -W 1 $gw >/dev/null; then
    devices[1]=u
fi

# Map sdX1 to hardware device
declare -A hwmap
echo "Mapping devices..."
while read line; do
    MAP=($line)
    device=${MAP[0]}
    hctl=${MAP[1]}
    partitions=$(lsblk -l -o NAME | grep "^${device}[0-9]\+$")
    for part in $partitions; do
        hwmap[$part]=${hctl:0:1}
        echo "Mapped $part to ${hctl:0:1}"
    done
done <<< "$(lsblk -S -o NAME,HCTL | tail -n +2)"

# Print the hwmap for verification
echo "Hardware mapping (hwmap):"
for key in "${!hwmap[@]}"; do
    echo "$key: ${hwmap[$key]}"
done

# Check status of zpool disks
echo "Checking zpool status..."
while read line; do
    DEV=($line)
    partition=${DEV[0]}
    echo "Processing $partition with status ${DEV[1]}"
    if [[ -n "${hwmap[$partition]}" ]]; then
        index=$((${hwmap[$partition]} + 2))
        echo "Device $partition maps to index $index"
        if [ ${DEV[1]} = "ONLINE" ]; then
            devices[$index]=o
        else
            devices[$index]=f
        fi
    else
        echo "Warning: No mapping found for $partition"
    fi
done <<< "$(zpool status -L | grep -E '^\s+sd[a-h][0-9]')"

# Output the final device statuses
echo "Final device statuses:"
for i in "${!devices[@]}"; do
    echo "$i: ${devices[$i]}"
    case "${devices[$i]}" in
        p)
            "$SCRIPTPATH/ugreen_leds_cli" ${map[$i]} -color 255 255 255 -on -brightness 64
            ;;
        u)
            "$SCRIPTPATH/ugreen_leds_cli" ${map[$i]} -color 255 255 255 -on -brightness 64
            ;;
        o)
            "$SCRIPTPATH/ugreen_leds_cli" ${map[$i]} -color 0 255 0 -on -brightness 64
            ;;
        f)
            "$SCRIPTPATH/ugreen_leds_cli" ${map[$i]} -color 255 0 0 -blink 400 600 -brightness 64
            ;;
        *)
            "$SCRIPTPATH/ugreen_leds_cli" ${map[$i]} -off
            ;;
    esac
done
  • Save the led.sh RIGHT NEXT to the CLI.
    /mnt/SDD/ix-applications/setup/DXP_4800LED/HERE!

  • Give the led.sh also chmod 777. IT DOESN'T MATTER! IT'S JUST ABOUT LEDs!

  • In TrueNAS under System -> Advanced Settings -> Init/Shutdown Scripts, Create the following to load the i2c-dev module on boot:
    Description: Enable i2c-dev
    Type: Command
    Command: modprobe i2c-dev
    When: Pre Init

  • Create a new Cron Job in TrueNAS under System -> Advanced Settings -> Cron Jobs:
    Description: Update Status LEDs on my shitty DXP
    Command:
    bash /ABSOLUTE/PATH/TO/led.sh like
    /mnt/SSD/ix-applications/setup/DXP_4800LED/led.sh
    Run as User: root
    Schedule: Every 5 Minutes
    Hide Standard Output: YES
    Hide Standard Error: NO
    Enabled: YES

Reboot your system after all these steps.

Easy chain: Cronjob calls .sh and .sh calls CLI.
Troubleshoot:

  • Try to run led.sh with sudo manually in shell
  • Triple check the absolute path to your led.sh in cronjob
  • triple check the permissions for cli and led.sh
  • If you have any issues, try to solve it togheter with your favorite AI agent

@daibaron
Copy link

daibaron commented Jan 22, 2026

TY very much, it's greatly appreciated
I have this recurring error with CRON
[EFAULT] CronTask "/mnt/Tank/DXP_4800LED/led.sh > /dev/null" exited with 137 (non-zero) exit status
That seems not related to your script.
Tried to google this with no luck

@S2ciOnur
Copy link

S2ciOnur commented Jan 22, 2026

TY very much, it's greatly appreciated I have this recurring error with CRON [EFAULT] CronTask "/mnt/Tank/DXP_4800LED/led.sh > /dev/null" exited with 137 (non-zero) exit status That seems not related to your script. Tried to google this with no luck

It can be everything error says nothing.
I updated the guide.
Check again.
If it still does not work:

  • could be that you use wrong path,
  • could be you did not give +X (execute) to cli or .sh
  • or cron is not working well.
    dunno can be everything.

Did you also executed step No 6 in the description on the top?
Try to run the .sh with sudo manually.
do your LEDs change color? does it work?
Did you tried reboot your NAS?
Try to troubleshoot togheter with your favorite AI assistant

@daibaron
Copy link

daibaron commented Jan 22, 2026

@S2ciOnur many thanks

It works !

I started from the scratch, followed your step-by-step tutorial which was missing the Init/Shutdown Scripts (my fault)
In shell, I've manually run bash led.sh and fixed permission
CRON Job was still the issue until I've added Command: bash /MyPath/led.sh
I now have 4 solid green LEDs that don't react to any disk activity.

@S2ciOnur
Copy link

@S2ciOnur many thanks

It works !

I started from the scratch, followed your step-by-step tutorial which was missing the Init/Shutdown Scripts (my fault) In shell, I've manually run bash led.sh and fixed permission CRON Job was still the issue until I've added Command: bash /MyPath/led.sh I now have 4 solid green LEDs that don't react to any disk activity.

Ok, nice.
I updated my guide above and hope it will help other people too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment