Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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):

  1. If no read/write request to drive X was submitted for y minutes, turn of X and remember that X was connected.

  2. If a read/write request is submitted destined for X, turn on X and handle the request.

  3. 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.

share|improve this question
1  
You might consider a program like spindown. –  Dan D. Apr 9 '13 at 11:14
add comment

2 Answers

up vote 2 down vote accepted

I think you are looking for the hdparm util which allows you to play with drive parameters.

Different drives take different parameters, and different disks have different levels of support for example -J wukk set a WD Green drives idle timeout. (but you probably want something like -S or conceivably -s, but man hdparm will provide the lowdown.

share|improve this answer
add comment

If you want such precise control you probably have to turn off the disks power management and do that yourself: Keep a programm running (or have it started every x minutes) which has a look at the disks' access data in e.g. /sys/block/sda/sda9/stat. If your script detects that there have been no accesses over your threshold period then you power down the respective disk (if it isn't yet).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.