HDD standby/spindown

Status
Not open for further replies.

Ef57uiKnN6

Dabbler
Joined
Mar 25, 2012
Messages
28
Just noticed the by FreeNAS 9.1.0 introduced 'Init/Shutdown Script' option which makes the addition of rc files unnecessary.
 

zephyr

Dabbler
Joined
Aug 29, 2013
Messages
14
How can I check if the script has been installed correctly and working? My FreeNAS version is 9.2.0.
I still have a problem with the HDD Caviar Green 3TB EZRX. I can not put it in IDLE. The disk is in the ZFS Pool and "Enable atime" is "Off".
 

Ef57uiKnN6

Dabbler
Joined
Mar 25, 2012
Messages
28
How can I check if the script has been installed correctly and working?
There is no one correct way to install the script. But the INSTALL file within the tarball (0.3 recently updated with updated INSTALL file) shows how one might install it properly.
You can check if the script is running by taking a look at the process list:
Code:
[root@freenas2] ~# pgrep -f hdd_spindown.sh
5883
[root@freenas2] ~# ps 5883
 PID TT  STAT    TIME COMMAND
5883 v0- I    0:00.74 /bin/bash /data/bin/hdd_spindown.sh -s
[root@freenas2] ~#


Beside taking a look at your message log:
Code:
[root@freenas2] /data/bin# grep hdd_spindown /var/log/messages 
Jan 14 03:20:39 freenas2 hdd_spindown[5887]: Configured HDD standby times will be refreshed after every '12' checks
Jan 14 03:20:39 freenas2 hdd_spindown[5889]: Initial check does not spin down any drive
Jan 14 03:20:40 freenas2 hdd_spindown[5917]: Drive da0 is configured to be spun down after '7200' seconds of inactivity
Jan 14 03:20:40 freenas2 hdd_spindown[5919]: Drive da1 is configured to be spun down after '7200' seconds of inactivity
Jan 14 03:20:40 freenas2 hdd_spindown[5923]: Drive da2 is configured to be spun down after '7200' seconds of inactivity
Jan 14 03:20:40 freenas2 hdd_spindown[5927]: Drive ada0 is configured to be spun down after '7200' seconds of inactivity
Jan 14 03:20:40 freenas2 hdd_spindown[5931]: Drive ada1 is configured to be spun down after '7200' seconds of inactivity
Jan 14 03:20:40 freenas2 hdd_spindown[5935]: Drive ada2 is configured to be spun down after '7200' seconds of inactivity
Jan 14 03:20:40 freenas2 hdd_spindown[5936]: Drive ada3 is configured to be spun down after '7200' seconds of inactivity
Jan 14 03:20:40 freenas2 hdd_spindown[5938]: Drive ada4 is configured to be spun down after '7200' seconds of inactivity
Jan 14 03:20:40 freenas2 hdd_spindown[5939]: Drive ada5 is configured to be spun down after '7200' seconds of inactivity
Jan 14 03:20:40 freenas2 hdd_spindown[5943]: Drive ada6 is configured to be spun down after '7200' seconds of inactivity
Jan 14 03:20:40 freenas2 hdd_spindown[5944]: Drive ada7 is configured to be spun down after '7200' seconds of inactivity
Jan 14 03:20:40 freenas2 hdd_spindown[6060]: Sleeping '7200' seconds till next check. '11' checks left to next update of HDD standby times.
Jan 14 05:20:40 freenas2 hdd_spindown[10083]: Spinning down drive by command 'camcontrol stop ada7' failed
Jan 14 05:20:40 freenas2 hdd_spindown[10086]: Spinning down drive by command 'atacontrol spindown ada7' failed
Jan 14 05:20:40 freenas2 hdd_spindown[10089]: Spinning down drive by command 'ataidle -s /dev/ada7' failed
Jan 14 05:20:40 freenas2 hdd_spindown[10092]: Drive 'ada7' successfully spun down by command '/usr/local/sbin/ataidle -s /dev/ada7'


you can start the script manually and see if it works as expected:
Code:
[root@freenas2] ~# /data/bin/hdd_spindown.sh 
1389727828 0info Configured HDD standby times will be refreshed after every '12' checks
1389727828 0info Initial check does not spin down any drive
1389727829 0info Drive da0 is configured to be spun down after '7200' seconds of inactivity
1389727829 0info Drive da1 is configured to be spun down after '7200' seconds of inactivity
1389727829 0info Drive da2 is configured to be spun down after '7200' seconds of inactivity
1389727829 0info Drive ada0 is configured to be spun down after '7200' seconds of inactivity
1389727829 0info Drive ada1 is configured to be spun down after '7200' seconds of inactivity
1389727829 0info Drive ada2 is configured to be spun down after '7200' seconds of inactivity
1389727829 0info Drive ada3 is configured to be spun down after '7200' seconds of inactivity
1389727829 0info Drive ada4 is configured to be spun down after '7200' seconds of inactivity
1389727829 0info Drive ada5 is configured to be spun down after '7200' seconds of inactivity
1389727829 0info Drive ada6 is configured to be spun down after '7200' seconds of inactivity
1389727829 0info Drive ada7 is configured to be spun down after '7200' seconds of inactivity
1389727829 0info Sleeping '7200' seconds till next check. '11' checks left to next update of HDD standby times.
^C
[root@freenas2] ~#


