Unsure of SATA drive spindown

Status
Not open for further replies.

Milhouse

Guru
Joined
Jun 1, 2011
Messages
564
Big thank you to Milhouse for your Script!
I have a Intel SASUC8i controller with 7 discs attached and the script works fine for me. Is there a solution for autostart of this script yet?

Yes, I've been running an updated version that can be installed as a service and started at boot (or stopped/started manually). There are two files you need to create, and a config change, all three files are attached to this post in a single archive.

Follow the steps below and you should be good to go... an installable package would be nice, but I don't know how to make one. :)

  1. Obtain read-write access to your root partition

    Code:
    mount -uw /
    

  2. Create the following service control script as /conf/base/etc/local/rc.d/sasidled (or copy from the attached archive)
    Code:
    #!/bin/sh
    
    # PROVIDE: sasidled
    # REQUIRE: FILESYSTEMS DAEMON
    # BEFORE: LOGIN
    # KEYWORD: shutdown
    
    #sasidled_enable=YES
    sasidled_prefix="/usr/local"
    
    . /etc/rc.subr
    
    name="sasidled"
    command_interpreter="/bin/sh"
    rcvar=`set_rcvar`
    
    load_rc_config $name
    
    command="${sasidled_cmdpath-/usr/local/bin}/sasidle"
    command_args="${sasidled_args}"
    
    required_dirs="/var/run"
    pidfile="/var/run/$name.pid"
    
    start_precmd="sasidled_prestart"
    stop_postcmd="sasidled_poststop"
    
    sasidled_prestart()
    {
        if [ ! -d /var/run ]; then
            mkdir -p /var/run
        fi
    }
    
    sasidled_poststop()
    {
        rm -f $pidfile
    }
    
    run_rc_command "$1"
    

  3. Install the service wherever you want, on my system I create it as /mnt/share/bin/sasidle (or copy from the attached archive)

    EDIT: See post #79 for the latest version of the script.

  4. Set the correct permissions on the service and control files:
    Code:
    chmod 555 /conf/base/etc/local/rc.d/sasidled
    chmod 755 /mnt/share/bin/sasidle
    

  5. Configure the service by adding the following entries to the end of /conf/base/etc/rc.conf (or copy from the attached archive)
    Code:
    sasidled_enable=YES
    sasidled_cmdpath=/mnt/share/bin
    sasidled_args="-v"


    Note that sasidled_cmdpath points to the directory containing sasidle - in my case this is /mnt/share/bin.

    You can specify the sasidle command line arguments in sasidled_args. The "-v" option will log output every 1 minute to /var/log/messages, eventually you will want to change this to just "". You can also specify in sasidled_args which disks to monitor if this isn't detected automatically, and which zPool to monitor (currently the script can only handle a single zPool). Default timeout and intervals are 30 and 60, which should spindown all disks visible to camcontrol after 30 minutes (30 x 60 seconds) of idle.

  6. Remount root partition as read-only and reboot:
    Code:
    mount -ur /
    reboot

You should see notification that sasidled has started towards the end of the boot sequence.

You can monitor sasidled by executing "/etc/local/rc.d/sasidled status", or start and stop it by specifying the appropriate parameter.

Log output is written to /var/log/messages.

Any problems let me know and I'll try to fix them! :)
 

jfr2006

Contributor
Joined
May 27, 2011
Messages
174
Hi:

I have 2 pools: volume1 and volume2. I want to control stop discs at volume2. Would changing the sasidled_args from "-v" to "-p volume2 -v" work?

sorry for this dumb question, but shell script is not my strong ;)

Regards.
 

Milhouse

Guru
Joined
Jun 1, 2011
Messages
564
Hi:

I have 2 pools: volume1 and volume2. I want to control stop discs at volume2. Would changing the sasidled_args from "-v" to "-p volume2 -v" work?

sorry for this dumb question, but shell script is not my strong ;)

Regards.

Yes, should do. If it doesn't let me know and I'll investigate.

Alternatively, you can specify the individual disks to be controlled with -d, so just specify your volume2 disks in addition to "-p volume2".
 

jfr2006

Contributor
Joined
May 27, 2011
Messages
174
Thanks for the quick answer. I runned sasidle -v volume2 to test it and got the following output:

2011/11/09 14:39:00 ./sasidle starting
Identifying devices for pool "volume2"...
---------------------------------------------------------
Monitored Pool: volume2
Pool Interval: 60 seconds
Timeout interval: 30 * 60 seconds
ASync Enabled: Yes
Simulated Stop: No
Pool Devices: da0 da1 da2 da3
---------------------------------------------------------

