Skip to content

Instantly share code, notes, and snippets.

@johndavisnz
Last active July 5, 2024 23:10
Show Gist options
  • Save johndavisnz/bae122274fc6f0e006fdf0bc92fe6237 to your computer and use it in GitHub Desktop.
Save johndavisnz/bae122274fc6f0e006fdf0bc92fe6237 to your computer and use it in GitHub Desktop.
Installing Debian on the Nimbustor4/2 ( as5304t/as5202t )

Whilst Asustor's ADM suits most people, it is possible to install ANY intel operating system on the nimbustor4/2 (as5202t/as5304t) as they run fairly generic intel hardware (asmedia sata controller, rtl8125 2.5gbe nic and ite system management chip)

in this gist I'll detail the steps needed to install and configure Debian11

Before proceeding you need to decide where you're going to install Debian.

Most people will choose to install it to a usb3 attached drive - either a usb3 ssd ( samsung t5 or similar ) or a usb3 hdd. This gives the most straightforward install ( just tell Debian to use the entire usb3 drive to install to ) and maximises available space on the NAS HDDs

The other option is to install Debian direct to the NAS hard drives - that means no extra drive hanging off the nas, and you can raid1 mirror the system partition across all drives for added resiliency ( though this is somewhat limited as the EFI boot partition is only on sda - so in the case of sda failing you'd need to boot off install media and rebuild the EFI partition). Downside is a more complex setup procedure and you'll need to go thru manual partitioning as opposed to guided (you'll also need a working knowledge of how to setup md raid1 in the partitioner)

NOTE - do NOT try and use a basic usb pendrive to install the system to - they have neither the write speed nor the write durability needed

Similarly do NOT try and install to the eMMC built into the unit - it's only 8gb ( which is too small for anything but the most minimal install ), and like pendrives, eMMC lacks write durability and write speed. Most importantly if you over-write the eMMC you will be unable to revert to ADM ( the eMMc has a minimal boot image on it which is used to recover the system - and there is no tool to restore it if wiped )

For this guide I'll detail the external system drive method

step 1 - change BIOS settings https://gist.github.com/johndavisnz/3b47df6a255b718b3e910e6331656cf6

step 2 - install Debian https://gist.github.com/johndavisnz/0d721c0b97615a5720660024f4a5f158

step 3 - install custom kmod for fan control and setup lm_sensors https://gist.github.com/johndavisnz/b5aae0236141666a77aac094701d7839

step 4 - install custom fan control script https://gist.github.com/johndavisnz/06a5e1aabaf878add0ad95669b3a0b3d

step 5 - install rtl8125 and i915 firmware, install OMV6 and Plex https://gist.github.com/johndavisnz/d4d8cf1304ebade08f924411d2c83327

@OrcD3vil
Copy link

@johndavisnz

I was wondering if you could help me with this, I'm sorry this is above my knowledge base as I do not have the knowledge to script. I can understand the basics and read some and fairly new to Linux. I have taken the output from my ASUSTOR AS6604T running FreeNAS and copied your outputs would you be so kind as to help me? If you would like to contact me, I'm more than happy to let me know.

Here is the output of 'sensors' on the AS6604T

coretemp-isa-0000
Adapter: ISA adapter
Package id 0: +37.0°C (high = +105.0°C, crit = +105.0°C)
Core 0: +36.0°C (high = +105.0°C, crit = +105.0°C)
Core 1: +36.0°C (high = +105.0°C, crit = +105.0°C)
Core 2: +35.0°C (high = +105.0°C, crit = +105.0°C)
Core 3: +35.0°C (high = +105.0°C, crit = +105.0°C)

acpitz-acpi-0
Adapter: ACPI interface
temp1: +36.0°C (crit = +95.0°C)

it8625-isa-0290
Adapter: ISA adapter
in0: 1.18 V (min = +1.65 V, max = +1.74 V) ALARM
in1: 1.19 V (min = +0.51 V, max = +1.95 V)
in2: 2.04 V (min = +1.18 V, max = +0.71 V) ALARM
in3: 2.02 V (min = +0.85 V, max = +0.35 V) ALARM
in4: 1.89 V (min = +1.94 V, max = +0.49 V) ALARM
in5: 1.80 V (min = +2.08 V, max = +1.35 V) ALARM
in6: 1.69 V (min = +0.02 V, max = +1.42 V) ALARM
3VSB: 3.32 V (min = +5.08 V, max = +0.29 V) ALARM
Vbat: 3.08 V
+3.3V: 3.23 V
fan1: 2163 RPM (min = 1433 RPM)
fan2: 0 RPM (min = 106 RPM) ALARM
fan3: 0 RPM (min = 17 RPM) ALARM
temp1: -128.0°C (low = -105.0°C, high = +64.0°C)
temp2: -128.0°C (low = +76.0°C, high = -68.0°C) sensor = thermal diode
temp3: -128.0°C (low = -35.0°C, high = +23.0°C)
intrusion0: ALARM

nvme-pci-0800
Adapter: PCI adapter
Composite: +26.9°C (low = -5.2°C, high = +79.8°C)
(crit = +84.8°C)

Checking the mapping of hwmon directory

root@truenas[/sys/class/hwmon]# ls -ltr
total 0
lrwxrwxrwx 1 root root 0 Aug 29 13:24 hwmon3 -> ../../devices/platform/it87.656/hwmon/hwmon3
lrwxrwxrwx 1 root root 0 Aug 29 13:24 hwmon2 -> ../../devices/platform/coretemp.0/hwmon/hwmon2
lrwxrwxrwx 1 root root 0 Aug 29 13:24 hwmon1 -> ../../devices/pci0000:00/0000:00:13.3/0000:08:00.0/hwmon/hwmon1
lrwxrwxrwx 1 root root 0 Aug 29 13:24 hwmon0 -> ../../devices/virtual/thermal/thermal_zone0/hwmon0
root@truenas[/sys/class/hwmon]#

hddtemp of the hard drives

root@truenas[/sys/class/hwmon]# hddtemp /dev/sda /dev/sdb /dev/sdc /dev/sdd
/dev/sda: ST10000VN0008-2JJ101: 31°C
/dev/sdb: ST10000VN0008-2JJ101: 29°C
/dev/sdc: ST10000VN0008-2JJ101: 31°C
/dev/sdd: ST10000VN0008-2JJ101: 30°C
root@truenas[/sys/class/hwmon]#

@johndavisnz
Copy link
Author

as I suspected the mapping inside /sys/class/hwmon is the biggest issue - the nvme thermal sensor is bumping the numbering so what is hwmon1 ( coretemp ) on the as5202t is hwmon2 on the 6604t and similarly the it87 sensors ( not used for temperatures reading but used to read/set fan speed ) goes from hwmon2 to hwmon3

I've attached a link to a test version that should work for the 6604t ( quick/dirty change to the logic to handle 4 cores and 4 drives, and have modified the hwmon related references to match the numbering on the as6604t )

Let me know if it works for you and if so I'll modify the release version to abstract those references to variables and to query the number of cores and work out the numbering of /sys/class/hwmon on startup ( which should make it a LOT more portable )

[beta temp control script for as6604t]https://gist.github.com/johndavisnz/6f21205fa77414bfccd8a44b43c72afb

@Smart123s
Copy link

Fan controls and everything works perfectly on my AS6602T. Thanks for this detailed tutorial. It saved me from weeks of debugging.

@johndavisnz
Copy link
Author

johndavisnz commented Mar 19, 2023 via email

@Smart123s
Copy link

The package is available on my Turenas Scale install

root@truenas[/home/admin]# apt install hddtemp 
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
hddtemp is already the newest version (0.3-beta15-54).

@johndavisnz
Copy link
Author

johndavisnz commented Mar 19, 2023 via email

@Smart123s
Copy link

Fan controls worked for me after reboots and I e only followed your guidance. (Adding it to /etc/modules)

I've also found this project: https://github.com/mafredri/asustor-platform-driver/tree/it87

I was hoping that it would get the LEDs to work properly but it didn't.

It's kinda late, but next week I want to check out the adm kernel source to see if there's anything useful in there. Although I'm pretty sure someone would have already published it here.

@UhuGeschwader
Copy link

Got it working on a new 5402T with OMV 6 installed. The script currently doesn't load on start-up, but after manually executing, the fan finally went to a nice silent state. Big thank you for your work.
Maybe you could add a hint to download the Linux-header file, else the make will abort with a "[/lib/modules//build/ not existent]". Yes, this could be solved with 5 minutes of research, but a small note is always appreciated.

@LPJon
Copy link

LPJon commented Dec 31, 2023

@johndavisnz Is there any chance you figured out how to get the LCD Display functional. I have also moved to TrueNAS Scale 22.10.1 but my Asustor is a AS6706T. I have everything else working except the LCD (Which at this point I can only turn on or off). I would love to get some simple data on the display like an IP address and maybe the hostname of the box.

@hlugt
Copy link

hlugt commented Jan 1, 2024

@johndavisnz Is there any chance you figured out how to get the LCD Display functional. I have also moved to TrueNAS Scale 22.10.1 but my Asustor is a AS6706T. I have everything else working except the LCD (Which at this point I can only turn on or off). I would love to get some simple data on the display like an IP address and maybe the hostname of the box.

You can have a look at: https://github.com/mafredri/lcm. Hostname and ip is done. Needs golang installed though.

@Aractor
Copy link

Aractor commented Jul 5, 2024

@johndavisnz Trying to get this working under TrueNAS Scale Dragonfish-24.04.1.1 on an AS6706T and not having any luck.

I've gone through the instructions provided, and while sensors is showing my fan, it's running at a lowly ~490 RPM. Despite all the instructions above, I cannot seem to get it to spin up any faster.

it8625-isa-0a30
Adapter: ISA adapter
fan1:         491 RPM  (min =   12 RPM)

When I try to run the original temp_monitor.sh script I get an error for hddtemp missing, which appears to no longer be in the Debian apt repo. https://tracker.debian.org/pkg/hddtemp

root@whnas2[/home/admin]# ./temp_monitor.sh 
./temp_monitor.sh: line 117: hddtemp: command not found
./temp_monitor.sh: line 99: echo: write error: Invalid argument
./temp_monitor.sh: line 117: hddtemp: command not found

If I try to run the other version of the script (temp_monitor6604t.sh I get similar errors.

root@whnas2[/home/admin]# ./temp_monitor6604t.sh 
./temp_monitor6604t.sh: line 109: hddtemp: command not found
./temp_monitor6604t.sh: line 91: echo: write error: Invalid argument

Any advice or recommendations would be greatly appreciated, thank you!

@hlugt
Copy link

hlugt commented Jul 5, 2024

FWIW I used the shell script by https://github.com/bernmc/flashstor-trueNAS-fancontrol/tree/main, and have only made minor adjustments as I recall.

@johndavisnz
Copy link
Author

johndavisnz commented Jul 5, 2024

if you're seeing 'hddtemp : command not found' it means you're you haven't enabled apt and installed the hddtemp package ( truenas ships with a very limited number of packages pre-installed and apt disabled ) - the hddtemp package is required to get the drive temperatures

@johndavisnz
Copy link
Author

and be aware than BernMC's version is explicitly for NVME ( for his flashstor unit ) - so uses a totally different function to query the drive temps via /sys/ ( since nvme m.2 are pci devices ), it won't read the temperatures on sata hdds at all

@johndavisnz
Copy link
Author

johndavisnz commented Jul 5, 2024

I did a limited amount of testing of TrueNAS on the as5202t in 2023 and had a version of the fan control script using smartctl to query the drive temps ( removing the hddtemp dependency ) - I'll re-install current TrueNAS on it and check if it still works on the current release

@johndavisnz
Copy link
Author

if you replace the get_hdd_temp() function with this it will read the drive temps using smartctl ( installed as standard as part of TrueNAS ) - meaning you do not need to enable apt and install the hddtemp package :

[ note this presumes you've got up to 8 hdds - however depending on how you've got truenas installed you may need to exclude some - I had an external m.2 sata drive at one stage as the boot device, and it of course was much warmer than the hdds and was forcing higher than needed fan speeds ]

# query all drive temperatures and set the global hdd_temp to the highest
function get_hdd_temp() {

    hdd_temp=0

# presume we have up to 8 drives - find the highest temperature on them
# 
# if you have an external HDD / m.2 sata ssd as the boot device you'll need to exclude it from the drive list so as to ignore it's temperature

    for i in /dev/sda /dev/sdb /dev/sdc /dev/sdd /dev/sde /dev/sdf /dev/sdg /dev/sdh
    do
        # SMART attribute 194 is drive temperature
        temp=`smartctl -a $i | grep 194 | awk '{ print $10 }'`
        if [ -z $temp ]; then
           if [ $debug -gt 1 ]; then
              echo "temp is NULL - drive does not exist"
           fi
        else
           if [ $debug -gt 1 ]; then
              echo "drive=" $i " temp=" $temp
           fi
           if [ $temp -gt $hdd_temp ]; then
              hdd_temp=$temp
              if [ $debug -gt 1 ]; then
                 echo "setting hdd_temp"
              fi
           fi
        fi
     done

    if [ $debug -gt 1 ]; then
       echo "GET_HDD_TEMP: hdd_temp= " $hdd_temp
    fi

}

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