I still have a problem with the HDD Caviar Green 3TB EZRX. I can not put it in IDLE. The disk is in the ZFS Pool and "Enable atime" is "Off".

If the deposited commands don't spin down the drive, then try to find a proper command and add it to the script:
Code:
--- SNIP hdd_spindown.sh ---
  SPINDOWN_CMD+=('this-is-a-new-command $DEV')
  SPINDOWN_CMD+=('/usr/local/sbin/ataidle -s $DEV')
  SPINDOWN_CMD+=('ataidle -s $DEV')
  SPINDOWN_CMD+=('/usr/local/sbin/ataidle -s /dev/$DEV')
  SPINDOWN_CMD+=('ataidle -s /dev/$DEV')
  SPINDOWN_CMD+=('atacontrol spindown $DEV')
  SPINDOWN_CMD+=('camcontrol stop $DEV')
--- SNAP hdd_spindown.sh ---
 

zephyr

Dabbler
Joined
Aug 29, 2013
Messages
14
Command "ataidle -s /dev/ada1" called from the console stops the drive in ZFS pool, but in the script doesn't work. Script works fine for drive ada0 - "Drive 'ada0' successfully spun down by command '/usr/local/sbin/ataidle -s /dev/ada0'.
 

Ef57uiKnN6

Dabbler
Joined
Mar 25, 2012
Messages
28
I wonder if there is really no I/O on ada1.
What is the output with increased log level?
Code:
/path/to/hdd_spindown.sh -l 0


You probably might want to set the 'HDD Standby' for the drive in question to '5' for getting a quicker result.
Setting TIME_FACTOR within update_dev_cfg() from 60 to 6 would make the script interprete 5 minutes as 30 seconds.
 

Ef57uiKnN6

Dabbler
Joined
Mar 25, 2012
Messages
28
After the command I got the message: hdd_spindown.sh: Command not found.
When the shell script does not reside in one of the configured paths in your PATH variable, then you have to call the script either relatively or absolutely:
Code:
[root@freenas2] /data/bin# pwd
/data/bin
[root@freenas2] /data/bin# ls -1 hdd_spindown.sh
hdd_spindown.sh*
[root@freenas2] /data/bin# ./hdd_spindown.sh -h
usage: hdd_spindown.sh [-dhist] [-l level]
    -d          daemonize
    -h          help
    -i          initial spindown
    -l level    log level
    -s          log to syslog
    -t          test / one-shot mode
[root@freenas2] /data/bin#

Code:
[root@freenas2] ~# ls -1 /data/bin/hdd_spindown.sh
/data/bin/hdd_spindown.sh*
[root@freenas2] ~# /data/bin/hdd_spindown.sh -h
usage: hdd_spindown.sh [-dhist] [-l level]
    -d          daemonize
    -h          help
    -i          initial spindown
    -l level    log level
    -s          log to syslog
    -t          test / one-shot mode
[root@freenas2] ~#
 

zephyr

Dabbler
Joined
Aug 29, 2013
Messages
14
The problem is that I am in the folder where the file hdd_pindown.sh* is located and message "hdd_spindown.sh: Command not found" persists.
 

Ef57uiKnN6

Dabbler
Joined
Mar 25, 2012
Messages
28
The problem is that I am in the folder where the file hdd_pindown.sh* is located and message "hdd_spindown.sh: Command not found" persists.
Did you noticed the point and the slash before 'hdd_spindown.sh' in the example for execution when the script is located in the current working directory?:
Code:
[root@freenas2] /data/bin# ./hdd_spindown.sh -h
 

evilandy

Dabbler
Joined
Sep 26, 2011
Messages
38
Thanks, for this. I'm currently looking into using the script and before doing so, am analysing my current setup to try and troubleshoot via the FreeNAS GUI options first.

I had a ridiculously high amount of startup/spin downs from the SMART log so needed to obtain a solution. I've previously been using the following settings for a set of new Seagate 4TB NAS drives using the FreeNAS 9.1 GUI under Disk

HDD Standby 5
Advanced Power Management 1

Drives seem to be up and down quite a lot. I think this is aggressive APM. After reading the forums, I can see the use of both is not advised.

Thanks,

EA
 

evilandy

