## HDD Spindown on Arch Linux

From hdparm's man page on the CLI parameter -S:

Put the drive into idle (low-power) mode, and also set the standby (spindown) timeout for the drive. This timeout 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.

From hdparm's man page on the CLI parameter -B:

Get/set Advanced Power Management feature, if the drive supports it. A low value means aggressive power management and a high value means better performance. Possible settings range from values 1 through 127 (which permit spin-down), and values 128 through 254 (which do not permit spin-down). The highest degree of power management is attained with a setting of 1, and the highest I/O performance with a setting of 254. A value of 255 tells hdparm to disable Advanced Power Management altogether on the drive (not all drives support disabling it, but most do).

To set the spindown time to 30 minutes for /dev/sda, /dev/sdb and /dev/sdc, run:

for dev in /dev/sd{a..c}; do hdparm -S 241 $dev; done  To make this persistent, create the file /etc/udev/rules.d/11-sdb-spindown.rules to create a udev rule (only for /dev/sdb): ACTION=="add", SUBSYSTEM=="block", KERNEL=="sdb", RUN+="/usr/bin/hdparm -S 241 /dev/$kernel"


or to apply for all /dev/sd[a-z] drives:

ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="1", RUN+="/usr/bin/hdparm -S 241 /dev/$kernel"  Try running sudo udevadm trigger afterwards to apply the new rules. When you change the SATA-port you connect your HDDs to rather often, it would make more sense, to specify spin-down times on the model / serial: udevadm info --query=all --attribute-walk --name=/dev/sda KERNEL=="sd?1", SUBSYSTEMS=="usb", ATTRS{serial}=="ABCDEF012345", SYMLINK+="musik" ATTRS{model}=="ST1000DM003-1CH1"  To check the current power status of the drives: for drive in /dev/sd?; do echo$drive:; sudo hdparm -C $drive; done # or if that is spinning your drive up again, try: for drive in /dev/sd?; do echo$drive:; sudo smartctl -i -n standby $drive | egrep 'Device Model|Power|STANDBY'; done  To force a drive to spin down: sudo hdparm -y /dev/sdc  A script to spin down a drive if not spun down currently: #/bin/sh DISK=/dev/sdd if hdparm -C$DISK | grep -q active; then
#echo silencing
hdparm -y \$DISK
fi


I call this regularly via this crontab entry:

*/5 * * * * /root/silence.sh