should i expect any other output?

Regards.
 

Milhouse

Guru
Joined
Jun 1, 2011
Messages
564
Thanks for the quick answer. I runned sasidle -v volume2 to test it and got the following output:



should i expect any other output?

Regards.

No, not when running it like that, because it needs to "consume" the output from zpool, instead try:

Code:
zpool iostat volume2 60 | sasidle -v -p volume2


and you should get some output every 60 seconds (when run as a daemon, sasidle automatically "consumes" output from zpool for the relevant volume).

So the question I have is this: is your volume2 zpool made up of disks da0/da1/da2/da3?

I only have the one pool so I never really tested the device detection code when multiple pools are available, and it's entirely possible it has a bug in which case I already have a new version, but first send me the output from so that I know it will work for you:

Code:
/usr/local/bin/sqlite3 /data/freenas-v1.db "SELECT * FROM storage_disk ORDER BY disk_name ASC"


Thanks.
 

jfr2006

Contributor
Joined
May 27, 2011
Messages
174
Hi:

Yes, my volume2 zpool is made of discs da0/da1/da2/da3. Just finished installing the scripts and the daemon and notice that the output of the zpool iostats appears at the log.

As for the output of the command, here it goes:

Disabled|Always On|{uuid}509b8bb9-95d8-11e0-88d8-f46d04923303|1|Disabled|Auto|Member of volume1 raidz|1||1|ada0
Disabled|Always On|{uuid}50e9cf06-95d8-11e0-88d8-f46d04923303|1|Disabled|Auto|Member of volume1 raidz|1||2|ada1
Disabled|Always On|{uuid}da552b12-e94a-11e0-a10c-f46d04923303|1|Disabled|Auto|Member of volume1 raidz|1||10|ada2
Disabled|Always On|{uuid}51866467-95d8-11e0-88d8-f46d04923303|1|Disabled|Auto|Member of volume1 raidz|1||4|ada3
Disabled|Always On|{uuid}51ebb777-95d8-11e0-88d8-f46d04923303|1|Disabled|Auto|Member of volume1 raidz|1||5|ada4
Disabled|10|{uuid}4ecbec0b-b894-11e0-be8c-f46d04923303|1|Disabled|Auto|Member of volume2 raidz|2||11|ada5p2
Disabled|10|{uuid}5b97e6d8-b894-11e0-be8c-f46d04923303|1|Disabled|Auto|Member of volume2 raidz|2||12|ada6p2
Disabled|10|{uuid}68f3447a-b894-11e0-be8c-f46d04923303|1|Disabled|Auto|Member of volume2 raidz|2||13|ada7p2
Disabled|10|{uuid}75949fe3-b894-11e0-be8c-f46d04923303|1|Disabled|Auto|Member of volume2 raidz|2||14|ada8p2
 

Milhouse

Guru
Joined
Jun 1, 2011
Messages
564
the output of the zpool iostats appears at the log.

Yes it will if you specify the "-v" parameter in rc.conf for sasidled_args. Once you're happy it's working as it should you can remove the "-v" parameter.

Glad it's working for you, in any case I've updated post #41 (step 3) with the latest version v.0.2.1 of sasidle.
 

jfr2006

Contributor
Joined
May 27, 2011
Messages
174
Yes, it's working..i saw the camcontrol stop command on the log, after around 30 minutes system up :)

Good work!

Freenas team should include this script until they were able to fix the LSI drivers.

Regards.
 

Milhouse

Guru
Joined
Jun 1, 2011
Messages
564
Any pointers as how to adapt this script for freeBSD?

The only change required would be to change how automatic device detection is performed, as the current version depends upon the FreeNAS sqlite configuration database for this information (you could use "camcontrol devlist" instead, and then somehow cross reference with the devices in the pool, maybe using zdb).

If however you specify your own devices with the -d parameter you should be able to use it as-is in FreeBSD. It does obviously also depend on the presence of ZFS.
 

scsi-toaster

Cadet
Joined
Sep 13, 2011
Messages
4
Since I've updated to FreeNAS 8.0.4 my drives won't spin down anymore.
In /var/log/messages i got the following:

