Skip to content. | Skip to navigation

Personal tools


You are here: Home / Members / jhb / Preventing etxternal usb 3 hard disk from going to sleep

Preventing etxternal usb 3 hard disk from going to sleep

by Jörg Baach last modified Feb 17, 2013 11:29 PM
I have an Toshiba store.e external USB 3 harddisk, that goes to sleep after a while, basically dissappearing from my ubuntu machine. How can I prevent that?

The above problem has been annoying me for a while. Its preventing me to do a copy of my main backup harddisk.

I have two approaches underway atm. One is

sudo sdparm --clear STANDBY -6 /dev/sde

the other is a little python script that will keep the disk busy in a given interval.

import os, sys, random,time
if len(sys.argv) != 3:
    print 'usage:\n   %s path interval' % sys.argv[0]
path = sys.argv[1]
interval = sys.argv[2]

prefix = 'prevent_standby_'

while 1:
    #delete old ones
    oldnames = [n for n in os.listdir(path) if n.startswith(prefix)]    
    for name in oldnames:
        oldpath = os.path.join(path,name)
        print 'deleted '+oldpath
    #write new
    suffix = random.randint(1000000,9999999)
    newname = os.path.join(path,prefix+str(suffix))
    content = 'foo %s' % random.randint(1000000,9999999)
    fh = open(newname,'w')
    print 'wrote   '+newname

Lets wait to see which one actually works

Ok, at least one combination does work: the script above and disabling power management by doing:

sudo hdparm -B 255 /dev/sde

On the one side this shows the harddisk to be somewhat unusable - but just doing a copy of another hd, and storing this hd somewhere offline, its good enough.


Add comment

You can add a comment by filling out the form below. Plain text formatting.

Question: What is 23 plus 19?
Your answer: