Checking for TLER, ERC, etc. support on a drive

xterminated

Dabbler
Joined
Dec 26, 2015
Messages
12
Thanks.
The script does it like this (with full path):

Code:
#!/usr/local/bin/python2.7

import os
import sys
import subprocess
from pprint import pprint
from disks import get_disks

if len(sys.argv) < 3:
    raise SystemExit('Usage: %s READ_SECS WRITE_SECS' % sys.argv[0])

read_secs, write_secs = (float(val) for val in sys.argv[1:3])

def set_scterc(disk, read_sec, write_sec):
    try:
        print subprocess.check_output(['/usr/local/sbin/smartctl',
                                       '-l',
                                       'scterc,%d,%d' % (read_sec*10, write_sec*10),
                                       '/dev/%s' % disk])
    except Exception as ex:
        print 'Failed to set TLER on /dev/%s' % disk

disks = get_disks()

for disk in sorted(disks.keys()):
    print '%s (%s):' % (disk, disks[disk])
    set_scterc(disk, read_secs, write_secs)
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
Thanks.
The script does it like this (with full path):

Code:
#!/usr/local/bin/python2.7

import os
import sys
import subprocess
from pprint import pprint
from disks import get_disks

if len(sys.argv) < 3:
    raise SystemExit('Usage: %s READ_SECS WRITE_SECS' % sys.argv[0])

read_secs, write_secs = (float(val) for val in sys.argv[1:3])

def set_scterc(disk, read_sec, write_sec):
    try:
        print subprocess.check_output(['/usr/local/sbin/smartctl',
                                       '-l',
                                       'scterc,%d,%d' % (read_sec*10, write_sec*10),
                                       '/dev/%s' % disk])
    except Exception as ex:
        print 'Failed to set TLER on /dev/%s' % disk

disks = get_disks()

for disk in sorted(disks.keys()):
    print '%s (%s):' % (disk, disks[disk])
    set_scterc(disk, read_secs, write_secs)
Ummm... okay. Next thing to check: who is the owner and how are the permissions set on the script?
 

xterminated

Dabbler
Joined
Dec 26, 2015
Messages
12
Here the permissions:
-rwxrwxr-x+ 1 root wheel 808 Jan 23 11:48 /mnt/myvault/usr/scripts/set_tler.py

I use this Freenas Version
FreeNAS-11.2-RELEASE-U1 (Build Date: Dec 20, 2018 22:41)

And here how I'd like to start it
freenas_settlrscript_start.png
 
Last edited:

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
Here the permissions:
-rwxrwxr-x+ 1 root wheel 808 Jan 23 11:48 /mnt/myvault/usr/scripts/set_tler.py

I use this Freenas Version
FreeNAS-11.2-RELEASE-U1 (Build Date: Dec 20, 2018 22:41)

And here how I'd like to start it
Try running it as a script instead of as a command. I run my startup script as a script, and it calls my 'set TLER' script, among other things.
 

Mr. Slumber

Contributor
Joined
Mar 10, 2019
Messages
182
Try running it as a script instead of as a command. I run my startup script as a script, and it calls my 'set TLER' script, among other things.

Thank you @Spearfoot for your script and help! :)

It was working perfectly for me but now I have a question:

I created a dataset called "sysadmin" on my pool, copied the script into it and started the script as a script and "postinit". Worked perfectly.
But now I encrypted this pool and set a passphrase so after bootin up I have to manually unlock the pool.
Please correct me if I'm wrong but now the script can not start because it is located on an encrypted pool/dataset and the pool/dataset is unlocked manually by me after the boot process is finished, right?

So how can I get this script to run if it is located on an encrypted pool? Or would it be better to copy it some place else?

Thanks in advance. :cool:
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
Thank you @Spearfoot for your script and help! :)

It was working perfectly for me but now I have a question:

I created a dataset called "sysadmin" on my pool, copied the script into it and started the script as a script and "postinit". Worked perfectly.
But now I encrypted this pool and set a passphrase so after bootin up I have to manually unlock the pool.
Please correct me if I'm wrong but now the script can not start because it is located on an encrypted pool/dataset and the pool/dataset is unlocked manually by me after the boot process is finished, right?

So how can I get this script to run if it is located on an encrypted pool? Or would it be better to copy it some place else?

