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.

twisted

Newbie
Joined
Sep 12, 2012
Messages
23
I'm trying to see if my disks will spin down after a period of time. So far no good. Is it possible to see which process is using the disks? Running the script I just get this.

Code:
camcontrol: error sending command
da0: UNKNOWN
ada0: SPINNING
ada1: SPINNING
ada2: SPINNING
ada3: SPINNING
camcontrol: error sending command
da0: UNKNOWN


da0 is my USB key that FreeNAS is running from I assume.

I have "Enable powerd (Power Saving Daemon)" enabled in the advanced settings. For each disk I have "HDD Standby" set to 5. I have Advanced Power Management disabled for all. Acoustic Level disabled. SMART enabled. Extra smart options are "-m root".

All drives are the same, info from camcontrol below.

Code:
pass0: <WDC WD30EZRX-00DC0B0 80.00A80> ATA-9 SATA 3.x device
pass0: 300.000MB/s transfers (SATA 2.x, UDMA6, PIO 8192bytes)
 
protocol              ATA/ATAPI-9 SATA 3.x
device model          WDC WD30EZRX-00DC0B0
firmware revision    80.00A80
serial number        WD-WCC###
WWN                  5001###
cylinders            16383
heads                16
sectors/track        63
sector size          logical 512, physical 4096, offset 0
LBA supported        268435455 sectors
LBA48 supported      5860533168 sectors
PIO supported        PIO4
DMA supported        WDMA2 UDMA6
 
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      no      no
automatic acoustic management  no      no
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 (DSM/TRIM) no
Host Protected Area (HPA)      yes      no      5860533168/5860533168
HPA - Security                no


I've got minidlna and PLEX installed. Apart from that I've got a ZFS RAID10 mirror setup.
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
8,256
Here is how you can test if your system does support spinning down the drives...

At the shell window (or SSH is what I prefer)
Code:
smartctl -a /dev/ada0
Record the Start Stop Count value (typically item 4 in the list).

Type the following to force your drive into standby every 5 minutes after it's not in standby:
Code:
ataidle -S 5 /dev/ada0


And now check to see if it's in Standby:
Code:
smartctl -a -n standby /dev/ada0

If it comes back with an exit code of 2, then it is in standby.

And to prove it:
Code:
smartctl -a /dev/ada0

Now compare the Start Stop Count value. If it incremented then your drive did go into standby.

All this proves is the drive can spin down. Now since you already have these spindown values set in the GUI, record all the Start Stop Counts for each drive and after 10 minutes of inactivity check to see if the count has changed. If it didn't, disconnect the Ethernet cable from your FreeNAS device, again wait 10+ minutes and then plug in the Ethernet cable or you could use your console if you have one hooked up, check the values again. If you are not getting incrementing values then there is a problem with FreeNAS. Let me know you results.

-Mark
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
8,256
I have taken a quick look into this and I can see there is something wrong on my system as well. I can force my drives into standby however after a short period of time they spin right back up. Short meaning maybe a minute. I'm going to create a script to troubleshoot this problem. Maybe it's my MiniDLNA plugin, I don't know but I will figure it out.
 

twisted

Newbie
Joined
Sep 12, 2012
Messages
23
Hmmm, it says its an illegal parameter.

