12

I have a hard drive, which should go to standby automatically after 30 or 60 minutes.

I tried (3 minutes for testing):

# hdparm -S 36 /dev/sda

/dev/sda:
 setting standby to 36 (3 minutes)

And it didn't work, even when there were no access for more than 5 minutes. Now I thought about some process accessing data, so I tested

# hdparm -y /dev/sda

/dev/sda:
 issuing standby command

Drive went to standby and kept sleeping, as you can lookup with

# hdparm -C /dev/sda;date

/dev/sda:
 drive state is:  standby

Touching some file in the mountpoint woke it up as you would expect it.

Why isn't the automatic suspend working? As far as I understood it should even turn off the hard drive independend from the OS, as long as there is no access.

  • Doing this is typically false economy. Why do you want to do this? – EEAA May 21 '17 at 21:06
  • 2
    I have a pi with a desktop drive for tv recordings. Now the drive is unused for like 20 hours a day and as a desktop drive it should live longer when it goes to standby for 20 hours than when it runs the whole day (which is quite the opposite of server drives). The 3 minutes were only for testing, i actually want it to go to standby after 30-60 minutes. – allo May 21 '17 at 22:20
  • This and this is related. – Albert May 2 at 12:07
7

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.

| improve this answer | |
  • 3
    With hdparm -B 127 it works. – allo May 22 '17 at 20:00
5

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.

| improve this answer | |
  • How did you address this issue? Did you remove smartd altogether? I've been having a similar problem with my ZFS pool that consists of three WD gold drives. While two drives go on standby after some period of inactivity, the third one never does. I've been search for a solution for months now and couldn't find anything besides manually setting the drive to standby w/ hdparm. – Petaflop Jun 12 at 18:51
  • 1
    I disabled smartd. But you should probably be able to configure the test intervals. – allo Jun 14 at 20:46
3

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
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.