How to find out if a drive is spinning down properly.

Durkatlon

Patron
Joined
Aug 19, 2011
Messages
414
For installs that use the AHCI driver to control the hard drives, it is not obvious how you can find out if a drive has actually spun down according to the configuration that you have set.

This post shows you how you can use the camcontrol command to find out the power state of a drive.

First you need to identify the drive you want to take a look at:
Code:
nanotube# camcontrol devlist
<ST1500DL003-9V16L CC32>       at scbus0 target 0 lun 0 (pass0,ada0)
<ST1500DL003-9V16L CC32>       at scbus2 target 0 lun 0 (pass1,ada1)
<USB 2.0 Flash Drive 5.00>     at scbus6 target 0 lun 0 (pass2,da0)

So on my system, ada0 and ada1 are my two harddrives that I'm interested in. I will inspect the power state of ada0.
Code:
nanotube# camcontrol cmd ada0 -a "E5 00 00 00 00 00 00 00 00 00 00 00" -r -
50 00 00 00 00 40 00 00 00 FF 00

Take a look at the 10th hexadecimal value in the output. If this says "FF", the drive is spinning, if it says "00" the drive is spun down. It's that easy!!

I wrote a little script that checks both of my drives every 30 seconds so I can see if they indeed fall asleep after 5 minutes like I told them to in the GUI:
Code:
nanotube# cat standby_check
#!/usr/local/bin/bash
while [ 1 ]
do
  ada0_out=`camcontrol cmd ada0 -a "E5 00 00 00 00 00 00 00 00 00 00 00" -r -`
  ada1_out=`camcontrol cmd ada1 -a "E5 00 00 00 00 00 00 00 00 00 00 00" -r -`
  echo "ADA0: $ada0_out -- ADA1: $ada1_out"
  sleep 30
done
nanotube# ./standby_check
ADA0: 50 00 00 00 00 40 00 00 00 FF 00 -- ADA1: 50 00 00 00 00 40 00 00 00 FF 00
ADA0: 50 00 00 00 00 40 00 00 00 FF 00 -- ADA1: 50 00 00 00 00 40 00 00 00 FF 00
ADA0: 50 00 00 00 00 40 00 00 00 FF 00 -- ADA1: 50 00 00 00 00 40 00 00 00 FF 00
ADA0: 50 00 00 00 00 40 00 00 00 FF 00 -- ADA1: 50 00 00 00 00 40 00 00 00 FF 00
ADA0: 50 00 00 00 00 40 00 00 00 FF 00 -- ADA1: 50 00 00 00 00 40 00 00 00 FF 00
ADA0: 50 00 00 00 00 40 00 00 00 FF 00 -- ADA1: 50 00 00 00 00 40 00 00 00 FF 00
ADA0: 50 00 00 00 00 40 00 00 00 FF 00 -- ADA1: 50 00 00 00 00 40 00 00 00 FF 00
ADA0: 50 00 00 00 00 40 00 00 00 FF 00 -- ADA1: 50 00 00 00 00 40 00 00 00 FF 00
ADA0: 50 00 00 00 00 40 00 00 00 FF 00 -- ADA1: 50 00 00 00 00 40 00 00 00 FF 00
ADA0: 50 00 00 00 00 40 00 00 00 00 00 -- ADA1: 50 00 00 00 00 40 00 00 00 00 00
ADA0: 50 00 00 00 00 40 00 00 00 00 00 -- ADA1: 50 00 00 00 00 40 00 00 00 00 00
^C
nanotube#

Note how both drive started in a spun up state and after 9 checks (4.5 minutes) they went to a spun down state (the ZFS pool had been idle for a few seconds before I started the command).

I hope this is useful to someone out there. It beats listening with your ear glued to the drive, in the hopes of being able to hear the moment when the drive spins down.
 

sonisame72

Dabbler
Joined
Aug 14, 2011
Messages
25
For installs that use the AHCI driver to control the hard drives, it is not obvious how you can find out if a drive has actually spun down according to the configuration that you have set.

This post shows you how you can use the camcontrol command to find out the power state of a drive.

