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.
Install the deps needed in the build process:
$ sudo apt-get install build-essential fakeroot debhelper -y
hd-idle source code:
$ wget http://sourceforge.net/projects/hd-idle/files/hd-idle-1.05.tgz
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 -h
Mine is simply the most elementary:
sda, yours might be
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.
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
$ sudo vim /etc/default/hd-idle
In there, you can enable the idling:
START_HD_IDLE=true 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. Tweet me @hiljaa if you want to make a correction etc.