Unsure of SATA drive spindown

Status
Not open for further replies.

evilandy

Dabbler
Joined
Sep 26, 2011
Messages
38
Hi Milhouse,

Thank you for the script. It looks great. I've modified it by swapping out the sas commands with the ataidle commands (since I'm using the N36L onboard sata but still have problems with my drives not spinning down via the script and the FreeNAS GUI (9.1 release) can't make my Hitachi drives spin down. However, I'm a bit stuck. Everything looks good until the execution of the spindown.

My current output is as follows:

Feb 13 21:44:25 storage100 sasidle[2302]: 005: capacity operations bandwidth
Feb 13 21:44:25 storage100 sasidle[2302]: 005: pool alloc free read write read write
Feb 13 21:44:25 storage100 sasidle[2302]: 005: ---------- ----- ----- ----- ----- ----- -----
Feb 13 21:44:25 storage100 sasidle[2302]: 005: storage100 13.3T 363G 11 59 49.4K 230K
Feb 13 21:45:25 storage100 sasidle[2302]: 005: storage100 13.3T 363G 0 3 273 7.62K
Feb 13 21:45:25 storage100 sasidle[2310]: 005: storage100_ssd 2.28G 55.2G 32 13 852K 332K
Feb 13 21:46:25 storage100 sasidle[2302]: 004: storage100 13.3T 363G 0 0 0 0
Feb 13 21:46:25 storage100 sasidle[2310]: 005: storage100_ssd 2.28G 55.2G 0 2 68 13.6K
Feb 13 21:47:25 storage100 sasidle[2302]: 003: storage100 13.3T 363G 0 0 0 0
Feb 13 21:47:25 storage100 sasidle[2310]: 005: storage100_ssd 2.28G 55.2G 0 1 0 14.7K
Feb 13 21:48:25 storage100 sasidle[2302]: 002: storage100 13.3T 363G 0 0 0 0
Feb 13 21:48:25 storage100 sasidle[2310]: 005: storage100_ssd 2.28G 55.2G 0 1 0 6.73K
Feb 13 21:49:25 storage100 sasidle[2302]: 001: storage100 13.3T 363G 0 0 0 0
Feb 13 21:49:25 storage100 sasidle[2310]: 005: storage100_ssd 2.28G 55.2G 0 1 0 6.73K
Feb 13 21:50:25 storage100 sasidle[2302]: 000: storage100 13.3T 363G 0 0 0 0
Feb 13 21:50:25 storage100 sasidle[2302]: ** Stopping devices in pool "storage100" **
Feb 13 21:50:25 storage100 sasidle[2302]: ataidle -S 5 /dev/ada0
Feb 13 21:50:25 storage100 sasidle[2302]: ataidle -S 5 /dev/ada1
Feb 13 21:50:25 storage100 sasidle[2302]: ataidle -S 5 /dev/ada2
Feb 13 21:50:25 storage100 sasidle[2302]: ataidle -S 5 /dev/ada3
Feb 13 21:50:25 storage100 sasidle[2302]: ataidle -S 5 /dev/ada5
Feb 13 21:50:25 storage100 sasidle[2310]: 005: storage100_ssd 2.28G 55.2G 0 4 0 40.8K
Feb 13 21:51:25 storage sasidle[2302]: 000: storage100 13.3T 363G 0 0 0 0

The correct pool and devices are recognised. Everything works until I get to the ataidle -S 5 /dev/ada0 command.

This command works via the cli so I'm not sure why it's not spinning down the drives?

Any thought would be really helpful.
 

evilandy

Dabbler
Joined
Sep 26, 2011
Messages
38
Yey, I got it to work, I used:

/usr/local/sbin/ataidle -s /dev/ada0 to shut down the Hitatchi drives in the script.
 

ajohnson

Dabbler
Joined
Feb 25, 2013
Messages
18
Hey Millhouse, thanks for this script, it works great on my FreeNAS box with an M1015.

I made a bunch of mods to better a setup where I have SMART tests enabled and threw it on github here:
https://github.com/ajohnson23/millhouse

Again, my modifications were made to better support SMART. Namely:
  • If a SMART test runs that causes the disks to spin up, this will be detected and the idle timer will be reset. Previously, if the disks were spun down and awoken by a SMART test, the script wouldn't know about this and wouldn't spin the disks back down.
  • If a SMART test is in progress, we won't try to spin the disks down.
  • Use "smartctl -s standby,now" to spin the disks down instead of "camcontrol stop". A benefit of this is that we can use the smartctl "-n standby" flag, so that if the disk already happens to be spun down, we don't wake it up in order to spin it down again.