First you need to identify the drive you want to take a look at:
Code:
nanotube# camcontrol devlist
<ST1500DL003-9V16L CC32>       at scbus0 target 0 lun 0 (pass0,ada0)
<ST1500DL003-9V16L CC32>       at scbus2 target 0 lun 0 (pass1,ada1)
<USB 2.0 Flash Drive 5.00>     at scbus6 target 0 lun 0 (pass2,da0)

So on my system, ada0 and ada1 are my two harddrives that I'm interested in. I will inspect the power state of ada0.
Code:
nanotube# camcontrol cmd ada0 -a "E5 00 00 00 00 00 00 00 00 00 00 00" -r -
50 00 00 00 00 40 00 00 00 FF 00

Take a look at the 10th hexadecimal value in the output. If this says "FF", the drive is spinning, if it says "00" the drive is spun down. It's that easy!!

I wrote a little script that checks both of my drives every 30 seconds so I can see if they indeed fall asleep after 5 minutes like I told them to in the GUI:
Code:
nanotube# cat standby_check
#!/usr/local/bin/bash
while [ 1 ]
do
  ada0_out=`camcontrol cmd ada0 -a "E5 00 00 00 00 00 00 00 00 00 00 00" -r -`
  ada1_out=`camcontrol cmd ada1 -a "E5 00 00 00 00 00 00 00 00 00 00 00" -r -`
  echo "ADA0: $ada0_out -- ADA1: $ada1_out"
  sleep 30
done
nanotube# ./standby_check
ADA0: 50 00 00 00 00 40 00 00 00 FF 00 -- ADA1: 50 00 00 00 00 40 00 00 00 FF 00
ADA0: 50 00 00 00 00 40 00 00 00 FF 00 -- ADA1: 50 00 00 00 00 40 00 00 00 FF 00
ADA0: 50 00 00 00 00 40 00 00 00 FF 00 -- ADA1: 50 00 00 00 00 40 00 00 00 FF 00
ADA0: 50 00 00 00 00 40 00 00 00 FF 00 -- ADA1: 50 00 00 00 00 40 00 00 00 FF 00
ADA0: 50 00 00 00 00 40 00 00 00 FF 00 -- ADA1: 50 00 00 00 00 40 00 00 00 FF 00
ADA0: 50 00 00 00 00 40 00 00 00 FF 00 -- ADA1: 50 00 00 00 00 40 00 00 00 FF 00
ADA0: 50 00 00 00 00 40 00 00 00 FF 00 -- ADA1: 50 00 00 00 00 40 00 00 00 FF 00
ADA0: 50 00 00 00 00 40 00 00 00 FF 00 -- ADA1: 50 00 00 00 00 40 00 00 00 FF 00
ADA0: 50 00 00 00 00 40 00 00 00 FF 00 -- ADA1: 50 00 00 00 00 40 00 00 00 FF 00
ADA0: 50 00 00 00 00 40 00 00 00 00 00 -- ADA1: 50 00 00 00 00 40 00 00 00 00 00
ADA0: 50 00 00 00 00 40 00 00 00 00 00 -- ADA1: 50 00 00 00 00 40 00 00 00 00 00
^C
nanotube#

Note how both drive started in a spun up state and after 9 checks (4.5 minutes) they went to a spun down state (the ZFS pool had been idle for a few seconds before I started the command).

I hope this is useful to someone out there. It beats listening with your ear glued to the drive, in the hopes of being able to hear the moment when the drive spins down.

Awesome this scripts works and my drives do spindown..

Sonisame
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,970
What drives is this working for because my system only returns the following...

