Register for the iXsystems Community to get an ad-free experience and exclusive discounts in our eBay Store.

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

xterminated

Newbie
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
1,939
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

Newbie
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
1,939
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

FreeNAS Experienced
Joined
Mar 10, 2019
Messages
145
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
1,939
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

Super Moderator
Moderator
Joined
May 2, 2015
Messages
9,551
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

FreeNAS Experienced
Joined
Dec 2, 2018
Messages
128
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

Super Moderator
Moderator
Joined
May 2, 2015
Messages
9,551
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

FreeNAS Experienced
Joined
Feb 16, 2014
Messages
128
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
 
Top