Hard disk not going to standby automatically
Note that some drives do not implement this feature, even if the command passes. You may also need to reduce the Advanced Power Management level to 127 or less with hdparm -B 127 /dev/sda
. From the man page:
-B Get/set Advanced Power Management feature... values 1 through 127 (which permit spin-down), and values 128 through 254 (which do not permit spin-down).
If all fails, you can write a small script that polls /proc/diskstats
or /sys/block/sda/stat
for the number of read/writes on the device and explicitly puts the drive in standby if they don't change over several minutes. See the hd-idle utility.
The actual problem was smartd
, which regulary checked the values of the device, even when it was in standby mode.
I solved it by disabling smartd
and running tests with smartctl
from time to time.
i'm running ubuntu 18.04 and had this same issue. thanks to @allo's answer, i found out the smartd
is indeed the cause.
by default the /etc/smartd.conf
is configured like this:
DEVICESCAN -d removable -n standby -m root -M exec /usr/share/smartmontools/martd-runner
which will auto scan all drives and poll them (this operation spins up the disk) periodically (default 30 minutes, changable).
although with the -n standby
part smartd will skip spun-down disks, but the problem is: if the smartd polling interval is shorter than the disk's "spin-down after" time, then smartd will always poll the disk BEFORE it has the opportunity to spin-down, thus the disk will never get into standby mode.
if the disk's "spindown timeout" is shorter than smartd's polling interval, then the disk would spin-down before smartd polling, after which smartd will skip this disk and not spin it up.
if the disk is (manually) spun-down by other tools like hd-idle
, then smartd also will skip it.
one way to change smartd polling interval longer is edit this line in /etc/default/smartmontools
:
smartd_opts="--interval=1800"
1800 meas 30 min, make it 10800 (3 hours) is long enough, for example. and don't forget restart them:
systemctl restart smartd smartmontools