Dabbler
Joined
Sep 26, 2011
Messages
38
This maybe useful. I seems to get different results with two hard drives manufacturers. My 4TB Seagate drives seem to work pretty well at spinning down (5 min) via the FreeNAS GUI but my 3tb Hitachi drives don't. All on the SATA motherboard.
 

evilandy

Dabbler
Joined
Sep 26, 2011
Messages
38
Under the FreeNAS GUI settings for Disks with:

HDD Standby 5
Advanced Power Management 0

Everything spins down after 5 minutes of inactivity on the Seagate drives.
 

evilandy

Dabbler
Joined
Sep 26, 2011
Messages
38
Hi Everyone,

I'm still looking into the Hitachi and Seagate drives ability to idle. Using cam control, I noticed:

Seagate: 50 00 00 00 00 40 00 00 00 00 00
Hitachi: ADA0: 50 00 00 00 00 00 00 00 00 FF 00

Does anyone know what the 40 means?

Thanks

EA
 

evilandy

Dabbler
Joined
Sep 26, 2011
Messages
38
After playing with the scripts, I've ended up not testing this one out and have used a modified version of Milhouse's script with a few snippets from this script. Thank you both for your hard work. I'm please to say that after a long day, I've got my 6 SATA drives on the N36L HP Microserver motherboard (including eSATA) to spin down.
 

evilandy

Dabbler
Joined
Sep 26, 2011
Messages
38
After playing with the scripts, I've ended up not testing this one out and have used a modified version of Milhouse's script but using a few snippets from this script. Thank you both for your hard work. I'm please to say that after a long day, I've got my 6 SATA drives on the N36L HP Microserver motherboard (including eSATA) to spin down.
 

sifebr

Cadet
Joined
Aug 28, 2014
Messages
2
I upload the scripts ,but got following message from /var/log/message .... Did I do something wrong?....
My Environment:
- FreeNAS-9.2.1.7-x64
- i3-2120
- LSI SAS 9211-8i
- WDC Red NAS 2T x 4 @RAIDZ