Mar 21 14:17:13 freenas sasidle[1629]: 001: Volume1 7.80T 3.07T 0 0 0 0
Mar 21 14:18:13 freenas sasidle[1629]: 000: Volume1 7.80T 3.07T 0 0 0 0
Mar 21 14:18:13 freenas sasidle[1629]: ** Stopping devices in pool "Volume1" **
Mar 21 14:18:13 freenas sasidle[1629]: camcontrol stop ada0
Mar 21 14:18:13 freenas sasidle[1629]: camcontrol stop ada1
Mar 21 14:18:13 freenas sasidle[1629]: camcontrol stop ada2
Mar 21 14:18:13 freenas sasidle[1629]: camcontrol stop ada3
Mar 21 14:18:13 freenas sasidle[1629]: camcontrol stop ada4
Mar 21 14:18:13 freenas sasidle[1629]: camcontrol stop ada5
Mar 21 14:18:13 freenas sasidle[1629]: Error received from stop unit command
Mar 21 14:18:13 freenas last message repeated 5 times
Mar 21 14:19:13 freenas sasidle[1629]: 000: Volume1 7.80T 3.07T 0 0 0 0

so I testet manually by typing "camcontrol stop ada0" and got: "Error received from stop unit command"

Please help me :smile:
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,994
I see you have posted here before. What version of FreeNAS were you running before 8.0.4 and have you made any hardware changes?

Try "camcontrol sleep ada0"

Also the "stop" command is only for SCSI devices. "sleep" is for ATA devices. Do you think this could be your problem?

Also you should retry "ataidle -S 60 /dev/ada0" or equivalent command since camcontrol as I understand it is called from ataidle.

Last thing, are you using the HDD Standby setting at all?
 

arryo

Dabbler
Joined
May 5, 2012
Messages
42
I tried to set the hdd spindown in GUI but it seems not working, I googled around and found this. I tried various command such as:

ataidle -S 5 /dev/ada0
ataidle -S 5 /dev/ada1
ataidle -S 5 /dev/ada2

and I checked using: http://forums.freenas.org/showthread.php?2068-How-to-find-out-if-a-drive-is-spinning-down-properly.

There's only 1 disk that is spundown, there other two are not.

Then I tried using these command to test if my drives can go standby:

camcontrol standby ada0 -t 900
camcontrol standby ada1 -t 900
camcontrol standby ada2 -t 900

None of these seem to have effect on my zfs pool (3 3Tb HDDs, of which 2 seagates and 1 WD green)

I plug all of my 3 hdds directly to MB, running Freenas 8.2.0 Beta3
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,994
@ arryo

I'm not running 8.2.0 versions at all so I can't test on the same version just to let you know. I will not be switching over to 8.2.0 until it's a bit more solid as I cut my teeth on 8.0 through 8.0.4 and let me tell you, that was something just over a year in length.

Are you getting any error messages at all when you type in these commands and are you root? Also are you running any plugins at all? I'm looking for something that might cause disk activity basically ensuring the drives never power down.

I'm sure you can hear the drives spin down and up but try this, assuming your drive is /dev/ada0

1) ataidle -S 120 /dev/ada0
2) smartctl -a -n standby /dev/ada0

If the second line returns a lot of data about your drive then it wasn't in standby otherwise you will get a message it is in standby.

Not knowing any history behind your machine I have a few questions...
1) Have you run FreeNAS 8.0.4 [or earlier versions] and had the drives spin down?
2) What drives are you running (model numbers as well)?
3) You might as well list your entire system specs in case someone spots a hardware compatibility issue.

Good Luck.
 

arryo

Dabbler
Joined
May 5, 2012
Messages
42
Thanks joeschmuck for your reply. Actually I was looking around for an OS that can handle spindown harddrives and came to freenas and this is my very first try on freenas. I downloaded two versions 8.0.4 and 8.2.0 and notice that the 8.0.4 doesn't have plugins session it it , that's why I switch to 8.2.0. I didn't know that two different versions will handle the hardware different ways.

After getting your reply, I tried 8.0.4 and the HDD spindown option in GUI. Same as 8.2.0, this GUI wouldn't work for my system. But when i use the ataidle command and use smartcl to check I see that my harddrives did spindown. So I will keep this 8.0.4 and figure out the way to install plugins (jail)

Since I can't use GUI to spindown HDD, can I use the script in http://forums.freenas.org/showthrea...A-drive-spindown&p=10883&viewfull=1#post10883 to make my HDDs spindown? and what should I change to make it work for my system (all of my HDDs are directly pluged to mainboard), that scrips it seems is for HDD plugged to card raid, isn't it?
 

arryo

Dabbler
Joined
May 5, 2012
Messages
42
update:

I added one folder to samba share and even though that folder not being accessed by anyone, the ataidle hdd spindown command i used seems to work for only 1 HDD, the other two still in active mode.

My hdd list:

