Manual reference for hdparm (or you can do man hdparm
from the command line.)
Manual reference for hdparm.conf (or you can do man hdparm.conf
from the command line)
Configuration reference: read the /etc/hdparm.conf file which contains examples in the comments
You may need to install the hdparm package: apt install hdparm
Iāll share some things you can try. I recommend you first try getting the result you like using only the -B or apm=nnn
option I show you below. If you canāt suit yourself using -B then try adding in the -S or spindown_time=nnn
alternative. I assume that your external drive has the /dev name of /dev/sdb
for these examples.
# this will set the apm (Advanced Power Management) setting to maximum power savings without spindown. I use this on a server to frequent cycling wear but still save some power
$sudo hdparm -B 128 /dev/sdb
# this will set the apm to maximum apm power saving which includes the use of spindown
$sudo hdparm -B 1 /dev/sdb
# you can pick an apm value between 1 and 127 to save power and spin down with 1 giving the most power saving and 127 giving the least power saving which include spindown. The hdparm manual page does not specify the differences between values in the 1 - 127 range. Try to find one you like.
$sudo hdparm -B 92 /dev/sdb
You can use the -S option to hdparm to set spindown options. Hereās what the manual says:
-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 acā
tivity) 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.
I would start on the conservative side here because the power cycles will accumulate as wear on the device.
# use vendor defined timeout period (maybe between 8-12 hours)
$sudo hdparm -S 253 /dev/sdb
# use 21 minutes which is about the maximum you can specify
$sudo hdparm -S 252 /dev/sdb
When you get these set up as you wish, you can persist this in the /etc/hdparm.conf file. You would edit this file as root (or using sudo) and add the following lines in the section of the file which has these options:
apm=92
spindown_time=252
Once you modify /etc/hdparm.conf such as that these settings are applied at reboot. This may take a bit more work to make this apply to a hotplug USB drive. The /etc/hdparm.conf file contains examples how to apply the hdparm settings to a specific device which may be what you need for the external USB device.