I have built for myself a simple Media Center, based on Zotac ZBOX ID41 Plus, XBMC-Live, Transmission, Flirc and other useful stuff. The idea is having a low-energy consumption machine that I control with a remote. And it has to be always on.
One thing I was concerned about is how to deal with my external HD connected to it: I’m of course expecting those to eventually fail if they are always spinning.

Well, a bit of scripting and cron can go a long way. Here is my solution.
Step 1: dependencies
Just install sdparm and you should be all set, at least on a “normal” Linux box where Cron is already configured.
Step 2: scripting FTW
Put a script like this somewhere in your system. I have it in my ~/bin:
| |
A very basic and simple one, isn’t it?
What it does is just probe /proc/diskstats virtual file to get info about the recent activity of a disk. If it has not changed in the last 30 minutes, than it’s time to use sdparm to send a stop command --command=stop. That’s it.
Step 3: Cron-it-up!
Add the following lines to your /etc/crontab:
| |
The above lines execute the script against sda, sdb, sdc, sdd and sde.
That’s it. I have been using this method for almost 2 years not, and thought it might be helpful to others.