Now, the catch here is that your drives have to have SMART turned on and be capable of handling smartctl -s standby,now and smartctl -n standby, etc.

Anyway, hopefully someone out there finds this useful. Cheers.
 

TCM

Cadet
Joined
Mar 23, 2014
Messages
6
What about this ugly hack? (requires zsh for arrays but I just took the easy route there)

Code:
#!/usr/local/bin/zsh
 
timeout=$((60*60))
typeset -A timeouts
 
iostat -x 1 \
| stdbuf -o L egrep '^a?da' \
| while read device rs ws kr kw qlen svct b; do
        if [[ "${kr}" == "0.0" && "${kw}" == "0.0" ]]; then
                timeouts[${device}]=$((timeouts[${device}]+1))
        else
                timeouts[${device}]=0
        fi
 
        if [[ ${timeouts[${device}]} -eq ${timeout} ]]; then
                echo "$(date +'%Y-%m-%d %T') spindown ${device}"
                case ${device} in
                        ada*)
                                camcontrol standby ${device}
                                ;;
                        da*)
                                camcontrol stop ${device}
                                ;;
                esac
        fi
done


It doesn't care about ZFS at all. It just spins down any da* and ada* disks that have been idle for $timeout seconds.
 

ajohnson

Dabbler
Joined
Feb 25, 2013
Messages
18
I like it! This could tidy up an idle script nicely, since some of the zfs / pool specific stuff could be ripped out -- you can just deal with things on an individual drive basis.

Note, if one wanted to handle the SMART issues I mentioned in my post above, a separate handling would still be required for that, because in my cursory examination, iostat does not report SMART test related IO.

What about this ugly hack? (requires zsh for arrays but I just took the easy route there)
<snip code>
It doesn't care about ZFS at all. It just spins down any da* and ada* disks that have been idle for $timeout seconds.
 

TCM

Cadet
Joined
Mar 23, 2014
Messages
6
Feel free to abuse it. I hacked it together in like 10 minutes. It could also be made to work with plain /bin/sh, and proper configuration handling, and logging and anything else I didn't care about. :)

It should be no problem to put additional checks before the camcontrols. Also note I'm only using camcontrol standby for ATA disks because of the warning about "sleep" in the man page. No idea what's up with that and I didn't want to risk anything on my live server.
 

NetworkCo

Cadet
Joined
Mar 3, 2014
Messages
8
Is there any plans to include camcontrol into powerdaemon's skillset thus eliminating the complications LSI's controllers present?

It sure would be nice to have my drives attached to any controller spin down as expected without complicaed customizations
 

eddyanm

Cadet
Joined
Jul 29, 2014
Messages
6
I want to first say that this thread has been very informative. I was trying to disable APM to stop my Seagate ST3000DM001's from frequent load/unloading of the heads and has the same issue with LSI MPT driver not passing the command. Searching the Internet led me to believe that this is not an issue with Linux distributions. So I came up with a workaround.

My drives are attached to an IBM M1115 (similar to M1015 and LSI SAS2008 OEM) SAS HBA and I ran into the same issue when running

Code:
camcontrol cmd /dev/da1 -a "EF 85 00 00 00 00 00 00 00 00 00 00" -v

where da1 is my first ST3000DM001.

It would return "CAM status: CCB request was invalid."

I am running FreeNAS 9.2.1.6 in a VM with the disks being physical RDM'ed and assigned to the FreeNAS VM.

As a workaround, I powered off the VM for FreeNAS and attached them temporarily to an Ubuntu VM and ran

Code:
hdparm -B 255 /dev/sdb

(where sdb is the same drive from FreeNAS)

Code:
hdparm -B /dev/sdb

confirms that APM is now turned off for the drive.

I then power off the Ubuntu VM and detached the drives.

When I restarted FreeNAS, I was able to confirm that the disks now have APM turned off from within FreeNAS using

Code:
camcontrol identify /dev/da1


The only annoying part about this workaround and that the APM setting is not persistent between power cycle (per what I can find on the internet) so I would have to do this every time I power cycle the machine. I haven't tested power cycling yet. Luckily, my setup is meant to be a server so I only power cycle it once or twice a year.

The same workaround can be used to enable and set APM and AAM. For those running FreeNAS on iron, I think you can try rebooting the server into Linux on an USB stick, make the changes and reboot back into FreeNAS without power cycling the machine and lose your changes.

Cheers.
 
Status
Not open for further replies.
Top