Code:
[root@##] /# smartctl -S 5 /dev/ada0
smartctl 6.1 2013-03-16 r3800 [FreeBSD 9.1-STABLE amd64] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org
 
=======> INVALID ARGUMENT TO -S: 5
=======> VALID ARGUMENTS ARE: on, off <=======
 
Use smartctl -h to get a usage summary
 
[root@##] /#


The usage information is:

Code:
  -s VALUE, --smart=VALUE
        Enable/disable SMART on device (on/off)
  -S VALUE, --saveauto=VALUE                                          (ATA)
        Enable/disable Attribute autosave on device (on/off)
  -s NAME[,VALUE], --set=NAME[,VALUE]
        Enable/disable/change device setting: aam,[N|off], apm,[N|off],
        lookahead,[on|off], security-freeze, standby,[N|off|now],
        wcache,[on|off], rcache,[on|off]
 

twisted

Newbie
Joined
Sep 12, 2012
Messages
23
Oh and also the start stop info.
Code:
[root@##] /# smartctl -a /dev/ada0 | grep "Start_Stop_Count"
  4 Start_Stop_Count        0x0032  100  100  000    Old_age  Always      -      12
[root@##] /# smartctl -a /dev/ada1 | grep "Start_Stop_Count"
  4 Start_Stop_Count        0x0032  100  100  000    Old_age  Always      -      10
[root@##] /# smartctl -a /dev/ada2 | grep "Start_Stop_Count"
  4 Start_Stop_Count        0x0032  100  100  000    Old_age  Always      -      3
[root@##] /# smartctl -a /dev/ada3 | grep "Start_Stop_Count"
  4 Start_Stop_Count        0x0032  100  100  000    Old_age  Always      -      6
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
8,256
Yes, I agree smartctl -S is invalid, now try to do what I wrote, use ataidle ;).
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
8,256
I've looked into this and it appears that if you have ANY jail running that the hard drives will not sleep. I'll bring this up in another posting to see if others are having this problem.
 

twisted

Newbie
Joined
Sep 12, 2012
Messages
23
Yes, I agree smartctl -S is invalid, now try to do what I wrote, use ataidle ;).
Wow, what a horrible reading fail. My mind somehow tricked me into typing the wrong command :) So I did those commands. The Stat_Stop increased by 1 as you said it would. But as you've found I had the same issue. Since issuing the command the disks have not stopped. The box has had no activity other than SSH with no direct access to the zpool in the SSH session.
 

jgreco

Resident Grinch
Moderator
Joined
May 29, 2011
Messages
12,151
As monitored by zpool iostat, or just what you "think" should generate pool I/O?

Because quite frankly a UNIX system generates a lot of garbage I/O to its running image, daemons reading files and causing atime updates, etc. And for a jail, that image is on the pool. I would not be shocked to find an I/O-naive jail image. To suppress superfluous I/O is difficult! We try to minimize garbage writes here on virtualized systems but it's not trivial. Lots of stuff writes tmpfiles so you make darn sure to do a mfs tmp. Logs, use syslog where possible to log remotely rather than locally. Base system, mount noatime or better yet readonly. Etc.

I woild consider it very likely your system is doing some occasional task that keeps the disks awake with a trite atime update write now and then, or equivalent.
 

twisted

Newbie
Joined
Sep 12, 2012
Messages
23
I think from your other thread Joe, I will put a stand alone drive in just for jails. My jails need no redundancy so that will do :) How often do people recommend spinning down drives? I've got my WD Greens set to park the heads after 5 minutes and I suppose spinning down after 30 minutes of inactivity is reasonable.
 

Dusan

FreeNAS Guru
Joined
Jan 29, 2013
Messages
1,165
I think from your other thread Joe, I will put a stand alone drive in just for jails. My jails need no redundancy so that will do :) How often do people recommend spinning down drives? I've got my WD Greens set to park the heads after 5 minutes and I suppose spinning down after 30 minutes of inactivity is reasonable.
I spin down my WD REDs after 1 hour of inactivity. I installed a small SSD (no redundancy) to hold the jails. I snapshots & replicate the SSD to the main pool daily, so that I can quickly restore the jails in case the SSD dies.
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
8,256
I now recall why I didn't have problems with FreNAS 8.3.x, because I used a USB Flash drive for my jails. To be honest it worked great. I formatted it for UFS and installed the jails. It wasn't a speed demon but I did use a very good quality flash drive that was fast on a USB 2.0 connection. You could also use CF, SD, or similar products. I myself do not have any open SATA connections so using a SSD is not in the picture unless I installed an add-on card (which I think I have buried in my basement somewhere).

But I let my drives run all the time so it doesn't impact my usage. I think the GUI where the Standby time is set, should be updated with a statement (info icon) that states if a jail/plugin is in use that the drive(s)/pool the jails exist on will not sleep.

Cheers!
 

cyberjock

Moderator
Joined
Mar 25, 2012
Messages
19,148
You could make the same argument for the syslog dataset too. I bet I could think up more examples if I really wanted to.

So where do you draw the line? This is rhetorical as you have to, at some point, say enough is enough. Right?
 

jgreco

Resident Grinch
Moderator
Joined
May 29, 2011
Messages
12,151
But I let my drives run all the time so it doesn't impact my usage. I think the GUI where the Standby time is set, should be updated with a statement (info icon) that states if a jail/plugin is in use that the drive(s)/pool the jails exist on will not sleep.

Cheers!
Except I don't think that's true; a properly designed jail could certainly allow the drives to sleep. FreeNAS also does allow you to disable atime updates on a dataset. That's not a cure-all though.

It is tempting to just cram a full FreeBSD image within a jail and make it run, because it gives a feel to users that is very similar to a FreeBSD server. But along the way, you get the fun of things like cron running periodic scripts, other daemons maintaining other things, whatever...

In a service provider environment, often jails are built the other way up. We start with an empty directory and populate it with only the minimal things needed to make a jail work. Well-designed jails contain no /bin/sh for example. That often means that there's a single daemon executable running "within" the jail environment and nothing more. As long as that daemon isn't needlessly fondling the underlying disk resources, and as long as there's sufficient memory to eliminate needless page-in events, the disks should be able to sleep.
 

evilandy

Newbie
Joined
Sep 26, 2011
Messages
38
Hi, I have a FreeNAS on HP ProLiant Microserver with 5x 3TB Hitachi Drives that support standby and an SSD with it's own stripe for jails and plugins, separate from the main pool. I can manually make the drives sleep with smartctl -a -n standby /dev/ada0 but they won't sleep by themselves. I'm on FreeNAS 9.1 Release. Can you think of anything else that may cause the drives to stay spinning? I'll try turning a few things on an off.

Thanks,

EA
 

Glorious1

FreeNAS Guru
Joined
Nov 23, 2014
Messages
975
As far as I know, that smartctl command should NOT put them in standby (spin down). "-a" gets all information on the drive, and "-n standby" just means don't bother the drive if it's in standby. So I don't know how you verify that they're spinning down from that command.

You didn't mention syslog; that's a common cause of keeping drives spinning.
https://forums.freenas.org/index.php?threads/how-to-let-drives-spin-down.26314/

Edit: oops - just noticed that post was a year old . . .
 
Joined
Apr 3, 2016
Messages
2
Did a tiny edit of the idle-test SMART based script so it scans all the drives in the camcontrol devlist, except for any cdrom drives, or any others you specify not to do(add another awk surrounded by pipes per device and modify cd to whatever you wish to not check
Code:
#!/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 all drives listed in camcontrol devlist..."
camcontrol devlist | awk '!/cd/' | awk -F\( '{print $2'} | awk -F\, '{print $1}' |while read LINE
do
  switch1="/dev/"$LINE
  testidle
done

# Cleanup our tiny mess
echo "Cleaning up temp files"
rm /var/tempfile
echo "Done with cleanup, exiting now"
exit 0
 
Last edited:

ric

FreeNAS Experienced
Joined
Dec 22, 2013
Messages
168
I've tried everything all the commands to put my HDs to sleep/standby mode that they have suggested here in the freenas forum but the HDs don't spindown!

Is this because of my HDDs do not support spindown/idle or what?

Services / SMART > Power Mode* Standby

1556987319681.png


1556987437093.png


1556987538706.png
 
Last edited:
Joined
Aug 14, 2019
Messages
6
Code:
camcontrol: error sending command
da0: UNKNOWN
ada0: SPINNING
ada1: SPINNING
ada2: SPINNING
ada3: SPINNING
camcontrol: error sending command
da0: UNKNOWN
 
Top