A good[ish] website

Web development blog, loads of UI and JavaScript topics

Spin down idle disks on a Raspberry PI

Filed under: System— Tagged with: Raspberry PI, linux

Here’s how to make hard disks stop after a period of idle time.

Lately I’ve been dabbling around with Raspberry PIs, and I had a problem where the PIs disks were constantly spinning, since I use it only every-now-and-then, that felt pretty wasteful.

There’s a program called hdparm, that spins down disks, but for some reason I couldn’t get it working on my PI, it just gave me an error SG_IO: bad/missing sense data.

But, I managed to get another package working: hd-idle. It’s not on apt-get, but it’s in SourceForge and you can built it manually.

How to install hd-idle

Install the deps needed in the build process:

$ sudo apt-get install build-essential fakeroot debhelper -y

Get the hd-idle source code:

$ wget

Decompress the tarball and run the build command:

$ tar -xvf hd-idle-1.05.tgz \
  && cd hd-idle \
  && dpkg-buildpackage -rfakeroot sudo dpkg -i ../hd-idle\_\*.deb

After it has done building, figure out your hard drive’s ID with the df command:

$ df -h

Mine is simply the most elementary: sda, yours might be sda1 or sda2, for example.

Try if the newly installed hd-idle actually spins the disc down:

$ sudo hd-idle -t sda

If you heard the drive powering down, then everything is working fine.

Configure hd-idle

Next, configure the drive to power down after a given amount of idle time. Pop open the config file (I'm using vim you might want nano):

$ sudo vim /etc/default/hd-idle

In there, you can enable the idling:

HD_IDLE_OPTS="-i 600"

That will put all the hard drives to sleep after 10 minutes of idle time.

To have different idle time per drive, use the -a flag to separate the entries, and the drive’s ID:

HD_IDLE_OPTS="-i 600 -a sda1 -i 400 -a sda2 -i 200"

After you’re done with the config, restart the service:

$ sudo service hd-idle restart


A bit of a departure from my normal front-end style articles. Hope this was helpful. Thanks for reading!

Comments would go here, but the commenting system isn’t ready yet, sorry.

  • © 2022 Antti Hiljá
  • About
  • All rights reserved yadda yadda.
  • I can put just about anything here, no one reads the footer anyways.
  • I love u!