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

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

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
8,258
You may have already tried this but if not... Reboot FreeNAS and then run the script.

Do you have APM or Standby values set for those two drives? How about deleting those settings and turn off your machine and then power it back on, not a reboot. You want to cycle power to the hard drives to clear any previous settings.

If you have no Standby or APM settings the drives should remain spinning at all times under FreeNAS 8.0.4. If you still get a message that the drives are idle then you must be using a separate controller or different controller on the motherboard that isn't passing the information properly. If this is true then my concern would be that your drives might run all the time and you may not desire that. Please list your hard drive controller card if this is the case and the mother board you are using. I may not be able to help you just because I don't have any hardware like that to test on.

Something else you could try...
Type: smartctl -a /dev/ada5 and see what it tells you. If the drive is actually spinning the complete results will be quick. If there is a pause during the operation then the drive was spinning up. Pay attention to if the drive spins right back down. If it spins right back down you likely have APM set at 127 or below which is not a good setting, just disable it or you will kill your drives.

Any details or observations you can provide will help.
 

tingo

FreeNAS Experienced
Joined
Nov 5, 2011
Messages
137
Do you have APM or Standby values set for those two drives? How about deleting those settings and turn off your machine and then power it back on, not a reboot. You want to cycle power to the hard drives to clear any previous settings.
No. All drives are the same, and I have not "set" anything for any drive.

joeschmuck said:
If you have no Standby or APM settings the drives should remain spinning at all times under FreeNAS 8.0.4. If you still get a message that the drives are idle then you must be using a separate controller or different controller on the motherboard that isn't passing the information properly. If this is true then my concern would be that your drives might run all the time and you may not desire that. Please list your hard drive controller card if this is the case and the mother board you are using. I may not be able to help you just because I don't have any hardware like that to test on.
AFAIK, this motherboard (Asus E35M1-I) only has one controller. But you might be on to something. From dmesg:
Code:
[root@kg-f3] ~# dmesg | grep ahci
ahci0: <ATI IXP700 AHCI SATA controller> port 0xf190-0xf197,0xf180-0xf183,0xf170-0xf177,0xf160-0xf163,0xf150-0xf15f mem 0xfeb4b000-0xfeb4b3ff irq 19 at device 17.0 on pci0
ahci0: [ITHREAD]
ahci0: AHCI v1.20 with 4 6Gbps ports, Port Multiplier supported
ahcich0: <AHCI channel> at channel 0 on ahci0
ahcich0: [ITHREAD]
ahcich1: <AHCI channel> at channel 1 on ahci0
ahcich1: [ITHREAD]
ahcich2: <AHCI channel> at channel 2 on ahci0
ahcich2: [ITHREAD]
ahcich3: <AHCI channel> at channel 3 on ahci0
ahcich3: [ITHREAD]
ada0 at ahcich0 bus 0 scbus0 target 0 lun 0
ada1 at ahcich1 bus 0 scbus1 target 0 lun 0
ada2 at ahcich2 bus 0 scbus2 target 0 lun 0
ada3 at ahcich3 bus 0 scbus3 target 0 lun 0
[root@kg-f3] ~# dmesg | grep ata
atapci0: <ATI IXP700/800 UDMA133 controller> port 0x1f0-0x1f7,0x3f6,0x170-0x177,0x376,0xf100-0xf10f irq 17 at device 20.1 on pci0
ata0: <ATA channel 0> on atapci0
ata0: [ITHREAD]
ata1: <ATA channel 1> on atapci0
ata1: [ITHREAD]
ada4 at ata0 bus 0 scbus4 target 0 lun 0
ada5 at ata0 bus 0 scbus4 target 1 lun 0

I wonder why FreeBSD / FreeNAS detects it like that? In the BIOS, everything looks the same.