.
Aug 31 16:35:22 NAS hdd_spindown[61500]: Sleeping '0' seconds till next check. '7' checks left to next update of HDD standby times.
Aug 31 16:35:22 NAS hdd_spindown[61507]: Sleeping '0' seconds till next check. '6' checks left to next update of HDD standby times.
Aug 31 16:35:22 NAS hdd_spindown[61514]: Sleeping '0' seconds till next check. '5' checks left to next update of HDD standby times.
Aug 31 16:35:22 NAS hdd_spindown[61521]: Sleeping '0' seconds till next check. '4' checks left to next update of HDD standby times.
Aug 31 16:35:22 NAS hdd_spindown[61528]: Sleeping '0' seconds till next check. '3' checks left to next update of HDD standby times.
Aug 31 16:35:22 NAS hdd_spindown[61535]: Sleeping '0' seconds till next check. '2' checks left to next update of HDD standby times.
Aug 31 16:35:22 NAS hdd_spindown[61542]: Sleeping '0' seconds till next check. '1' checks left to next update of HDD standby times.
Aug 31 16:35:22 NAS hdd_spindown[61549]: Sleeping '0' seconds till next check. '0' checks left to next update of HDD standby times.
Aug 31 16:35:22 NAS hdd_spindown[61555]: Got at leaset one unexpected value from database: COL1=, COL2=
Aug 31 16:35:22 NAS hdd_spindown[61561]: Sleeping '0' seconds till next check. '11' checks left to next update of HDD standby times.
Aug 31 16:35:22 NAS hdd_spindown[61568]: Sleeping '0' seconds till next check. '10' checks left to next update of HDD standby times.
Aug 31 16:35:22 NAS hdd_spindown[61575]: Sleeping '0' seconds till next check. '9' checks left to next update of HDD standby times.
Aug 31 16:35:22 NAS hdd_spindown[61582]: Sleeping '0' seconds till next check. '8' checks left to next update of HDD standby times.
Aug 31 16:35:22 NAS hdd_spindown[61589]: Sleeping '0' seconds till next check. '7' checks left to next update of HDD standby times.
Aug 31 16:35:22 NAS hdd_spindown[61596]: Sleeping '0' seconds till next check. '6' checks left to next update of HDD standby times.
Aug 31 16:35:22 NAS hdd_spindown[61603]: Sleeping '0' seconds till next check. '5' checks left to next update of HDD standby times.
Aug 31 16:35:22 NAS hdd_spindown[61610]: Sleeping '0' seconds till next check. '4' checks left to next update of HDD standby times.
Aug 31 16:35:22 NAS hdd_spindown[61617]: Sleeping '0' seconds till next check. '3' checks left to next update of HDD standby times.
Aug 31 16:35:22 NAS hdd_spindown[61624]: Sleeping '0' seconds till next check. '2' checks left to next update of HDD standby times.
Aug 31 16:35:22 NAS hdd_spindown[61631]: Sleeping '0' seconds till next check. '1' checks left to next update of HDD standby times.
Aug 31 16:35:22 NAS hdd_spindown[61638]: Sleeping '0' seconds till next check. '0' checks left to next update of HDD standby times.
Aug 31 16:35:22 NAS hdd_spindown[61644]: Got at leaset one unexpected value from database: COL1=, COL2=
Aug 31 16:35:22 NAS hdd_spindown[61650]: Sleeping '0' seconds till next check. '11' checks left to next update of HDD standby times.
Aug 31 16:35:22 NAS hdd_spindown[61657]: Sleeping '0' seconds till next check. '10' checks left to next update of HDD standby times.
Aug 31 16:35:22 NAS hdd_spindown[61664]: Sleeping '0' seconds till next check. '9' checks left to next update of HDD standby times.
Aug 31 16:35:22 NAS hdd_spindown[61671]: Sleeping '0' seconds till next check. '8' checks left to next update of HDD standby times.
Aug 31 16:35:22 NAS hdd_spindown[61678]: Sleeping '0' seconds till next check. '7' checks left to next update of HDD standby times.
Aug 31 16:35:23 NAS hdd_spindown[61685]: Sleeping '0' seconds till next check. '6' checks left to next update of HDD standby times.
Aug 31 16:35:23 NAS hdd_spindown[61692]: Sleeping '0' seconds till next check. '5' checks left to next update of HDD standby times.
Aug 31 16:35:23 NAS hdd_spindown[61699]: Sleeping '0' seconds till next check. '4' checks left to next update of HDD standby times.
Aug 31 16:35:23 NAS hdd_spindown[61706]: Sleeping '0' seconds till next check. '3' checks left to next update of HDD standby times.
Aug 31 16:35:23 NAS hdd_spindown[61713]: Sleeping '0' seconds till next check. '2' checks left to next update of HDD standby times.
Aug 31 16:35:23 NAS hdd_spindown[61720]: Sleeping '0' seconds till next check. '1' checks left to next update of HDD standby times.
Aug 31 16:35:23 NAS hdd_spindown[61727]: Sleeping '0' seconds till next check. '0' checks left to next update of HDD standby times.
Aug 31 16:35:23 NAS hdd_spindown[61733]: Got at leaset one unexpected value from database: COL1=, COL2=
Aug 31 16:35:23 NAS hdd_spindown[61739]: Sleeping '0' seconds till next check. '11' checks left to next update of HDD standby times.
Aug 31 16:35:23 NAS hdd_spindown[61746]: Sleeping '0' seconds till next check. '10' checks left to next update of HDD standby times.
Aug 31 16:35:23 NAS hdd_spindown[61753]: Sleeping '0' seconds till next check. '9' checks left to next update of HDD standby times.
Aug 31 16:35:23 NAS hdd_spindown[61760]: Sleeping '0' seconds till next check. '8' checks left to next update of HDD standby times.
Aug 31 16:35:23 NAS hdd_spindown[61767]: Sleeping '0' seconds till next check. '7' checks left to next update of HDD standby times.
 
Last edited:

filipvh

Cadet
Joined
Jun 3, 2012
Messages
5
hi, wanted to try out your script, tried it in test mode:


[root@nas] /???/???/???# ./hdd_spindown.sh -t

[INFO ] Initial check does not spin down any drive
[ERROR ] Got at leaset one unexpected value from database: COL1=, COL2=
[INFO ] Test/One-shot mode. Exiting.
 

qanomaly

Cadet
Joined
Feb 8, 2015
Messages
1
hi, wanted to try out your script, tried it in test mode:


[root@nas] /???/???/???# ./hdd_spindown.sh -t

[INFO ] Initial check does not spin down any drive
[ERROR ] Got at leaset one unexpected value from database: COL1=, COL2=
[INFO ] Test/One-shot mode. Exiting.

The script only checks for drives which are not set to "Always on" in Storage > Volumes > View Disks. Set some value for "HDD Standby" there and try again :)
 
Y

YpsiNine

Guest
Hi, thanks for this script. First time user of FreeNAS, just installed 9.3 with 16 drives connected to SM backplane -> LSI 9211-8i and I have massive problems getting anything to make the drives spin down, nothing in the GUI works. So I figured I'd look into all this script stuff (I'm a Windows guy).

I cannot get the script to start, this is what I get:
Code:
./hdd_spindown.sh -d
./hdd_spindown.sh: line 292: export: `-d': not a valid identifier
./hdd_spindown.sh: line 292: export: `0': not a valid identifier


The above was via Putty / SSH. Same in Shell in GUI.

Thanks,
Y
 
Y

YpsiNine

Guest
I figured out the above problem, it was actually a copy/paste problem into Putty. Now it works, thanks a lot!
 
Status
Not open for further replies.
Top