Code:
[Mark@freenas] /usr/test# ataidle -I 5 ada0
[Mark@freenas] /usr/test# ataidle -I 5 ada1
[Mark@freenas] /usr/test# ./standby_check.sh
ADA0: 50 00 00 00 00 00 00 00 00 00 00 -- ADA1: 50 00 00 00 00 00 00 00 00 00 00
ADA0: 50 00 00 00 00 00 00 00 00 00 00 -- ADA1: 50 00 00 00 00 00 00 00 00 00 00
ADA0: 50 00 00 00 00 00 00 00 00 00 00 -- ADA1: 50 00 00 00 00 00 00 00 00 00 00
ADA0: 50 00 00 00 00 00 00 00 00 00 00 -- ADA1: 50 00 00 00 00 00 00 00 00 00 00
ADA0: 50 00 00 00 00 00 00 00 00 00 00 -- ADA1: 50 00 00 00 00 00 00 00 00 00 00
ADA0: 50 00 00 00 00 00 00 00 00 00 00 -- ADA1: 50 00 00 00 00 00 00 00 00 00 00
ADA0: 50 00 00 00 00 00 00 00 00 00 00 -- ADA1: 50 00 00 00 00 00 00 00 00 00 00
ADA0: 50 00 00 00 00 00 00 00 00 00 00 -- ADA1: 50 00 00 00 00 00 00 00 00 00 00
ADA0: 50 00 00 00 00 00 00 00 00 00 00 -- ADA1: 50 00 00 00 00 00 00 00 00 00 00
ADA0: 50 00 00 00 00 00 00 00 00 00 00 -- ADA1: 50 00 00 00 00 00 00 00 00 00 00
ADA0: 50 00 00 00 00 00 00 00 00 00 00 -- ADA1: 50 00 00 00 00 00 00 00 00 00 00
^C
The drives did power down as indicated on the watts drawn and the spinning down noise.

Using build 7652 for this test, don't think that would matter but you never know what might have been patched somewhere.

EDIT: Here is what the identify command returns, if it helps any...

Code:
[Mark@freenas] /mnt# camcontrol identify ada0
pass1: <SAMSUNG HD204UI 1AQ10001> ATA-8 SATA 2.x device
pass1: 150.000MB/s transfers (SATA, UDMA5, PIO 8192bytes)

protocol              ATA/ATAPI-8 SATA 2.x
device model          SAMSUNG HD204UI
firmware revision     1AQ10001
serial number         S2H7J1AZC08730
WWN                   50024e9047c3f46
cylinders             16383
heads                 16
sectors/track         63
sector size           logical 512, physical 512, offset 0
LBA supported         268435455 sectors
LBA48 supported       3907029168 sectors
PIO supported         PIO4
DMA supported         WDMA2 UDMA6
media RPM             5400

Feature                      Support  Enabled   Value           Vendor
read ahead                     yes      yes
write cache                    yes      yes
flush cache                    yes      yes
overlap                        no
Tagged Command Queuing (TCQ)   no       no
Native Command Queuing (NCQ)   yes              32 tags
SMART                          yes      yes
microcode download             yes      yes
security                       yes      no
power management               yes      yes
advanced power management      yes      no      0/0x00
automatic acoustic management  yes      yes     254/0xFE        254/0xFE
media status notification      no       no
power-up in Standby            yes      no
write-read-verify              no       no
unload                         no       no
free-fall                      no       no
data set management (TRIM)     no
 

Durkatlon

Patron
Joined
Aug 19, 2011
Messages
414
So based on that it looks like the drives were already asleep when you started running the standby check script. Did you try "disturbing" the drives through another ssh shell by copying some data onto the pool?

The "E5" command requests the power state of the drive per the ATA spec. If an error occurred the final hex number should be non-zero. That doesn't appear to be the case with your drive.
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,970
Durk,
I spun the drives up and down in a separate SSH window while the script was running in a different window with no change. I'm not sure what's going on with these drives or if it's NanoBSD. I'll do some research. Many I'll try good ol'e beta-4 with this script.

-Mark
 

Letni

Explorer
Joined
Jan 22, 2012
Messages
63
I am running 8.0.3p1 and i'm running into the issue where I also am not seeing SATA drives attached to local AHCI controller completly power down, even though the FreeNAS GUI has all the drives to be configured to power down after 5 minutes.. It looks as if the highest drive (drive plugged into the last port) seems to be functional, but the others are NOT.. I have manually tried to set the timeout via ataidle -S , and it will immediately idle the drives, but as soon as I disturbe them from sleep, they remain spinning.. I have even tried rebooting several times after fiddling with the settings.. Here is my setup:

AMD Phenom
AMD 760 chipset motherboard
8 GB RAM
4 GB USB Boot device
Various SATA drives in a single ZFS RAID-Z pool.

I have also written a little better script here that may help determine what is spinning and what is not based on the above posts:


#!/bin/sh

