waking up a sleeping external usb storage drive on linux?

0

So I got a Seagate external usb storage that goes to sleep after 90 minutes. All its power comes from the usb.
At dmesg, this is what happens:

[Dom Jun 29 17:25:08 2014] sd 7:0:0:0: Attached scsi generic sg4 type 0
...
[Dom Jun 29 19:06:48 2014] sd 7:0:0:0: Device offlined - not ready after error recovery

Whatever that may mean, if I unplug and plug back it works fine.

There are several answers speaking about sdparm and hdparm to keep the drive awake.
What I am looking for is how to make it go sleep after 15 minutes without being used, and how to wake it up back without re-plugging the usb cable?

When it gets "offlined", the /dev/sde vanishes; and its entry at lsusb vanishes too.

The dmesg log; I put everything I think is related; I see many errors and problems; now I am not sure it is actually going to sleep? also I am using a 2m long usb cable.

dmesg -T |grep "sde\|7:0:0:0\|8-2:"

[Seg Jun 30 15:02:09 2014] usb 8-2: new high-speed USB device number 2 using xhci_hcd
[Seg Jun 30 15:02:09 2014] usb 8-2: New USB device found, idVendor=0bc2, idProduct=2300
[Seg Jun 30 15:02:09 2014] usb 8-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[Seg Jun 30 15:02:09 2014] usb 8-2: Product: Portable        
[Seg Jun 30 15:02:09 2014] usb 8-2: Manufacturer: Seagate 
[Seg Jun 30 15:02:09 2014] usb-storage 8-2:1.0: USB Mass Storage device detected
[Seg Jun 30 15:02:09 2014] usb-storage 8-2:1.0: Quirks match for vid 0bc2 pid 2300: 200000
[Seg Jun 30 15:02:09 2014] scsi7 : usb-storage 8-2:1.0
[Seg Jun 30 15:02:10 2014] scsi 7:0:0:0: Direct-Access     Seagate  Portable         0130 PQ: 0 ANSI: 4
[Seg Jun 30 15:02:10 2014] sd 7:0:0:0: Attached scsi generic sg4 type 0
[Seg Jun 30 15:02:10 2014] sd 7:0:0:0: [sde] 1953525168 512-byte logical blocks: (1.00 TB/931 GiB)
[Seg Jun 30 15:02:10 2014] sd 7:0:0:0: [sde] Write Protect is off
[Seg Jun 30 15:02:10 2014] sd 7:0:0:0: [sde] Mode Sense: 2f 08 00 00
[Seg Jun 30 15:02:10 2014] sd 7:0:0:0: [sde] No Caching mode page found
[Seg Jun 30 15:02:10 2014] sd 7:0:0:0: [sde] Assuming drive cache: write back
[Seg Jun 30 15:02:10 2014]  sde: sde1 sde3
[Seg Jun 30 15:02:10 2014] sd 7:0:0:0: [sde] Attached SCSI disk
[Seg Jun 30 15:02:54 2014] FAT-fs (sde1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
[Seg Jun 30 15:02:54 2014] EXT4-fs (sde3): mounted filesystem with ordered data mode. Opts: (null)
[Seg Jun 30 15:24:51 2014] sd 7:0:0:0: Device offlined - not ready after error recovery
[Seg Jun 30 15:24:51 2014] sd 7:0:0:0: [sde] Unhandled error code
[Seg Jun 30 15:24:51 2014] sd 7:0:0:0: [sde]  
[Seg Jun 30 15:24:51 2014] usb 8-2: USB disconnect, device number 2
[Seg Jun 30 15:24:51 2014] sd 7:0:0:0: [sde] CDB: 
[Seg Jun 30 15:24:51 2014] end_request: I/O error, dev sde, sector 1100056568
[Seg Jun 30 15:24:51 2014] EXT4-fs warning (device sde3): __ext4_read_dirblock:908: error reading directory block (ino 33032637, block 0)
[Seg Jun 30 15:24:51 2014] end_request: I/O error, dev sde, sector 0
[Seg Jun 30 15:24:51 2014] sd 7:0:0:0: [sde] Synchronizing SCSI cache
[Seg Jun 30 15:24:51 2014] sd 7:0:0:0: [sde]  
[Seg Jun 30 15:24:51 2014] Buffer I/O error on device sde3, logical block 119046144
[Seg Jun 30 15:24:51 2014] lost page write due to I/O error on sde3
[Seg Jun 30 15:24:51 2014] JBD2: Error -5 detected when updating journal superblock for sde3-8.

But after using fsck, the problem diminished: now, after 10h keeping sde3 unmounted, if I try to mount it, it gives no errors! But if I forget it mounted, after some time it goes to sleep (?) and then, if I try to access it, I get some errors, it gets unmounted, it seems to restart but fail and then I am forced to reconnect the usb cable... so the problem still seems related to going sleep? not sure tho, I need to do more tests, but I think it should auto unmount if there is no activity for some time (before the sleep time), to prevent the reconnect usb problem.

Aquarius Power

Posted 2014-06-30T05:41:13.493

Reputation: 545

You gave us too little info. The problem has nothing to do with sleep, the error message talks about error recovery, not sleep. But which error is it talking about? You should post the whole output of dmesg | grep sd – MariusMatutiae – 2014-06-30T06:42:13.340

strange, this time it took 20min only and my external hdd was not acessible but it refreshed and I did not have to re-plug the usb cable at least.. I will get the log in; may be I am not still understanding how it works.. – Aquarius Power – 2014-06-30T18:59:09.930

Do you have any error message, in dmesg, about uas? uas_eh_abort, uas_eh_device, uas_eh_target? – MariusMatutiae – 2014-06-30T21:02:02.600

dmesg |grep uas -i returned nothing – Aquarius Power – 2014-06-30T23:00:54.530

I am not sure if this can help? http://askubuntu.com/questions/645/how-do-you-reset-a-usb-device-from-the-command-line

– Aquarius Power – 2014-07-01T00:16:39.223

Answers

1

There is still no obvious error in your log, execpt for a CDB error which, however, occurs after the error recovery that blocks your disk. So I suggest you install smartmontools and run smartctl on your disk. You should run the extended test, which is the most helpful,

 sudo smartctl -t log /dev/sde

This will take some time, if you want to see an estimate of how long yu can run

 sudo smartctl -c /dev/sde

before the first command, it will tell you how long it will take.

It is obvious that your disk is going offline not as a consequence of a sleep command, but because of unrecoverable errors. smartctl will help you locate all errors on your disk, of which we are already sure there are plenty.

MariusMatutiae

Posted 2014-06-30T05:41:13.493

Reputation: 41 321

wow, thx on the -c option: "Total time to complete Offline, data collection: ( 689) seconds. Short self-test routine, recommended polling time: ( 1) minutes. Extended self-test routine, recommended polling time: ( 273) minutes. Conveyance self-test routine, recommended polling time: ( 2) minutes." as I understood, it will take more than 4 hours to complete!!! :o, what about I just run fsck? – Aquarius Power – 2014-07-01T19:06:19.117

I am still making tests; I had not yet put my system under 4hours test, but I disabled the auto-mount from nautilus (ubuntu), and ran fsck.vfat on sde1; the erros are gone; I think now the problem could be related to errors; sde3 (ext4) was clean, I forced fsck and it gave a clean result; I will keep an eye on this as seem to take time to happen; if smartctl can show partial results and be interrupted I may give it a try later; other than that I need a good moment to do that 4h way; thx in advance! – Aquarius Power – 2014-07-02T20:00:50.433