joeschmuck said:
Something else you could try...
Type: smartctl -a /dev/ada5 and see what it tells you. If the drive is actually spinning the complete results will be quick. If there is a pause during the operation then the drive was spinning up. Pay attention to if the drive spins right back down. If it spins right back down you likely have APM set at 127 or below which is not a good setting, just disable it or you will kill your drives.
Perhaps my initial message was unclear; all drives are spinning, all the time. It is just the reporting / detection that is wrong.
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
8,258
Do you have the latest BIOS version (1308), came out 2 months ago. And your motherboard is popular at this site, maybe you could find someone who has one and see what they have to say.

I downloaded the user manual and it makes no mention of two SATA controllers but I typically have seen one controller for 4 ports and a separate controller for the other 2 ports. Not sure what is going on with your board but as you posted, clearly there is something going on.

I assume your BIOS is set to AHCI and this setting affects the entire group of SATA ports? If ports 5 & 6 are separate then that would be your issue and I would say you have two controllers. Even under IDE mode I would think SMART would work, even with an older BIOS.

Well I hope the solution is a newer BIOS, that would make it simple.

-Mark
 

tingo

FreeNAS Experienced
Joined
Nov 5, 2011
Messages
137
Do you have the latest BIOS version (1308), came out 2 months ago. And your motherboard is popular at this site, maybe you could find someone who has one and see what they have to say.
Interesting. Where did you find this BIOS version. On Asus pages for the E35M1-I I only find version 0807.

I downloaded the user manual and it makes no mention of two SATA controllers but I typically have seen one controller for 4 ports and a separate controller for the other 2 ports. Not sure what is going on with your board but as you posted, clearly there is something going on.

joeschmuck said:
I assume your BIOS is set to AHCI and this setting affects the entire group of SATA ports?
Yes and yes. All ports look "equal" in the BIOS, AFAICT.
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
8,258
Sorry about the BIOS version mix-up. I was looking at the Deluxe model but the 0807 came out at the same time so that would apparently be the proper version for your board.

I unfortunately don't know what to tell you. There is additional troubleshooting that you could do but you may risk damage to your data so it's likely not worth it. The only other thing I could suggest is to post a thread for folks who have this MB and ask if they too have this problem or if there is something different about the controller. I wish I had one to play with and figure it out as well.

If you figure it out, please post what you did to make it report properly.

-Mark
 

calgarychris

FreeNAS Experienced
Joined
Aug 27, 2011
Messages
115
Hi,

I'm afraid I've got a very basic question - I've tried googling and I'm still confused. I'd like to try your script but I don't know how to even get to the stage of writing the script. Is there a way to copy and paste the code that you've written joeschmuck? I ssh into my box and then I've tried su and su - and entered the first line !/usr/local/bin/sh to no avail. I've tried with and without the ! ...I either get "Command not found" or "Event not found". If I type cd usr/local/bin I can then type sh and get a # prompt which presumably is on the right track, but what am I doing wrong? Is there an easy way to paste from your post into a terminal window (using a Mac)?

Sorry to bother you with what will no doubt be an easy one, but if you could assist it would be greatly appreciated - thanks!
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
8,258
Sure thing... type ee to start the editor. Press Escape key to exit and save. That should get you started.
 

calgarychris

FreeNAS Experienced
Joined
Aug 27, 2011
Messages
115
Haha, thanks! Your idiot proof "Setup SMART reporting via email" had that critical bit in it for us idiots! Thanks again, I knew it was something stupid, I just kept thinking sh was the editor...Works a charm - my drives won't idle, but at least the reporting tells me that!

Cheers!
 

huberte

Newbie
Joined
Sep 20, 2011
Messages
87
I do have an error :

Code:
[root@freenas] ~# sh chkidle.sh /dev/ada0
: not found
: not found
: not found
chkidle.sh: 40: Syntax error: end of file unexpected (expecting "then")

 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
8,258
I do have an error :

Code:
[root@freenas] ~# sh chkidle.sh /dev/ada0
: not found
: not found
: not found
chkidle.sh: 40: Syntax error: end of file unexpected (expecting "then")