ada0 WDC WD30EZRX-00MMMB0
ada1 ST3000DM001-9YN166 (this is the one spundown correctly)
ada2 ST33000651AS


my system:

CPU: I3-530
MB: GAH55M-USB30

FreeNas 8.0.4 on USB

I'm not sure if APM affect the spindown of HDD but when I check camcontrol identify, 2 of my disks ( ada0, ada2) are not supported APM (those that not spundown correctly)

update 2: I tried again with :

camcontrol standby ada0 -t 900
camcontrol standby ada1 -t 900
camcontrol standby ada2 -t 900

and those commands seem to work, now all of my HDDs are in standby mode after 15min. The next question is how could I revise Milhouse's script. I saw the lines that related:

Code:
			for DISK in ${DEVICES}; do
				if [ "$DOSTOP" ]; then
					[ "$DEBUG" -o "$QUIET" ] && echo "camcontrol stop ${DISK}"
					[   "${ASYNC}" ] && camcontrol stop ${DISK} &
					[ ! "${ASYNC}" ] && camcontrol stop ${DISK}
				else
					[ "$DEBUG" -o "$QUIET" ] && echo "#camcontrol stop ${DISK}"
				fi


Should I replace the camcontrol stop with camcontrol standby -t 900?
 

Erwin

Dabbler
Joined
Sep 21, 2011
Messages
30
--> the WDC WD30EZRX-00MMMB0 should support spin-down, as it works fine in my case.

What I could experience, ist that the config via GUI does not have any immediate effect. I think it requires a reboot.
Without a reboot just do the
ataidle -S 120 /dev/ada0
command for each of your drives to see/hear them spin down immediately. When the drives start again due to usage, they will do subsequent spin downs (after 120 minutes in this example, similat to what you selected in the GUI).
When you reboot the box later on for any other reason, ther is no need to do the ataidle commands again, as the GUI setup cares about the spindown behavior.

erwin
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,994
Erwin is correct. You must reboot for your settings to take affect from the GUI.

I would recommend against using small values for idle time such as 15 minutes. This will only increase the amount of spin up events causing the drive to fail earlier than it needs to. I recommend 2 hours or more. You can use that smartctrl -a /dev/ada0 command to check how many spinup events there has been to date and then check it a week later to see how much it has increased. My count is roughly 16 times a week only because of the number of backup events I have, yours may be more depending on use.

Now lets briefly talk about plugins with respect to 8.2.0 and please understand that I'm no expert here but this is what I understand...
1) Plugins are stored in jails on the hard drives and last I heard could only reside on ZFS formatted drives.
2) When you access these plugins you typically access the hard drives which will cause them to spin up.
3) The Plugins are currently not very good with ease of installation or use but this will change with time.

I would have to ask you which plugins you are looking to use. If they are one of the three that are built into the 8.0.4-Multimedia then you would be better to start there. But if you want to run and test the latest product like I was doing last year then go for 8.2.0 but do not expect your hard drives to sleep much with plugins. I could recommend that you consider placing your plugins on a ZFS formatted flash drive (I have a 32GB USB Flash drive) and give that a shot. I don't know of anyone specifically doing that but it might keep your hard drives from spinning up all the time. I do plan to upgrade to 8.3 when it hits the streets but using that 32GB flash drive vice the hard drives for my plugins. Right now I use FireFly and iTunes and I'm not using Transmission although it does work well from what I've read.

Some advice: If you plan to run the hard drives as spinning all the time (24/7) then I strongly recommend enterprise level hard drives that are designed to handle non-stop operation.

As far as your question about the milhouse script, your suggestion sounds good but I haven't examined that script and unfortunately don't have the time to play with it. I have to replace the brakes on my daughters car which includes all the hardware except the hard lines and master cylinder. Yes, everything at the wheel ends, everything. Should be fun because I'm making my daughter help out. She's almost 16 and not mechanically inclined.

So let me know how things go. I will help with what I know.

-Mark

EDIT: APM and Acoustic level, leave those disabled. Neither give you any deal of benefit and APM set to the wrong level (typically 127 or lower) will cause the drives to spin up and down constantly. Leave then disabled.

Also, how much RAM do you have and are you running the 32 or 64 bit version of FreeNAS?
 

arryo

Dabbler
Joined
May 5, 2012
Messages
42
Im using 4G ram and 64bit version of Freenas. The plugins I would like to use are rtorrent, logitech media server but after searching around the forum I found out they are not available yet. I'm thinking of install the full freebsd but still not figuring how to make it run on USB
 
Status
Not open for further replies.
Top