Spin Down Idle Hard Disks

Necessary tools:

 sudo apt-get install hdparm

Now, you need to edit your hdparm.conf to add entries for each of your drives.

 nano /etc/hdparm.conf

Here’s an example of my setup.

/dev/disk/by-id/ata-Hitachi_HDS5C3030ALA630_MJ1313YNG1LMJC {
        apm = 127
        keep_features_over_reset = on
        spindown_time = 242

/dev/disk/by-id/ata-TOSHIBA_DT01ACA300_44LY9ENGS {
        apm = 127
        keep_features_over_reset = on
        spindown_time = 242

/dev/disk/by-id/ata-ST3000DM001-1ER166_Z7P0027C {
        apm = 127
        keep_features_over_reset = on
        spindown_time = 242

You will note that I’m identifying the drives by their unique ID rather than simply using /dev/hdX or /dev/sdX, as device assignments can change between reboots. You can determine these values by looking at the output of this command.

ls -l /dev/disk/by-id

It will give you output like this…

lrwxrwxrwx 1 root root  9 Mar  3 15:31 ata-HGST_HDN724040ALE640_PK1334PCGXGYYS -> ../../sdi
lrwxrwxrwx 1 root root 10 Mar  3 15:31 ata-HGST_HDN724040ALE640_PK1334PCGXGYYS-part1 -> ../../sdi1
lrwxrwxrwx 1 root root  9 Mar  3 15:31 ata-HGST_HDS5C4040ALE630_PL2331LAG9056J -> ../../sdb
lrwxrwxrwx 1 root root 10 Mar  3 15:31 ata-HGST_HDS5C4040ALE630_PL2331LAG9056J-part1 -> ../../sdb1

/dev/sdb would be identified by this in your /etc/hdparm.conf file.


You may also noticed that I have set Advanced Power Management to 127. This is the setting with the highest performance which still allows spindown, I’ve also told the drive to keep features over reset, in order to preserve the settings on a soft restart, and spindown delay has been set to 242 (1 hour).

Here’s the manpage description for more info.

The Time (in seconds) after which the Drive spins down is the value of your x multiplied with 5 From the manpage:

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.

NOTE: If you see an error like this, or some of your disks aren’t spinning down, it’s because your disk doesn’t support Advanced Power Management (APM). You can still spin them down with the hdparm -y, but this isn’t a viable solution, unless you want to roll a script to spin it down after a period of inactivity. Edit: I have created a script that will do just that. You can view it here.

setting Advanced Power Management level to 0xfe (254)
HDIO_DRIVE_CMD failed: Input/output error
setting standby to 1 (5 seconds)
APM_level = not supported

Reboot for this to go into effect.


The above does put your disks to sleep, but I was having issues in that smartd (SMART monitor was checking the drives every 30 minutes. When this was happened, it would wake the disks up, basically never allowing them to go into standby. I have changed it to check every 2 hours, and to not spin the drive up if it is in standby. You can do so by making the following changes.

nano /etc/default/smartmontools

and add this to the options…

smartd_opts="-q never -i 7200"

And, finally, if you don’t want to spin up idle hard drives, there’s one more file you need to edit.

nano +22 /etc/smartd.conf

Comment this line out

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

And add this below the commented out line.

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

One more reboot, and you should be on your way to drives that spin down, and all the energy savings associated with that.

If you’d like to check the status of your disks, you can view the current status like this.

hdparm -C /dev/sde

It should output something like this if the disk is spun down.

 drive state is:  standby

Or, all of them at once like this where x is the starting disk and y is the end.

hdparm -C /dev/sd[b-z]

Here’s example output…

root@fileserver:~# hdparm -C /dev/sd[b-k]

 drive state is:  standby

 drive state is:  standby

 drive state is:  standby

 drive state is:  standby

 drive state is:  standby

 drive state is:  standby

 drive state is:  standby

 drive state is:  standby

 drive state is:  standby



I love learning new things and trying out the latest technology.

You may also like...

5 Responses

  1. Savage702 says:

    Hi Zack,

    Well, I’m getting the first comment on an almost 10 year old article. Nice! Not sure what it says about me if nobody else has had a question. hahaha

    I understand you’re onto SAS drives, and doing something different, but hoping you might have some input on this.

    I’ve never paid much attention to my configuration of spinning down disks, till I pulled a drive out the other morning and it was blazing hot, while it should have been in suspend of quite some time.

    Since noticing that, updating my config, adding drives I forgot to add, I kept checking back, and only my Parity drive is going into standby, and just this morning, one of my 10 data drives were in standby.

    Is there a way to tell if my drives are EVER going into Standby?? Is there something that could be keeping all my drives spinning none stop? I know Plex has periods of no use throughout the day, and downloads are often, but not continuous.

    Ubuntu 18.04, SnapRaid, mergerfs, WD Reds, H310 and Intel 24 port expander card… everything is dockerized, not sure if anything else would be helpful.

    Any thoughts?

    • Zack says:

      Unfortunately, there are tons of things that can keep disks spinning like smartd, Plex, system processes, etc. If you turn off Plex’s periodic scans, and setup smartd like I mention in another tutorial, you can get to the point where most of your disks are spun down most of the time. I will say that if you have a very hot disk, you probably want to work on getting more managed airflow across your disks. I also have scripts on my site that cover temperature monitoring too 🙂

      • Savage702 says:

        Alright then, I’ll have to dig in. heh Smartd is setup just as shown. But what I had missed was some of the scanning for media settings… it wasn’t just the drop down for the number of hours but also automatic checking and monitoring for changes.

        I’ve told Sonarr & Radarr to tell Plex when an update has occurred. I’ll see if that makes a difference.

        As for the hot drive, I sent it back for a replacement, it was having some errors. But… it was my first foray into something other than WD Reds, a Seagate Exos… so it runs as 7200rpm vs all my other drives. I’m not sure if it was supposed to be that hot, if something was wrong, or what, but temp monitoring could be next. Or I might just stick with my lower rpm reds. I was hoping though that if it spun down a good portion of the time, it might be less of a concern.

        Thanks for the info, and thanks for fixing captcha. lol

      • Savage702 says:

        Well, once again… my fault. APM = Not Supported.

        I wasn’t seeing errors anywhere, so didn’t even question it… saw 2 other drives going into standby… of course, they were my newer 8TB drives and not my 3TB ones.

        So now I move on to your script and cron job, exclude the 8TB drives and let that handle the others. That should do the trick.

        • Zack says:

          Good job tracking it down! Sometimes figuring these things out feels like hitting your head against a wall. But, it is fun when things really start working the way that you planned 🙂

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.