I have a PC running Ubuntu 12.10 server as my custom home server. There are a number of hard drives connected to it via USB. The server runs 24-7 and I was wondering if there is any way or any commands that can be used to turn off the drives if they are not used and once a read/write request for the drive is submitted, the drives will automatically be turned on again to handle the request?
So I basically want a script that can do the following (if this is not digging to deep into the Linux kernel):
If no read/write request to drive X was submitted for y minutes, turn of X and remember that X was connected.
If a read/write request is submitted destined for X, turn on X and handle the request.
Start from 1 again.
Some of these drives contain data that I sometimes don't use for weeks/months, so I don't want their lifespan to be reduced by just sitting there in idle. And I don't want to switch the drives on/off every time I use them.