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

Script to make sure TLER is always enabled on your drives

fta

FreeNAS Experienced
Joined
Apr 6, 2015
Messages
148
Thanks
33
#1
Since the HGST NAS drives I just bought don't have TLER enabled by default, I wrote a quick script to enable it on all my drives at boot. To use the script, place it somewhere static and then add it as a preinit command in the init/shutdown scripts. I use it as follows:

Code:
/data/config/bin/set_tler.py 7 7


I put it in /data because my pool is encrypted with a password. The script will iterate through all drives and try to enable TLER. A failure is a no-op.

The scripts are here:
https://github.com/fhriley/freenas_config/blob/master/bin/set_tler.py
https://github.com/fhriley/freenas_config/blob/master/bin/disks.py
 
Last edited:
Joined
Mar 25, 2012
Messages
19,154
Thanks
1,854
#2
I like this idea. I've moved it to the guides section. Instead of putting it in /root, I'd put it in /data. /data is one of those safe havens where the upgrade process won't delete stuff that already exists.
 

fta

FreeNAS Experienced
Joined
Apr 6, 2015
Messages
148
Thanks
33
#3
Instead of putting it in /root, I'd put it in /data. /data is one of those safe havens where the upgrade process won't delete stuff that already exists.
Good call, I knew there was a good place, I was brain farting on where it was though. Updated the OP.
 
Joined
Jun 8, 2016
Messages
65
Thanks
7
#4
I'm trying to use your script but I have a problem.
I've created a directory /mnt/tank called scripts, in it I created the set_tler.py, changed attributes to executable and put this: "/mnt/tank/scripts/set_tler.py 7 7" as a Pre Init command into the Tasks; Init/Shutdown scripts and after a (re)boot TLER is not set.
When i run the script manually /mnt/tank/scripts# ./set_tler.py 7 7 (or ./set_tler.py only)
I get this:
Traceback (most recent call last):
File "./set_tler.py", line 7, in <module>
from disks import get_disks
ImportError: No module named disks

What I'm doing wrong?
 

fta

FreeNAS Experienced
Joined
Apr 6, 2015
Messages
148
Thanks
33
#5
I reorganized the code so I could reuse pieces of it. You'll need one additional file. I updated the OP.
 
Joined
Nov 24, 2013
Messages
71
Thanks
7
#7
FreeBSD newbie here trying to copy your script with the following command:
scp github.com:fhriley/freenas_config/blob/master/bin/set_tler.py /data


And receiving the error message:

Permission denied (publickey).

Any help would be appreciated.
 

fta

FreeNAS Experienced
Joined
Apr 6, 2015
Messages
148
Thanks
33
#8
Click on the link in the OP. On the page that pops up, right click the "raw" button and your browser should give you an option to download the file.
 

diskdiddler

FreeNAS Guru
Joined
Jul 9, 2014
Messages
2,138
Thanks
126
#9
How does one actually run this script? I literally don't know how to execute it?
 
Joined
Dec 26, 2015
Messages
12
Thanks
2
#10
Thanks for this great script.
It runs perfectly from a shell, but it doesn't apply if I add it to Init/Shutdown Scripts as a command (post init):

/mnt/tank/usr/scripts/set_tler.py 7 7

the script is not starting. Any idea? Thanks!
I am running Freenas 11.2 stable
 
Last edited:
Top