camcontrol devlist | awk -F\( '{print $2'} | awk -F\, '{print $1}' |while read LINE
do
CM=$(camcontrol cmd $LINE -a "E5 00 00 00 00 00 00 00 00 00 00 00" -r - | awk '{print $10}')
if [ "$CM" = "FF" ] ; then
echo "$LINE: SPINNING"
elif [ "$CM" = "00" ] ; then
echo "$LINE: IDLE"
else
echo "$LINE: UNKNOWN"
fi
done
 

Letni

Explorer
Joined
Jan 22, 2012
Messages
63
Another Question I am pondering here (since I'm a n00b to ZFS) is it possible to utilize a single "ZFS" cache device ( a drive dedicated to a ZFS pool for read caching on ZFS- intended to be on SSD type devices) to act as an "always on" device that would work in conjunction to ataidle to allow all the other devices (data devices) in the pool to power down (via ataidle timeout) and have the cache drive more or less act as a "buffer" to comonly used blocks out on the actual storage devices. The net result would be that the ZFS pool devices have a higher chances of staying "idle / spun down" when basic AFP/CIFS/NFS/iSCSI reads are requested...

The idea would be a such:

Main RAID-Z Pool:
DRIVE 1: 3.5 inch 2-TB drive SATA (set to idle at 5 min)
DRIVE 2: 3.5 inch 2-TB drive SATA (set to idle at 5 min)
DRIVE 3: 3.5 inch 2-TB drive SATA (set to idle at 5 min)
DRIVE 4: 3.5 inch 2-TB drive SATA (set to idle at 5 min)
Cache Device:
DRIVE 5: 2.5 inch 250-GB SATA drive (set to never idle)

I could see this being very useful for us who use FreeNAS at home and power consumption is a key factor on how our home NAS environments are set up, but i'm not familiar of this configuration would result any benefit to keeping larger 3.5 inch drives powered down (aside from the spindown issue I also currently am seeing anyway)
 

firestorm99

Dabbler
Joined
Sep 17, 2011
Messages
22
Code:
[root@freenas] ~# camcontrol devlist
<NECVMWar VMware IDE CDR10 1.00>   at scbus1 target 0 lun 0 (cd0,pass0)
<VMware Virtual disk 1.0>          at scbus2 target 0 lun 0 (da0,pass1)
<ATA WDC WD20EARS-00M AB51>        at scbus3 target 0 lun 0 (da1,pass2)
<ATA WDC WD20EARS-00M AB51>        at scbus3 target 1 lun 0 (da2,pass3)
<ATA WDC WD20EARS-00M AB51>        at scbus3 target 2 lun 0 (da3,pass4)
<ATA WDC WD20EARS-00M AB51>        at scbus3 target 3 lun 0 (da4,pass5)
<ATA WDC WD20EARS-00M AB51>        at scbus3 target 4 lun 0 (da5,pass6)
[root@freenas] ~# camcontrol cmd da3 -a "E5 00 00 00 00 00 00 00 00 00 00 00" -r -
camcontrol: error sending comm



I get this, if i pass the command. Does anyone have a clue why?
In my case FreeNAS 8.0.3 runs on an ESXI server. The Raid device (LSI 1068 based Dell) is passedthrough via directed I/O.


This is as well dealing about it: http://forums.freebsd.org/showthread.php?t=22152



Thanks in advance..


Edit: Seems this is executed successfully...
Code:
[root@freenas] ~# camcontrol stop da2
Unit stopped successfully


Drives are stopping, i get about 6 W difference for 5 wd green 2TB drives.

But why are the settings in the webinterface not working?
 

lrusak

Explorer
Joined
Dec 20, 2011
Messages
56
I am running 8.0.3p1 and i'm running into the issue where I also am not seeing SATA drives attached to local AHCI controller completly power down, even though the FreeNAS GUI has all the drives to be configured to power down after 5 minutes.. It looks as if the highest drive (drive plugged into the last port) seems to be functional, but the others are NOT.. I have manually tried to set the timeout via ataidle -S , and it will immediately idle the drives, but as soon as I disturbe them from sleep, they remain spinning.. I have even tried rebooting several times after fiddling with the settings.. Here is my setup:

AMD Phenom
AMD 760 chipset motherboard
8 GB RAM
4 GB USB Boot device
Various SATA drives in a single ZFS RAID-Z pool.

I have also written a little better script here that may help determine what is spinning and what is not based on the above posts:


#!/bin/sh

camcontrol devlist | awk -F\( '{print $2'} | awk -F\, '{print $1}' |while read LINE
do
CM=$(camcontrol cmd $LINE -a "E5 00 00 00 00 00 00 00 00 00 00 00" -r - | awk '{print $10}')
if [ "$CM" = "FF" ] ; then
echo "$LINE: SPINNING"
elif [ "$CM" = "00" ] ; then
echo "$LINE: IDLE"
else
echo "$LINE: UNKNOWN"
fi
done


Thanks for this, I was using something similar before but this is better. I modified it a little though to this:
Code:
#!/bin/sh

while [ 1 ]
do

camcontrol devlist | awk -F\( '{print $2'} | awk -F\, '{print $1}' |while read LINE
do
CM=$(camcontrol cmd $LINE -a "E5 00 00 00 00 00 00 00 00 00 00 00" -r - | awk '{print $10}')
if [ "$CM" = "FF" ] ; then
echo "$LINE: SPINNING"
elif [ "$CM" = "00" ] ; then
echo "$LINE: IDLE"
else 
echo "$LINE: UNKNOWN"
fi
done

sleep 30
done

I have a similar setup

MSI 785gm-p45
6 Seagate ST2000DL003-9VT166 in a raid Z2

now when I used this script I get
ada0: SPINNING
ada1: SPINNING
ada2: SPINNING
ada3: SPINNING
ada5: IDLE
ada6: IDLE

It seems like ada5 & 6 never spin up?
I've also noticed that the firmware on the HDDs are different, ada0-3 are CC32, and ada5&6 are CC3C
so I wonder what the difference is here. (ada4 is a separate drive i use to run programs, sabnzbd, sick beard, couch potato, etc)
 

xbmcg

Explorer
Joined
Feb 6, 2012
Messages
79
Nice script. However, my drives are always "IDLE" - even if I read or write data.

Very strange, maybe the heads are rotating around the sleeping disk ;-)
 

