miskcoo / ugreen_dx4600_leds_controller

An LED controller of UGREEN DX4600 Pro NAS, compatible with UGREEN DXP4800/6800/8800 series.
108 stars 16 forks source link

TrueNAS Scale #13

Open sgreiner opened 1 week ago

sgreiner commented 1 week ago

The following instructions are a memory log from my successful attempt today to get the LEDs of the Ugreen NASync DXP6800 Pro running poperly on TrueNAS Scale.

I hope I haven't forgotten anything, otherwise I'll add to it when I reinstall it (probably next weekend). Big thanks to @miskcoo for your work on this repository!

I thought someone might find this useful, so I add this as issue here, hope thats ok. There is also room for improvement to add zpool status related output to the leds (e.g. make them red if a pool is degraded etc).

Ugreen NAS LEDs on TrueNAS Scale

20.06.2024

Builder VM

Install TrueNAS Scale on a VM. These steps could be done on the target NAS, but we don't want to clutter the appliance more than necessary.

You might need to adjust the version numbers below in the future.

Execute as root (sudo su -) on a fresh TrueNAS VM with the exact same version as your target TrueNAS Scale.

export PATH=/usr/bin:/usr/sbin

mount -o remount,rw 'boot-pool/ROOT/24.04.1.1'
mount -o remount,rw 'boot-pool/ROOT/24.04.1.1/usr'

chmod +x /bin/apt*
chmod +x /usr/bin/dpkg

apt update

apt install build-essential linux-headers-generic

cd /root
git clone https://github.com/miskcoo/ugreen_dx4600_leds_controller.git

cd /root/ugreen_dx4600_leds_controller/cli && make
cd /root/ugreen_dx4600_leds_controller/kmod && make

copy these two files to your target TrueNAS somehow:

# example
scp /root/ugreen_dx4600_leds_controller/cli/ugreen_leds_cli root@target:/root
scp /root/ugreen_dx4600_leds_controller/kmod/led-ugreen.ko root@target:/root

Target TrueNAS (e.g. on a Ugreen NASync DXP6800 Pro)

install TrueNAS Scale:

On TrueNAS Scale 24.04.1.1 dependencies like i2c-dev, ledtrig-oneshot, ledtrig-netdev and smartmontools are available.

execute as root on your target TrueNAS:

cd /root
git clone https://github.com/miskcoo/ugreen_dx4600_leds_controller.git

# until next reboot we need write access
mount -o remount,rw 'boot-pool/ROOT/24.04.1.1/usr'
mount -o remount,rw 'boot-pool/ROOT/24.04.1.1/etc'

Create kernel modules load config:

vim /etc/modules-load.d/ugreen-led.conf

content:

i2c-dev
led-ugreen
ledtrig-oneshot
ledtrig-netdev

Put previously compiled kernel module in place (kernel version might change)

cp led-ugreen.ko /lib/modules/6.6.29-production+truenas/extra
chmod 644 /lib/modules/6.6.29-production+truenas/extra/led-ugreen.ko

Run depmod and modprobe:

depmod
modprobe -a i2c-dev led-ugreen ledtrig-oneshot ledtrig-netdev

systemd setup for leds

cd /root/ugreen_dx4600_leds_controller/

copy config and systemd units and scripts


# you may change settings here
cp scripts/ugreen-leds.conf /etc/ugreen-leds.conf

scripts=(ugreen-diskiomon ugreen-netdevmon ugreen-probe-leds)
for f in ${scripts[@]}; do
    chmod +x "scripts/$f"
    cp "scripts/$f" /usr/bin
done

cp scripts/*.service /etc/systemd/system/

systemctl daemon-reload

systemctl start ugreen-diskiomon.service
systemctl enable ugreen-diskiomon.service

# change name of NIC if needed
systemctl start ugreen-netdevmon@enp88s0
systemctl enable ugreen-netdevmon@enp88s0

Reboot and verify.

After a TrueNAS Scale Update you need to repeat all steps, as the boot-pool datasets are versioned and our changes will be gone in a new boot-pool dataset.

miskcoo commented 1 week ago

The instruction looks good, and don't forget to install dmidecode (especially for 6800 Pro). It will be used in the script to detect the device type and to choose the correct htcl mapping.

For ZFS, I am also using it. I am curious about how the zpool is configured on TrueNAS. Could zpool status -L | egrep "^\s*(sd|dm)" give the correct devices? Would you like to test the script here by manually running CHECK_ZPOOL=true ./ugreen-diskiomon? It will check the zpool's status every 5s, and if it successfully builds the mapping from zpool device to LEDs you will see outputs like:

zpool device dm-9 >> sda >> LED:disk1
zpool device dm-10 >> sdd >> LED:disk3
zpool device dm-8 >> sdb >> LED:disk4
zpool device dm-7 >> sdc >> LED:disk2
sgreiner commented 1 week ago

The instruction looks good, and don't forget to install dmidecode (especially for 6800 Pro). It will be used in the script to detect the device type and to choose the correct htcl mapping.

dmidecode is also available per default (version 3.4)

I will check the zpool stuff on the ata-disk-mapping branch

miskcoo commented 1 week ago

Not sure if this will work.

Maybe we can skip installing a VM by building the kmod in a Debian docker with the headers from truenas? I can build such a module using the scripts in the truenas-build branch.