I assume you have double checked the code to ensure it is correct? Where did you place this script? Not in a jail, right. I'm not sure it would work in a jail, I haven't tested it there.
 

huberte

Newbie
Joined
Sep 20, 2011
Messages
87
I assume you have double checked the code to ensure it is correct? Where did you place this script? Not in a jail, right. I'm not sure it would work in a jail, I haven't tested it there.
I did copy chkidle.sh in root and in /conf/base/etc/

Have this code :

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
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
8,258
What happens if you run this command:
Code:
smartctl -a -n standby /dev/ada0
 

huberte

Newbie
Joined
Sep 20, 2011
Messages
87
What happens if you run this command:
Code:
smartctl -a -n standby /dev/ada0
Device is in STANDBY mode, exit (2)

EDIT : I'm almost sure they're spinning, and not idling. My cifs is responding immediatly, hard drives are (very) hot and I heard them
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
8,258
If your drives are always spinning then you should not have seen this exit code if it properly supported smartctl. Some drives do not report properly normally because of the controller.

You will not be able to use this script to test if your drive are spun down. Thiere is another thread here, it's a bit more complex but it may work. I don't know where it's located of the top of my head but it pulls drive register data to see if the drive is spinning.

You can try the same command but remove the -n standby "smartctl -a /dev/ada0" and if it doesn't return a list of information then you will not be able to talk to your drives using the smartctl.
 

huberte

Newbie
Joined
Sep 20, 2011
Messages
87
This I have :

Code:
smartctl 5.42 2011-10-20 r3458 [FreeBSD 8.2-RELEASE-p9 amd64] (local build)
Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net

=== START OF INFORMATION SECTION ===
Model Family:     Seagate Barracuda Green (Adv. Format)
Device Model:     ST1500DL003-9VT16L
Serial Number:    5YD5N239
LU WWN Device Id: 5 000c50 0440536b3
Firmware Version: CC3C
User Capacity:    1,500,301,910,016 bytes [1.50 TB]
Sector Sizes:     512 bytes logical, 4096 bytes physical
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   8
ATA Standard is:  ATA-8-ACS revision 4
Local Time is:    Sun Sep 23 19:22:40 2012 AST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

General SMART Values:
Offline data collection status:  (0x82) Offline data collection activity
                                        was completed without error.
                                        Auto Offline Data Collection: Enabled.
Self-test execution status:      (   0) The previous self-test routine completed
                                        without error or no self-test has ever
                                        been run.
Total time to complete Offline
data collection:                (  623) seconds.
Offline data collection
capabilities:                    (0x7b) SMART execute Offline immediate.
                                        Auto Offline data collection on/off support.
                                        Suspend Offline collection upon new
                                        command.
                                        Offline surface scan supported.
                                        Self-test supported.
                                        Conveyance Self-test supported.
                                        Selective Self-test supported.
SMART capabilities:            (0x0003) Saves SMART data before entering
                                        power-saving mode.
                                        Supports SMART auto save timer.
Error logging capability:        (0x01) Error logging supported.
                                        General Purpose Logging supported.
Short self-test routine
recommended polling time:        (   1) minutes.
Extended self-test routine
recommended polling time:        ( 255) minutes.
Conveyance self-test routine
recommended polling time:        (   2) minutes.
SCT capabilities:              (0x30b7) SCT Status supported.
                                        SCT Feature Control supported.
                                        SCT Data Table supported.

SMART Attributes Data Structure revision number: 10
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x000f   115   099   006    Pre-fail  Always       -       88859896
  3 Spin_Up_Time            0x0003   097   092   000    Pre-fail  Always       -       0
  4 Start_Stop_Count        0x0032   100   100   020    Old_age   Always       -       78
  5 Reallocated_Sector_Ct   0x0033   100   100   036    Pre-fail  Always       -       0
  7 Seek_Error_Rate         0x000f   060   060   030    Pre-fail  Always       -       1079267
  9 Power_On_Hours          0x0032   100   100   000    Old_age   Always       -       339
 10 Spin_Retry_Count        0x0013   100   100   097    Pre-fail  Always       -       0
 12 Power_Cycle_Count       0x0032   100   100   020    Old_age   Always       -       8
