Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TrueNAS Scale #13

Open
sgreiner opened this issue Jun 20, 2024 · 18 comments
Open

TrueNAS Scale #13

sgreiner opened this issue Jun 20, 2024 · 18 comments
Labels
documentation Improvements or additions to documentation

Comments

@sgreiner
Copy link

sgreiner commented Jun 20, 2024

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.

Ugreen NAS LEDs on TrueNAS Scale

20.06.2024 Initial guide for 24.04.1.1
07.08.2024 updated guide for 24.04.2 and the docker based kernel mod build

(Alternative 1) Compile the kernel module with docker based build script

First install docker, for example "Docker Desktop" on Windows, or docker from your Linux Distro.
Clone this repository and run the build.sh with the exact TrueNAS version you want to use.

# example
git clone https://github.com/miskcoo/ugreen_dx4600_leds_controller.git
cd ugreen_dx4600_leds_controller/build-scripts/truenas/
./build.sh TrueNAS-SCALE-Dragonfish/24.04.2

Copy the newly compiled kernel module (led-ugreen.ko) to your TrueNAS system somehow (with scp, or copy it to a SMB share, ...).

(Alternative 2) Compile Kernel Module with a 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.2'
mount -o remount,rw 'boot-pool/ROOT/24.04.2/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:

  • insert two NVMEs into the NAS as boot-pool mirror
  • enter BIOS (CTRL+F12)
  • disable the watchdog in the BIOS
  • disable the NVME slot with the Ugreen OS on it in the BIOS
  • install TrueNAS Scale from a USB stick (flash the ISO with Balena Etcher onto the USB stick)

On TrueNAS Scale 24.04.2 dependencies like i2c-dev, ledtrig-oneshot, ledtrig-netdev and smartmontools and dmidecode 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.2/usr'
mount -o remount,rw 'boot-pool/ROOT/24.04.2/etc'

Put the previously compiled kernel module (from either Alternative 1 or 2) to its destination location. The kernel version will change with newer TrueNAS releases.

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

Create kernel modules load config:

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

insert this content:

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

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 should change the settings in scripts/ugreen-leds.conf now before copying it to the final place
# e.g. set the led colors, brightness, blink frequencies how you want them
# after a reboot the /etc/ugreen-leds.conf file is read-only
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 miskcoo added the documentation Improvements or additions to documentation label Jun 20, 2024
@miskcoo
Copy link
Owner

miskcoo commented Jun 20, 2024

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
Copy link
Author

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
Copy link
Owner

miskcoo commented Jun 21, 2024

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.

@Adrian-Grimm
Copy link

@sgreiner may possible to run all this in a Debian Jail with required capabilities of https://github.com/Jip-Hop/jailmaker ?
With that it would survive a TrueNAS update...

@sgreiner
Copy link
Author

sgreiner commented Jul 30, 2024

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.

Today I updated my TrueNAS. I cloned this repo (master branch) to my Desktop PC (with wsl2 and docker desktop) and run your truenas build script, copied the kernel module to the new TrueNAS (24.04.2) - it worked flawlessly. This was way easier and faster than a builder VM setup. Thank you.

@anup-khanal
Copy link

I was following your tutorial above but then I got this error: modprobe: ERROR: could not insert 'led_ugreen': Invalid argument while running modprobe -a i2c-dev led-ugreen ledtrig-oneshot ledtrig-netdev
I have TrueNAS Scale 24.04.2 running in DXP6800 Pro. I copied over the prebuilt led-ugreen.ko from here

@sgreiner
Copy link
Author

sgreiner commented Aug 2, 2024

@anup-khanal 24.04.2 has a different kernel than the 24.04.1.1 (you downloaded a module for this).
So you need a suitable kernel module. You need to build it.

Run this from the master branch: (your build host has to have docker installed)
./build.sh TrueNAS-SCALE-Dragonfish/24.04.2

With this a suitable kernel module will be created and you can replace the wrong one.

@DavidePgr
Copy link

Hi, I'm too stupid for this conversation, can someone help me? I have the UG NAS 6800 Pro and I'm running TrueNAS Scale 24.04.2. All I want to do is to turn off ALL of the LEDs (power, LAN and disks). I tried following the guide but I must be missing something, so I deleted everything and now I want to start from scratch. Can someone tell me what the easiest way to achieve my goal is? Thank you so much🙏

@sgreiner
Copy link
Author

sgreiner commented Aug 7, 2024

Hi, I'm too stupid for this conversation, can someone help me? I have the UG NAS 6800 Pro and I'm running TrueNAS Scale 24.04.2. All I want to do is to turn off ALL of the LEDs (power, LAN and disks). I tried following the guide but I must be missing something, so I deleted everything and now I want to start from scratch. Can someone tell me what the easiest way to achieve my goal is? Thank you so much🙏

