Pragmatism in the real world

Sleeping an external hard drive

One annoyance I had with my external USB hard drives is that they weren’t sleeping when idle which makes them noisy. We can’t have that!

My first port of call was hdparm and its -S parameter:

sudo hdparm -S 60 /dev/sdb

However this didn’t help.

Fortunately, I found hd-idle which worked!

After installing, you need to edit /etc/default/hd-idle and change the HD_IDLE_OPTS setting from -h to whatever you need.

For me, I have set: HD_IDLE_OPTS="-i 0 -a sdb -i 60 -a sdc -i 60"

These parameters are:

  • -i 0: This first -i sets the idle timeout for all drives. 0 means no timeout which is what I want for all drives except my external USB ones.
  • -a sdb -i 60: For only the disk set after the -a, set the idle time to the value of the subsequent -i. i.e. set sdb to 60 seconds timeout.
  • -a sdc -i 60: For only the disk set after the -a, set the idle time to the value of the subsequent -i. i.e. set sdc to 60 seconds timeout.

Not completely intuitive, but easy enough once you have understood what’s going on. I have left a comment in the /etc/default/hd-idle to remind me!

Then after a reboot, ps aux | grep hd-idle showed that it was running and now my external drives are quiet.

Thoughts? Leave a reply

Your email address will not be published. Required fields are marked *