March 16, 20215 yr I have a USB drive (sdb) mounted with UD: v6.9.1 spins it down correctly but the (substandard) interface returns bad/missing sense data: root@NAS:~# hdparm -y /dev/sdb /dev/sdb: issuing standby command SG_IO: bad/missing sense data, sb[]: f0 00 01 00 50 40 00 0a 80 00 00 00 00 1d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ...which this line in /usr/local/sbin/sdspin catches and records as an error: [[ $RET == 0 && ${OUTPUT,,} =~ "bad/missing sense" ]] && RET=1 So although the drive's spun down unRAID thinks it isn't causing (a) the activity LED to stay green and (b) unRAID to try to spin it down every spindown interval. I've worked around it by modifying the code (below) to exclude USB drives from the test. Is that risky, should I not have? I'm not sure what cases this test is meant to handle. I've also updated the status check for USB drives to use smartctl since (at least with mine) hdparm can't detect standby. #!/bin/bash # spin device up or down or get spinning status # $1 device name # $2 up or down or status # ATA only # hattip to Community Dev @doron RDEVNAME=/dev/${1#'/dev/'} # So that we can be called with either "sdX" or "/dev/sdX" get_device_id () { LABEL="${RDEVNAME:5}" DEVICE_ID=`ls -l /dev/disk/by-id/ | grep -v " wwn-" | grep "${LABEL}$" | rev | cut -d ' ' -f3 | rev` echo "$DEVICE_ID" } smartctl_status () { OUTPUT=$(/usr/sbin/smartctl --nocheck standby -i $RDEVNAME 2>&1) RET=$? # Ignore Bit 1 error (Device open failed) which usually indicates standby [[ $RET == 2 && $(($RET & 2)) == 2 ]] && RET=0 } hdparm () { OUTPUT=$(/usr/sbin/hdparm $1 $RDEVNAME 2>&1) RET=$? # ignore missing sense warning which might be caused by a substandard USB interface if [[ ! "$(get_device_id)" =~ ^usb-.* ]]; then [[ $RET == 0 && ${OUTPUT,,} =~ "bad/missing sense" ]] && RET=1 fi } if [[ "$2" == "up" ]]; then hdparm "-S0" elif [[ "$2" == "down" ]]; then hdparm "-y" else # use smartctl (instead of hdparm) for USB drives if [[ "$(get_device_id)" =~ ^usb-.* ]]; then smartctl_status else hdparm "-C" fi [[ $RET == 0 && ${OUTPUT,,} =~ "standby" ]] && RET=2 fi exit $RET Edited April 16, 20215 yr by CS01-HS
April 16, 20215 yr Author I've improved the script including the use of smartctl to check USB drive status (which unlike hdparm works reliably with substandard USB interfaces my drive's substandard USB interface.) Edited April 16, 20215 yr by CS01-HS
April 16, 20215 yr Community Expert On 4/16/2021 at 5:53 PM, CS01-HS said: I've improved the script including the use of smartctl to check USB drive status (which unlike hdparm works reliably with substandard USB interfaces.) It will error for USB drives not in the drive.h. Your drive is fine as its in the db. But if others use they should test first. Its simple to get devices added but a request needs to be submitted to the smartmontools team. There is a process to update drive.h but I dont think its in unraid will need to check. Edited April 17, 20215 yr by SimonF
April 17, 20215 yr To update drivedb.h you can add something like this to your go script: wget https://raw.githubusercontent.com/smartmontools/smartmontools/master/smartmontools/drivedb.h -O /usr/share/smartmontools/drivedb.h This will install the latest smartmontools drive database. Whether it will cover a given drive is a different question 🙂
April 17, 20215 yr Community Expert 15 minutes ago, doron said: To update drivedb.h you can add something like this to your go script: wget https://raw.githubusercontent.com/smartmontools/smartmontools/master/smartmontools/drivedb.h -O /usr/share/smartmontools/drivedb.h This will install the latest smartmontools drive database. Whether it will cover a given drive is a different question 🙂 There is a script /usr/sbin/update-smart-drivedb but have not checked unraid vers works.
April 17, 20215 yr 17 minutes ago, SimonF said: There is a script /usr/sbin/update-smart-drivedb but have not checked unraid vers works. It kind-of works (if you use with --no-verify, since gpg isn't available) but it will downgrade your db to 7.0 rather than upgrade to the latest... I guess it can be tweaked to do the right thing. Or, you can use the above.
Archived
This topic is now archived and is closed to further replies.