Thanks in advance. :cool:
Sorry, I've never used encrypted volumes, so I don't know how they work. :(

Perhaps someone experienced with using them can answer your question.
 

Chris Moore

Hall of Famer
Joined
May 2, 2015
Messages
10,080
Please correct me if I'm wrong but now the script can not start because it is located on an encrypted pool/dataset and the pool/dataset is unlocked manually by me after the boot process is finished, right?
Right. The order in which things happen. Your encrypted pool doesn't get unlocked until after the script attempts, and fails, to run. The only solution to that is having your scripts in a place that is not encrypted. I keep my scripts in a scripts directory that is at: /root/scripts
That way it is almost always available and I have a cron job that makes a copy of my scripts folder to a location in the pool on a weekly basis as a backup.
 

SMnasMAN

Contributor
Joined
Dec 2, 2018
Messages
177
It looks like the github links on the 1st page are no longer any good/valid (404)-
does anyone see any problems with this quick script i wrote?
(i would add it as a preinit and put it in /data/xyz.sh) - i have about 60x disks some do need TLER re-enabled after a reboot. (i do 1 to 100 to account for any future disks i may add, also all my disks are via LSI 9207 cards + expanders, so they are always /dev/daX , not adaX )

thanks

Code:
#!/bin/bash
/usr/bin/logger -s "START- STARTUP SCRIPT to enable TLER"
for i in {0..100}; do
/usr/local/sbin/smartctl -l scterc,80,80 /dev/da${i}; done
/usr/bin/logger -s "FINISHED- STARTUP SCRIPT to enable TLER"
 

Chris Moore

Hall of Famer
Joined
May 2, 2015
Messages
10,080
does anyone see any problems with this quick script i wrote?
Probably better to use the "get_smart_drives" function from this script:
https://github.com/Spearfoot/FreeNAS-scripts/blob/master/smart_report.sh

Code:
# 3. A smartctl-based function:
get_smart_drives()
{
  gs_drives=$("${smartctl}" --scan | grep "dev" | awk '{print $1}' | sed -e 's/\/dev\///' | tr '\n' ' ')

  gs_smartdrives=""

  for gs_drive in $gs_drives; do
    gs_smart_flag=$("${smartctl}" -i /dev/"$gs_drive" | grep "SMART support is: Enabled" | awk '{print $4}')
    if [ "$gs_smart_flag" = "Enabled" ]; then
      gs_smartdrives=$gs_smartdrives" "${gs_drive}
    fi
  done

  eval "$1=\$gs_smartdrives"
}
 

TAC

Contributor
Joined
Feb 16, 2014
Messages
152
HGST Deskstar NAS 4TB (0S04005) drives are disabled by default, but are settable.
Toshiba N300 6TB (HDWN160XZSTA) drives are disabled by default, but are settable.
Both drives retained values after reboot.

If 8 seconds is an acceptable value I will plan on setting all my drives with:
smartctl -l scterc,80,80 /dev/xxx
 

justjosh

Dabbler
Joined
Oct 21, 2019
Messages
11
Hello friends, apologies for digging this thread again.

I have received a couple of MyBooks which do not ship with TLER enabled and do not retain the setting on power cycle. I understand that this has been noted as an issue for more than 3 years now so surely someone has one of these drives drop out of an array by now? Would like to know if TLER was really enabled was was it a dud setting that had no effect at all.

Thank you.
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
Hello friends, apologies for digging this thread again.

I have received a couple of MyBooks which do not ship with TLER enabled and do not retain the setting on power cycle. I understand that this has been noted as an issue for more than 3 years now so surely someone has one of these drives drop out of an array by now? Would like to know if TLER was really enabled was was it a dud setting that had no effect at all.

Thank you.
See the first post of this thread for details on how to check and set the TLER on drives:
 

justjosh

Dabbler
Joined
Oct 21, 2019
Messages
11
See the first post of this thread for details on how to check and set the TLER on drives:
I know how to check and set TLER. I'm asking if the fact that the setting is lost after power cycle means that the TLER setting is just a fake value. Since we can't really test if TLER exists on a working drive, I was hoping someone had experience with one of these MyBook drives failing without TLER even though it was set in the options.
 

TooMuchData

Contributor
Joined
Jan 4, 2015
Messages
188
A few days ago I shucked two WD Elements and got two WD80EDAZ-11TA3A0. They respond to "smartctl -l scterc,70,70 /dev/adaX", and set TLER. But, they don't retain it after power off and on. Is there anything that can be done about that?
 
Joined
Oct 22, 2019
Messages
3,547
A few days ago I shucked two WD Elements and got two WD80EDAZ-11TA3A0. They respond to "smartctl -l scterc,70,70 /dev/adaX", and set TLER. But, they don't retain it after power off and on. Is there anything that can be done about that?

Storage > Disks > locate the drive in question > Edit > S.M.A.R.T. extra options

Add this line in the above text field:
-l scterc,70,70

smart-extra-options-tler.jpg
 
Last edited:

TooMuchData

Contributor
Joined
Jan 4, 2015
Messages
188
Perfect. Thanks for the help.
 

ragametal

Contributor
Joined
May 4, 2021
Messages
187
Storage > Disks > locate the drive in question > Edit > S.M.A.R.T. extra options

Add this line in the above text field:
-l scterc,70,70

View attachment 47540
I just logged in to report my experience trying to get my shucked WD80-EZAZ retain the TLER settings after a power cycle. I was going to suggest this solution as an alternative to the script posted in this thread.

So far this method works for me in a very reliable way. I'm all up to using scripts to do something that the OS doesn't do out of the box but in this case truenas has a native method of implementing my intent.

I honestly feel like I'm missing something. Am i giving up something by using this method instead of sing the script?
 

NASbox

Guru
Joined
May 8, 2012
Messages
644
A few days ago I shucked two WD Elements and got two WD80EDAZ-11TA3A0. They respond to "smartctl -l scterc,70,70 /dev/adaX", and set TLER. But, they don't retain it after power off and on. Is there anything that can be done about that?
@TooMuchData - I was wondering if these drives required any "special treatement" (jumpers or other mods), or if they can be installed like any other SATA drive? Thanks, and sorry for being a little off topic. Also is it possible to open the case without breaking it? I'm assuming that this voids the warranty.
 

jgreco

Resident Grinch
Joined
May 29, 2011
Messages
18,681
Also is it possible to open the case without breaking it? I'm assuming that this voids the warranty.

That's what they want you to assume. It isn't clear that a manufacturer refusing to honor warranty in this case is actually legal, but of course you have limited recourse if they choose to be like that.

You can(!) choose to shuck drives without using a Sawzall to open the case, however.


This isn't for the Elements case, but similar technique and care should result in a damage-less shucking.
 
Top