xbmcg

Explorer
Joined
Feb 6, 2012
Messages
79
Nice script. However, my drives are always "IDLE" - even if I read or write data.

Very strange, maybe the heads are rotating around the sleeping disk ;-)

Is there another way to find out, if the drives are configured the right way and if they are spinning?

Code:
[root@freenas] /tmp# camcontrol identify ada0
pass1: <WDC WD3200BEKT-00F3T0 11.01A11> ATA-8 SATA 2.x device
pass1: 150.000MB/s transfers (SATA, UDMA5, PIO 8192bytes)

protocol              ATA/ATAPI-8 SATA 2.x
device model          WDC WD3200BEKT-00F3T0
firmware revision     11.01A11
serial number         WD-WXMY*********
WWN                   5001************
cylinders             16383
heads                 16
sectors/track         63
sector size           logical 512, physical 512, offset 0
LBA supported         268435455 sectors
LBA48 supported       625142448 sectors
PIO supported         PIO4
DMA supported         WDMA2 UDMA6
media RPM             7200

Feature                      Support  Enabled   Value           Vendor
read ahead                     yes      yes
write cache                    yes      yes
flush cache                    yes      yes
overlap                        no
Tagged Command Queuing (TCQ)   no       no
Native Command Queuing (NCQ)   yes              32 tags
SMART                          yes      yes
microcode download             yes      yes
security                       yes      no
power management               yes      yes
advanced power management      yes      no      254/0xFE
automatic acoustic management  yes      no      254/0xFE        128/0x80
media status notification      no       no
power-up in Standby            no       no
write-read-verify              no       no
unload                         yes      yes
free-fall                      no       no
data set management (TRIM)     no


There is no change in the drive settings, when GUI is used to configure the drive - APM is turned off, AAM is turned off too.
 

lrusak

Explorer
Joined
Dec 20, 2011
Messages
56
Nice script. However, my drives are always "IDLE" - even if I read or write data.

Very strange, maybe the heads are rotating around the sleeping disk ;-)

what disks are you using? maybe they aren't recognized properly, I had the same issue sort of. I ended changing my drives from AHCI to IDE in the BIOS and it seemed to of solved my problem in my previous post.

