Unofficial method for control of individual drive spin down


RobJ

Recommended Posts

From an hdparm man page: http://linux.die.net/man/8/hdparm

-S

    Set the standby (spindown) timeout for the drive. This value is used by the drive to determine how long to wait (with no disk activity) before turning off the spindle motor to save power. Under such circumstances, the drive may take as long as 30 seconds to respond to a subsequent disk access, though most drives are much quicker. The encoding of the timeout value is somewhat peculiar. A value of zero means "timeouts are disabled": the device will not automatically enter standby mode. Values from 1 to 240 specify multiples of 5 seconds, yielding timeouts from 5 seconds to 20 minutes. Values from 241 to 251 specify from 1 to 11 units of 30 minutes, yielding timeouts from 30 minutes to 5.5 hours. A value of 252 signifies a timeout of 21 minutes. A value of 253 sets a vendor-defined timeout period between 8 and 12 hours, and the value 254 is reserved. 255 is interpreted as 21 minutes plus 15 seconds. Note that some older drives may have very different interpretations of these values.

 

By adding 'hdparm -S# /dev/?d?' lines to the end of the go script, you can control the spin down of each drive.  Below are common values for the -S# parameter, for the desired spin down time.  You can turn off spin down for a particular drive by using the value -S0 (minus ess zero).

 

Because of occasional inconsistency in responses to spindown commands, I have found it works best to turn off spindown first for a drive, before setting the desired spindown time.  You will see that in the example below.  Another example of inconsistent response is that unRAID's own 'Spin Up' button will occasionally spin up all but 1 drive, requiring a second push to get it to join the party.

 

Common standby values:

-S1     5 seconds

-S2    10 seconds

-S3    15 seconds

-S6    30 seconds

-S12    1 minute

-S24    2 minutes

-S36    3 minutes

-S60    5 minutes

-S120  10 minutes

-S180  15 minutes

-S240  20 minutes

-S241  30 minutes

-S242   1 hour

-S244   2 hours

-S246   3 hours

-S250   5 hours

-S0     standby is disabled, will not spin down

 

Below is an example of a go script, with spin down control and Joe's -setra optimization.  It keeps the unassigned drive sda spun down (-S2, down in 10 seconds), spins sdb down in 30 minutes (-S241), and the rest in 10 minutes (-S120).  The '/usr/sbin/' is not strictly necessary.

 

#!/bin/bash
# Start the Management Utility
/usr/local/sbin/emhttp &
sleep 30
for i in /dev/md*
do
    blockdev --setra 2048 $i
done
/usr/sbin/hdparm -S2   /dev/sda
/usr/sbin/hdparm -S0   /dev/sdg
/usr/sbin/hdparm -S0   /dev/sdd
/usr/sbin/hdparm -S0   /dev/sdb
/usr/sbin/hdparm -S0   /dev/sdf
/usr/sbin/hdparm -S0   /dev/sdc
/usr/sbin/hdparm -S0   /dev/hda
/usr/sbin/hdparm -S120 /dev/sdg
/usr/sbin/hdparm -S120 /dev/sdd
/usr/sbin/hdparm -S241 /dev/sdb
/usr/sbin/hdparm -S120 /dev/sdf
/usr/sbin/hdparm -S120 /dev/sdc
/usr/sbin/hdparm -S120 /dev/hda

 

Attached below is a copy of my go script, with the correct line-feed's only, ready for customizing for your system.  It MUST be edited to fit your drive inventory.  Remove the added .TXT extension, required only for attachment.

 

Note on editing 'go':  use Microsoft WordPad or an editor that can be configured to use Unix end-of-line's.  Do not use Notepad, Microsoft Word, or any editor that you can not adjust the end-of-line character.  In WordPad, Save As Text Document, not MS-DOS Format, and always start with an existing Unix file and edit it, don't start a new file and save.

 

Feel free to critique or add to the above...

 

Edit: change hdparm man page link, gentoo man pages were vandalized

Link to comment

You are absolutely right!  I was going to mention something about both points, and completely forgot.  My USB drive competes with a data drive for sde, the other gets sdf, and it seems to be a tossup who wins.  I added spindown lines for both sde and sdf, and the USB drive returns a seemingly harmless error.

 

Also, with any change to your hardware, you must remember to check for changes to these assignments, and edit 'go' accordingly.

 

This procedure may be incompatible with future versions, and hopefully will be unnecessary in the future!

 

Link to comment
  • 3 months later...

I have changed my thinking on the most reliable way of getting an hdparm spin command to 'take'.  You do not have to disable spindown first, before setting the desired spin down timing.  You just have to send the command twice, as it occasionally ignores the first attempt to set it.  I don't understand the factors that cause the inconsistency, so I would recommend just sending the spin control command once, and only if it seems unreliable, repeat the command.

 

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.