183 Runtime_Bad_Block       0x0032   100   100   000    Old_age   Always       -       0
184 End-to-End_Error        0x0032   100   100   099    Old_age   Always       -       0
187 Reported_Uncorrect      0x0032   100   100   000    Old_age   Always       -       0
188 Command_Timeout         0x0032   100   100   000    Old_age   Always       -       0
189 High_Fly_Writes         0x003a   100   100   000    Old_age   Always       -       0
190 Airflow_Temperature_Cel 0x0022   057   054   045    Old_age   Always       -       43 (Min/Max 35/44)
191 G-Sense_Error_Rate      0x0032   100   100   000    Old_age   Always       -       0
192 Power-Off_Retract_Count 0x0032   100   100   000    Old_age   Always       -       6
193 Load_Cycle_Count        0x0032   100   100   000    Old_age   Always       -       78
194 Temperature_Celsius     0x0022   043   046   000    Old_age   Always       -       43 (0 24 0 0 0)
195 Hardware_ECC_Recovered  0x001a   019   006   000    Old_age   Always       -       88859896
197 Current_Pending_Sector  0x0012   100   100   000    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0010   100   100   000    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x003e   200   200   000    Old_age   Always       -       0
240 Head_Flying_Hours       0x0000   100   253   000    Old_age   Offline      -       4191888081235
241 Total_LBAs_Written      0x0000   100   253   000    Old_age   Offline      -       1809810849
242 Total_LBAs_Read         0x0000   100   253   000    Old_age   Offline      -       28389223

SMART Error Log Version: 1
No Errors Logged

SMART Self-test log structure revision number 1
Num  Test_Description    Status                  Remaining  LifeTime(hours)  LBA_of_first_error
# 1  Extended offline    Interrupted (host reset)      50%       311         -

SMART Selective self-test log data structure revision number 1
 SPAN  MIN_LBA  MAX_LBA  CURRENT_TEST_STATUS
    1        0        0  Not_testing
    2        0        0  Not_testing
    3        0        0  Not_testing
    4        0        0  Not_testing
    5        0        0  Not_testing
Selective self-test flags (0x0):
  After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
8,258
So do this and you can be certain that the drive you are testing is spinning...

Do the smartctl -a /dev/ada0
After that output do the smartctl -a -n standby /dev/ada0
If it still says the drive is in standby, exit 2, then you know for a fact that you cannot use this method to detect if the drive is sleeping or not.

I'm still unsure what was going on with the script in which if failed so badly but that really doesn't matter now.

Good Luck.
 

huberte

Newbie
Joined
Sep 20, 2011
Messages
87
S
If it still says the drive is in standby, exit 2, then you know for a fact that you cannot use this method to detect if the drive is sleeping or not.
Thanks

Exactly ! this is the case with all my drives, is it because of my mobo's chipset ?

I'll post another thread in Noob section to see why my drives do not stop
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
8,258

anika200

FreeNAS Experienced
Joined
Mar 18, 2013
Messages
112
Thanks

Exactly ! this is the case with all my drives, is it because of my mobo's chipset ?

I'll post another thread in Noob section to see why my drives do not stop
Have you checked the motherboard bios settings to see if you have it set to allow spin down of hard drives? Also, some motherboards have a setting to allow smart harddrive reporting on or off.
 

anika200

FreeNAS Experienced
Joined
Mar 18, 2013
Messages
112
I have just tried the last couple of smartctl tests and my mobo fails at this as well. Smartctl reports all drives are spun down but I have torrents running, is this possible? Maybe Freenas and Transmission keep all this activity in memory??
 
Top