Check,

Code:
dmesg | grep ada

and
Code:
camcontrol devlist


to see if everything is recognized correctly.
 

xbmcg

Explorer
Joined
Feb 6, 2012
Messages
79
... my fault.
Your script works great.

I have 2 x 2.5" WD3200BEKT 7200rpm SATAII drives.
I set it to 5 Minutes in the UI to watch them spinning down when going to IDLE.

The effect was, that they spin down after 5 seconds, so they appear always IDLE.

I found out while transfering a large file, so they go online, and after file was done, immediately back IDLE.

I would assume it a "feature" .... So I set up the time much higher now to prevent them spin down after each access.
 

lrusak

Explorer
Joined
Dec 20, 2011
Messages
56
... my fault.
Your script works great.

I have 2 x 2.5" WD3200BEKT 7200rpm SATAII drives.
I set it to 5 Minutes in the UI to watch them spinning down when going to IDLE.

The effect was, that they spin down after 5 seconds, so they appear always IDLE.

I found out while transfering a large file, so they go online, and after file was done, immediately back IDLE.

I would assume it a "feature" .... So I set up the time much higher now to prevent them spin down after each access.

I set my spin down time to 30 minutes, just to prevent unnecessary amounts of spin ups and spin downs. I have also set my downloading programs to search every 4 hours to limit the mount the drives get spun up.

also, I edited my script to show the time, just so you know how much time has passed since you started. you could also change the 'sleep' value of the script if you wanted to change how often the script prints out

Code:
#!/bin/sh

while [ 1 ]
echo ""
date | awk '{print "time: "$4}'

do

camcontrol devlist | awk -F\( '{print $2'} | awk -F\, '{print $1}' |while read LINE
do
CM=$(camcontrol cmd $LINE -a "E5 00 00 00 00 00 00 00 00 00 00 00" -r - | awk '{print $10}')
if [ "$CM" = "FF" ] ; then
echo "$LINE: SPINNING"
elif [ "$CM" = "00" ] ; then
echo "$LINE: IDLE"
else 
echo "$LINE: UNKNOWN"
fi
done

sleep 30
done
 

tingo

Contributor
Joined
Nov 5, 2011
Messages
137
FWIW, I get a strange result on my raidz pool (two drives always says 'idle'), here is the info:
the pool
Code:
[root@kg-f3] ~# zpool status
  pool: zstore
 state: ONLINE
 scrub: resilver completed after 2h32m with 0 errors on Mon May 21 01:15:45 2012
config:

	NAME        STATE     READ WRITE CKSUM
	zstore      ONLINE       0     0     0
	  raidz1    ONLINE       0     0     0
	    ada0p2  ONLINE       0     0     0
	    ada1p2  ONLINE       0     0     0
	    ada2p2  ONLINE       0     0     0
	    ada3p2  ONLINE       0     0     0  344G resilvered
	    ada4p2  ONLINE       0     0     0
	    ada5p2  ONLINE       0     0     0

errors: No known data errors


the drives:
Code:
[root@kg-f3] ~# camcontrol devlist
<SAMSUNG HN-M101MBB 2AR10001>      at scbus0 target 0 lun 0 (ada0,pass0)
<SAMSUNG HN-M101MBB 2AR10001>      at scbus1 target 0 lun 0 (ada1,pass1)
<SAMSUNG HN-M101MBB 2AR10001>      at scbus2 target 0 lun 0 (ada2,pass2)
<SAMSUNG HN-M101MBB 2AR10001>      at scbus3 target 0 lun 0 (ada3,pass3)
<SAMSUNG HN-M101MBB 2AR10001>      at scbus4 target 0 lun 0 (ada4,pass4)
<SAMSUNG HN-M101MBB 2AR10001>      at scbus4 target 1 lun 0 (ada5,pass5)
<Verbatim STORE N GO 3.00>         at scbus6 target 0 lun 0 (da0,pass6)

