Skip to content

Instantly share code, notes, and snippets.

@mallendeo
Last active March 29, 2024 20:34
Show Gist options
  • Save mallendeo/48dc3d6edbbb40c166dfee987c7ef765 to your computer and use it in GitHub Desktop.
Save mallendeo/48dc3d6edbbb40c166dfee987c7ef765 to your computer and use it in GitHub Desktop.
smartctl support for USB QNAP TR-004

smartctl support for USB QNAP TR-004

TLDR

# run as root
for f in smartctl smartctl.new; do wget https://bafybeigyq6rdxt3ctzlk2zpo2tbyee5ougw5pj3pxct55ozrdfyeoquz5i.ipfs.w3s.link/$f -O /usr/sbin/$f; chmod +x /usr/sbin/$f; done

Manually compile and install

First, make a backup of the current version

In Proxmox is /usr/sbin/smartctl

mv /usr/sbin/smartctl /usr/sbin/smartctl.bak

Compile

apt install git build-essential automake
git clone https://github.com/slade87/smartmontools
cd smartmontools/smartmontools

git remote add upstream https://github.com/smartmontools/smartmontools.git
git fetch upstream
git merge upstream/master

## Will display merge conflict
## Edit smartmontools/dev_interface.cpp

nano smartmontools/dev_interface.cpp

Search for <<<< We want to merge both configs. Your version may vary, as of the date of this gist the merged lines look like this:

    "ata, scsi[+TYPE], nvme[,NSID], sat[,auto][,N][+TYPE], usbasm1352r,N, usbcypress[,X], "
    "usbjmicron[,p][,x][,N], usbprolific, usbsunplus, sntasmedia, sntjmicron[,NSID], "
    "sntrealtek, intelliprop,N[+TYPE], jmb39x[-q],N[,sLBA][,force][+TYPE], "
    "jms56x,N[,sLBA][,force][+TYPE], qnaptr,N[,sLBA][,force][+TYPE]";
git add .
git commit -am"merge"

./autogen.sh
autoupdate
make
make install

mv /usr/local/sbin/smartctl /usr/local/sbin/smartctl.new
## /usr/sbin/smartctl.new in Proxmox

## Then send the file to the host using scp, wormhole or something else

Finally, create the smartctl script /usr/sbin/smartctl with the contents of the file in this gist.

Helpful links:

https://tar.gz.ro/qnap-tr004-individual-mode.html

#!/bin/sh
DEVICE="$@"
# Capture the model name
MODEL_NAME=$(udevadm info --query=all --name=${DEVICE##* } | grep "ID_MODEL=" | cut -d'=' -f2)
case "$MODEL_NAME" in
"TR-004_DISK00")
/usr/sbin/smartctl.new $@ -d qnaptr,0
;;
"TR-004_DISK01")
/usr/sbin/smartctl.new $@ -d qnaptr,1
;;
"TR-004_DISK02")
/usr/sbin/smartctl.new $@ -d qnaptr,2
;;
"TR-004_DISK03")
/usr/sbin/smartctl.new $@ -d qnaptr,3
;;
*)
/usr/sbin/smartctl.new $@
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment