Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Does anyone know if there is an elegant way to tell an external usb drive not to spin down after a period of inactivity? I've seen cron based solutions that write a file every minute, but nothing that smells of nice unixey elegance. There must be a hdparm, or scsi command that I can issue (usb drives are accessed via the sd driver in OpenBSD) to the drive to tell it to not sleep. I'm afraid that this is probably a feature built into the controller in the enclosure, and as such not much can change it aside from ripping the drive out of it's enclosure and plopping it directly in the machine, but I figured I would ask, on the off chance.

Ideally, I'm looking for an OpenBSD solution, but I know there are others out there w/the same problem so any solutions will be considered for the answer.

share|improve this question
1  
I'm just curious why you don't want the drive to spin down. –  Tshepang Jan 3 '11 at 18:35
1  
Well, for the moment, it's because I have that drive mounted via NFS on another machine, and if I boot machine #2 while the drive is spun down, it timesout, and the NFS partition doesn't mount. –  gabe. Jan 4 '11 at 2:31
1  
Not letting the drive spin down can reduce its lifetime. I would consider addressing the timeout issue instead. I had a similar problem before with a backup NAS and using an automounter (such as autofs) ensured that the system would not timeout and only spin up the disks if the mountpoint is accessed (and auto-mounted). –  Unode Feb 16 '12 at 22:43

3 Answers 3

up vote 3 down vote accepted

Yeah, it's generally built into the firmware. Some drive manufacturers provide an MS Windows based management tool that will allow you to modify various parameters, including disabling the "sleep" or spin down timer. If you have access to a Windows box it might be worth it to pursue that angle.

share|improve this answer

This solution (for Linux) from http://www.arrfab.net/blog/?p=107 has helped for a 1TB Seagate Portable drive which kept going to sleep:

# sdparm --clear=STANDBY /dev/sdc -S

The drive now is immediately responsive even when left idle for an hour. Didn't test yet whether the setting is saved across restarts etc, though.

share|improve this answer
    
any tip on doing this without sudo? –  Aquarius Power Aug 23 at 0:57

The manual for the linux hdparm provides the following info:

-B  Query/set Advanced Power Management feature,
    if the drive supports it.
    A low value means aggressive  power  management
    and a high value means better performance.

    Possible settings range
    from values 1 through  127  (which  permit spin-down),
    and values 128 through 254 (which do not permit spin-down).

    The highest degree of  power  management
    is attained with a setting of 1,
    and the highest I/O performance with a setting of 254.

    A  value  of  255  tells hdparm to
    disable Advanced Power Management altogether on the drive
    (not all drives support disabling it, but  most do).

That being said, it's still not guaranteed that your drive enclosure will support relaying these instructions to the drive. The same reference mentions that being able to use hdparm with an enclosure at all is only possible with certain "newer (2008 and later)" models that support the SCSI-ATA Command Translation system, aka "SAT". I've yet to try doing this on anything but a recent cheap backup drive, an HP SimpleSave model. It seems to provide some limited power management functionality.

And of course this also assumes that OpenBSD's hdparm works in the same way. I am not at all knowledgeable in the ways of OpenBSD, so I can't help you there.

share|improve this answer
1  
The OpenBSD equivalent of hdparm is atactl. But I don't know if it works on USB devices; atactl(8) is referenced by wd(4) (the IDE disk driver man page) but not by umass(4) (the USB storage driver man page). –  Gilles Jan 4 '11 at 21:26
    
I'm going to play with this, though since usb drives mount using the /dev/sd* devices, I'm not sure wd and atactl apply. Time to do some reading/playing. –  gabe. Jan 6 '11 at 2:08
    
do you think hdparm could be used in a loop in some way without sudo to prevent sleeping? –  Aquarius Power Aug 23 at 1:01

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.