The test:
Code:
[root@kg-f3] ~# camcontrol cmd ada0 -a "E5 00 00 00 00 00 00 00 00 00 00 00" -r -
50 00 00 00 00 00 00 00 00 FF 00
[root@kg-f3] ~# camcontrol cmd ada1 -a "E5 00 00 00 00 00 00 00 00 00 00 00" -r -
50 00 00 00 00 00 00 00 00 FF 00
[root@kg-f3] ~# camcontrol cmd ada2 -a "E5 00 00 00 00 00 00 00 00 00 00 00" -r -
50 00 00 00 00 00 00 00 00 FF 00
[root@kg-f3] ~# camcontrol cmd ada3 -a "E5 00 00 00 00 00 00 00 00 00 00 00" -r -
50 00 00 00 00 00 00 00 00 FF 00
[root@kg-f3] ~# camcontrol cmd ada4 -a "E5 00 00 00 00 00 00 00 00 00 00 00" -r -
50 00 00 00 00 00 00 00 00 00 00
[root@kg-f3] ~# camcontrol cmd ada5 -a "E5 00 00 00 00 00 00 00 00 00 00 00" -r -
50 00 00 00 00 00 00 00 00 00 00

Is this "e5 ..." command documented anywhere?
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,970
What version of FreeNAS are you running?
FWIW, I get a strange result on my raidz pool (two drives always says 'idle'), here is the info:
the pool
Code:
[root@kg-f3] ~# zpool status
  pool: zstore
 state: ONLINE
 scrub: resilver completed after 2h32m with 0 errors on Mon May 21 01:15:45 2012
config:

	NAME        STATE     READ WRITE CKSUM
	zstore      ONLINE       0     0     0
	  raidz1    ONLINE       0     0     0
	    ada0p2  ONLINE       0     0     0
	    ada1p2  ONLINE       0     0     0
	    ada2p2  ONLINE       0     0     0
	    ada3p2  ONLINE       0     0     0  344G resilvered
	    ada4p2  ONLINE       0     0     0
	    ada5p2  ONLINE       0     0     0

errors: No known data errors


the drives:
Code:
[root@kg-f3] ~# camcontrol devlist
<SAMSUNG HN-M101MBB 2AR10001>      at scbus0 target 0 lun 0 (ada0,pass0)
<SAMSUNG HN-M101MBB 2AR10001>      at scbus1 target 0 lun 0 (ada1,pass1)
<SAMSUNG HN-M101MBB 2AR10001>      at scbus2 target 0 lun 0 (ada2,pass2)
<SAMSUNG HN-M101MBB 2AR10001>      at scbus3 target 0 lun 0 (ada3,pass3)
<SAMSUNG HN-M101MBB 2AR10001>      at scbus4 target 0 lun 0 (ada4,pass4)
<SAMSUNG HN-M101MBB 2AR10001>      at scbus4 target 1 lun 0 (ada5,pass5)
<Verbatim STORE N GO 3.00>         at scbus6 target 0 lun 0 (da0,pass6)

The test:
Code:
[root@kg-f3] ~# camcontrol cmd ada0 -a "E5 00 00 00 00 00 00 00 00 00 00 00" -r -
50 00 00 00 00 00 00 00 00 FF 00
[root@kg-f3] ~# camcontrol cmd ada1 -a "E5 00 00 00 00 00 00 00 00 00 00 00" -r -
50 00 00 00 00 00 00 00 00 FF 00
[root@kg-f3] ~# camcontrol cmd ada2 -a "E5 00 00 00 00 00 00 00 00 00 00 00" -r -
50 00 00 00 00 00 00 00 00 FF 00
[root@kg-f3] ~# camcontrol cmd ada3 -a "E5 00 00 00 00 00 00 00 00 00 00 00" -r -
50 00 00 00 00 00 00 00 00 FF 00
[root@kg-f3] ~# camcontrol cmd ada4 -a "E5 00 00 00 00 00 00 00 00 00 00 00" -r -
50 00 00 00 00 00 00 00 00 00 00
[root@kg-f3] ~# camcontrol cmd ada5 -a "E5 00 00 00 00 00 00 00 00 00 00 00" -r -
50 00 00 00 00 00 00 00 00 00 00

Is this "e5 ..." command documented anywhere?
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,970
Different way to test your drives

I popped this together this morning so some of you can see if this works for you. The two scripts are almost identical, basically because I like to make code as reusable as possible. This "should" work on all SMART compatible drives. I don't know if this works on SAS or SCSI because I don't have that hardware to test it.