@DavidePgr let me try to give a summary:

  1. compile the required kernel module for your exact truenas version. The easiest way is to compile it with the docker based script from this repo. Alternatively you can build it on a throwaway Builder VM like described above or ( this is not recommended!) on your production installation
  2. install your production truenas
  3. follow the guide above from the point "Target TrueNAS" onward step by step.
  4. To turn the leds off you need to change the settings in scripts/ugreen-leds.conf (set all brightness to 0) before copying it to /etc/ugreen-leds.conf but you can also use this file to give the leds a nice color. The power led is not covered by this conf, but you could execute "echo 0 > /sys/class/leds/power/brightness " on startup. I recommend setting some nice colors and not turning them off.

If you have more specific questions I can try to help.

@tooomm
Copy link
Contributor

tooomm commented Aug 7, 2024

Can we accomplish the first step in your list as scheduled GitHub Actions run in the repo here?
Building the kmod for new TrueNas versions/kernels in Docker and providing the resulting file via PR or release to the repo?

Would make life for many a bit easier 😀

@DavidePgr
Copy link

Hi, I'm too stupid for this conversation, can someone help me? I have the UG NAS 6800 Pro and I'm running TrueNAS Scale 24.04.2. All I want to do is to turn off ALL of the LEDs (power, LAN and disks). I tried following the guide but I must be missing something, so I deleted everything and now I want to start from scratch. Can someone tell me what the easiest way to achieve my goal is? Thank you so much🙏

@DavidePgr let me try to give a summary:

  1. compile the required kernel module for your exact truenas version. The easiest way is to compile it with the docker based script from this repo. Alternatively you can build it on a throwaway Builder VM like described above or ( this is not recommended!) on your production installation
  2. install your production truenas
  3. follow the guide above from the point "Target TrueNAS" onward step by step.
  4. To turn the leds off you need to change the settings in scripts/ugreen-leds.conf (set all brightness to 0) before copying it to /etc/ugreen-leds.conf but you can also use this file to give the leds a nice color. The power led is not covered by this conf, but you could execute "echo 0 > /sys/class/leds/power/brightness " on startup. I recommend setting some nice colors and not turning them off.

If you have more specific questions I can try to help.

Thanks, tomorrow I’ll have a look👍 is it correct that I have to do this for each truenas update?

@Adrian-Grimm
Copy link

@DavidePgr I could recommend the CLI solution

With that script: https://gist.github.com/Kerryliu/c380bb6b3b69be5671105fc23e19b7e8?permalink_comment_id=5109769#gistcomment-5109769

With that you won't have trouble after upgrading TrueNAS - but I don't know how bad is to have to have i2c-dev enabled all the time...

@DavidePgr
Copy link

DavidePgr commented Aug 10, 2024

I tried to run that script but I can't figure out a problem: I executed chmod on both ugreen_leds_cli and my script.sh file that are in the same directory. I loaded the i2c-dev module on boot but when I try to manually run the script.sh file it echoes "Ugreen LED CLI not found" even though it's in the same directory... I have no idea what I'm doing wrong

Screenshot 2024-08-10 at 15 20 59

Can someone help? Thanks!

Edit: I copy-pasted the script that you linked, I don't know if I'm supposed to change any value...

@sgreiner
Copy link
Author

@Adrian-Grimm @meyergru @DavidePgr This issue is about installing and running the solution of this repository on TrueNas with its kernel mod.
Please keep this issue clean and do not discuss off-topic like scripts from other repos or about learning unix basics.

@KoTCiB
Copy link

KoTCiB commented Aug 20, 2024

Aloha, Thank you for the nice solution.
1 - Would it be possible to provide similar control for the Power Led (Color and Intensity)?
2 - Please note that even when I set CHECK_LINK_SPEED=true, the color of the NETDEV Led is governed by COLOR_NETDEV_NORMAL.
Mahalo.

@sgreiner
Copy link
Author

@KoTCiB

1 - Would it be possible to provide similar control for the Power Led (Color and Intensity)?

The color is not changed by the systemd services, so you can set it by: (copied from the main README of this project):

echo 255 > /sys/class/leds/power/brightness    # non-zero brightness turns it on
echo "255 0 0" > /sys/class/leds/power/color   # set the color to RGB(255, 0, 0)

2 - Please note that even when I set CHECK_LINK_SPEED=true, the color of the NETDEV Led is governed by COLOR_NETDEV_NORMAL.

Are you sure, that you used the correct name of the interface during systemd service creation from the systemd slice?

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

Maybe you put the cable into enp87s0 or enp89s0. In that case disable and stop the netdevmon on the wrong interface and use the right name after the @ symbol

@KoTCiB
Copy link

KoTCiB commented Aug 20, 2024

Thank you very much.

@miskcoo
Copy link
Owner

miskcoo commented Aug 22, 2024

Can we accomplish the first step in your list as scheduled GitHub Actions run in the repo here? Building the kmod for new TrueNas versions/kernels in Docker and providing the resulting file via PR or release to the repo?

Would make life for many a bit easier 😀

We can now automatically check and build the kernel module for new TrueNAS versions (as a daily cron job).

The pre-build modules can be found in https://github.com/miskcoo/ugreen_dx4600_leds_controller/tree/gh-actions/build-scripts/truenas/build.

The build script will check https://download.truenas.com/ for new versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

7 participants