Spin down HDDs when idle

This (along with all my guides) is for Ubuntu but it could probably be done on any Debian based linux variant. It is worth setting your drives to spin down when the system is inactive. This will save some power and reduce the wear on the drive.First install your dependencies:
apt-get install hdparm smartmontools

You can send the command from the terminal to check if it works, this will spin down disks sda to sde:

hdparm -y /dev/sd[a-e]

And this command will tell you the current status of the drive:

hdparm -C /dev/sd[a-e]

You can automate this to make the drives spin down after X min of inactivity by editing the /etc/hdparm.conf file and adding:

/dev/sda {
spindown_time = 241
}

/dev/sdb {
spindown_time = 241
}

/dev/sdc {
spindown_time = 241
}

/dev/sdd {
spindown_time = 241
}

/dev/sde {
spindown_time = 241
}

/dev/sdf {
spindown_time = 241
}

The ‘241’ value will spin the drives down after 30 min inactivity. I can really remember where I found this value out initially but I have a note written down that says that this is the case. So if you need to find out you can do some Google-foo to find out – I expect that it is in the man page – why, yes it is (http://unixhelp.ed.ac.uk/CGI/man-cgi?hdparm):

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.
A value of 255 is interpreted as 21 minutes plus 15 seconds.
The value 254 is reserved.

Note that some older drives may have very different interpretations of these values.

Also note that smartd can interfere by checking SMART disk status every hour. When this was happened, it would wake the disks up, basically never allowing them to go into standby. To change SMART checking to every 2 hours, and to not spin the drive up if it is in standby we need to edit /etc/default/smartmontools and add:

smartd_opts="-q never -i 7200"

Then edit /etc/smartd.conf and comment out:

DEVICESCAN -m root -M exec /usr/share/smartmontools/smartd-runner

Add below commented line:

DEVICESCAN -S on -o on -a -I 194 -m username@gmail.com -s (S/../.././02|L/../../6/03) -n standby,q

Reboot the system.

Useful sources
http://zackreed.me/articles/60-spin-down-idle-hard-disks

Leave a Reply

(email optional)


Warning: Undefined array key "rerror" in /home/public/blog/wp-content/plugins/wp-recaptcha/recaptcha.php on line 291