The first script is for a single drive that is specified in the command line. Example: sh chkidle.sh /dev/ada0
Code:
#!/usr/local/bin/sh
#
# Place this in /conf/base/etc/ in order to have it after a reboot.
# Call: sh chkidle.sh /dev/ada0
# switch1 is the drive to check (passed parameter)
switch1=$1

### Run SMART Check
testidle()
{
smartctl -a -n standby ${switch1} > /var/tempfile

# If chkdrive returns a value 2 for sleeping
if [ $? -eq "2" ]
then
echo "${switch1} Drive is Idle."
#rm /var/tempfile
return 0
fi

# if drive returns a value other than 0, error.
if [ $? -ne "0" ]
then
echo "****************"
echo "There is a drive error.  Check your ${switch1} drive for proper operation."
echo "****************"
return 0
fi
echo "${switch1} Drive is Not Idle."
}

# Lets test the drive

echo "Checking your drive..."
  testidle

# Cleanup our tiny mess
  rm /var/tempfile

exit 0



My second script covers all the drives at once and you will have to edit the drives to match your setup.
It is executed as follows: sh chkidleall.sh
Code:
#!/usr/local/bin/sh
#
# Place this in /conf/base/etc/ in order to have it after a reboot.
# Call: sh chkidleall.sh
# switch1 is the drive to check (passed parameter)

### Run SMART Check
testidle()
{
smartctl -a -n standby ${switch1} > /var/tempfile

# If chkdrive returns a value 2 for sleeping
if [ $? -eq "2" ]
then
echo "${switch1} Drive is Idle."
return 0
fi

# if drive returns a value other than 0, error.
if [ $? -ne "0" ]
then
echo "****************"
echo "There is a drive error.  Check your ${switch1} drive for proper operation."
echo "****************"
return 0
fi
echo "${switch1} Drive is Not Idle."
}

# Lets test the drives
# You can see how this was setup, just repeat as needed.

echo "Checking your drives..."
  switch1="/dev/ada0"
  testidle
  switch1="/dev/ada1"
  testidle
  switch1="/dev/ada2"
  testidle
  switch1="/dev/ada3"
  testidle

# Cleanup our tiny mess
rm /var/tempfile

exit 0


These are basically the same program, very slight modifications. If it works, why change it?

I hope this helps.

-Mark
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,970
No problem. The only reason I ask is if you are using the new 8.2.x versions and using a plugin, well you could be spinning up your drives frequently. You should give one of my script above a try. Good Luck.
 

tingo

Contributor
Joined
Nov 5, 2011
Messages
137
My second script covers all the drives at once and you will have to edit the drives to match your setup.
It is executed as follows: sh chkidleall.sh
These are basically the same program, very slight modifications. If it works, why change it?
FWIW.
Sorry, it doesn't work any better here:
Code:
[root@kg-f3] ~# sh /mnt/zstore/home-tingo/bin/chkidleall.sh
Checking your drives...
/dev/ada0 Drive is Not Idle.
/dev/ada1 Drive is Not Idle.
/dev/ada2 Drive is Not Idle.
/dev/ada3 Drive is Not Idle.
/dev/ada4 Drive is Idle.
/dev/ada5 Drive is Idle.

Still running FreeNAS-8.0.4-RELEASE-p2-x64 (11367) and still with these drives:

[root@kg-f3] ~# camcontrol devlist
<SAMSUNG HN-M101MBB 2AR10001> at scbus0 target 0 lun 0 (ada0,pass0)
<SAMSUNG HN-M101MBB 2AR10001> at scbus1 target 0 lun 0 (ada1,pass1)
<SAMSUNG HN-M101MBB 2AR10001> at scbus2 target 0 lun 0 (ada2,pass2)
<SAMSUNG HN-M101MBB 2AR10001> at scbus3 target 0 lun 0 (ada3,pass3)
<SAMSUNG HN-M101MBB 2AR10001> at scbus4 target 0 lun 0 (ada4,pass4)
<SAMSUNG HN-M101MBB 2AR10001> at scbus4 target 1 lun 0 (ada5,pass5)
<Verbatim STORE N GO 3.00> at scbus6 target 0 lun 0 (da0,pass6)
 
Top