LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   USB Hard Drive disconnects (https://www.linuxquestions.org/questions/linux-hardware-18/usb-hard-drive-disconnects-692733/)

dkinfl 12-24-2008 07:54 AM

USB Hard Drive disconnects
 
We have 32 red hat linux 4 servers, each with western digital USB hard drives that have their own power supplies (NOT bus powered). The drives are only used nightly when a script runs to backup some data. Occasionally, on most of these servers, the drives "disconnect" and are missing from the /dev directory. The drives are mounted using the fstab, so a reboot of the server detects them and mounts them promptly. But, obviously a reboot is not a desirable thing.

Is there a command or something similar that will cause the server to re-detect the drive? I have only SSH access to the boxes. My thought is if there is such a command I could add it to my nightly backup script to correct a drive issue before the backup occurs.

Any info would be appreciated.

Thanks.

tredegar 12-24-2008 08:42 AM

Maybe mount -a ?
See man mount

dkinfl 12-24-2008 08:54 AM

That would work if the device was seen by the OS. I get the following:

[root@host ~]# mount -a
mount: special device /dev/sdb1 does not exist


It is like the USB drives are "sleeping" or some such thing causing the OS to not see them any more. I guess I need a way to tell Linux to rescan the USB ports to re-detect the drives. Unplugging and plugging back in the drive or rebooting the server causes the drive to be recognized, so I have to believe there is some kind of command available.

rizwanrafique 12-24-2008 09:20 AM

I had similar issue with a USB hard drive recently. (to my understanding) what happens is that hard drive spins down (effectively goes to sleep???). I couldn't find any affective solution to solve that but got around it by writing a cron job that runs every minute and just touches a file in the hard drive. The shell script looks like:

Code:

#!/bin/bash
touch /media/my_book/.keephdactive

and cron job is:
Code:

m h  dom mon dow  command
* * * * * /usr/bin/name_of_script

Another thing that I found useful was to mount the drive by its UUID. That provides solution of different drive name (sdc/sdd/sde etc).

tredegar 12-24-2008 09:24 AM

Quote:

It is like the USB drives are "sleeping"
Ah.
Maybe they have powered down to save wear, tear & power. (But I am surprised that they have "disconnected" from the USB bus.)

This behaviour can be changed with hdparm (but only when the device is recognised as being connected)

When the drive is "sleeping", and not seen at /dev/sdb1 has it been mounted somewhere else (eg /dev/sdc1) ?

When the drive is "sleeping" is it seen by lsusb ?

Is there anything interesting in /var/log/messages when a drive goes to sleep ?

dkinfl 12-24-2008 11:30 AM

the drive does not get remounted as any other device. /var/log/messages output below

Nov 30 15:07:23 host kernel: usb 1-6: USB disconnect, address 15
Nov 30 15:07:23 host kernel: scsi13 (0:0): rejecting I/O to dead device
Nov 30 15:07:23 host kernel: Buffer I/O error on device sdb1, logical block 1548
Nov 30 15:07:23 host kernel: lost page write due to I/O error on sdb1
Nov 30 15:07:23 host kernel: scsi13 (0:0): rejecting I/O to dead device
Nov 30 15:07:23 host kernel: Buffer I/O error on device sdb1, logical block 1548
Nov 30 15:07:23 host kernel: lost page write due to I/O error on sdb1
Nov 30 15:07:23 host kernel: scsi13 (0:0): rejecting I/O to dead device
Nov 30 15:07:23 host kernel: Buffer I/O error on device sdb1, logical block 1548
Nov 30 15:07:23 host kernel: lost page write due to I/O error on sdb1
Nov 30 15:07:23 host kernel: scsi13 (0:0): rejecting I/O to dead device
Nov 30 15:07:23 host kernel: Buffer I/O error on device sdb1, logical block 0
Nov 30 15:07:23 host kernel: lost page write due to I/O error on sdb1
Nov 30 15:07:24 host kernel: usb 1-6: new high speed USB device using address 16
Nov 30 15:07:24 host kernel: scsi14 : SCSI emulation for USB Mass Storage devices
Nov 30 15:07:29 host kernel: Vendor: WDC WD25 Model: 00BB-55RDA0 Rev: 20.0
Nov 30 15:07:29 host kernel: Type: Direct-Access ANSI SCSI revision: 02
Nov 30 15:07:29 host kernel: usb 1-6: control timeout on ep0in
Nov 30 15:07:29 host kernel: SCSI device sdb: 488397168 512-byte hdwr sectors (250059 MB)
Nov 30 15:07:29 host kernel: sdb: assuming drive cache: write through
Nov 30 15:07:29 host kernel: sdb: sdb1
Nov 30 15:07:29 host kernel: Attached scsi disk sdb at scsi14, channel 0, id 0, lun 0
Nov 30 15:07:29 host kernel: Attached scsi generic sg2 at scsi14, channel 0, id 0, lun 0, type 0
Nov 30 15:07:30 host scsi.agent[23366]: disk at /devices/pci0000:00/0000:00:1d.7/usb1/1-6/1-6:1.0/host14/target14:0:0/1
4:0:0:0
Nov 30 15:07:43 host kernel: usb 1-6: reset high speed USB device using address 16
Nov 30 15:10:06 host kernel: usb 1-6: USB disconnect, address 16
Nov 30 15:10:07 host kernel: usb 1-6: new high speed USB device using address 17
Nov 30 15:10:07 host kernel: scsi15 : SCSI emulation for USB Mass Storage devices
Nov 30 15:10:12 host kernel: usb 1-6: control timeout on ep0in
Nov 30 15:10:12 host kernel: Vendor: WDC WD25 Model: 00BB-55RDA0 Rev: 20.0
Nov 30 15:10:12 host kernel: Type: Direct-Access ANSI SCSI revision: 02
Nov 30 15:10:12 host kernel: SCSI device sdb: 488397168 512-byte hdwr sectors (250059 MB)
Nov 30 15:10:12 host kernel: sdb: assuming drive cache: write through
Nov 30 15:10:12 host kernel: sdb: sdb1
Nov 30 15:10:12 host kernel: Attached scsi disk sdb at scsi15, channel 0, id 0, lun 0
Nov 30 15:10:12 host kernel: Attached scsi generic sg2 at scsi15, channel 0, id 0, lun 0, type 0
Nov 30 15:10:12 host scsi.agent[23716]: disk at /devices/pci0000:00/0000:00:1d.7/usb1/1-6/1-6:1.0/host15/target15:0:0/1
5:0:0:0
Nov 30 15:10:26 host kernel: usb 1-6: reset high speed USB device using address 17

tredegar 12-24-2008 12:19 PM

Quote:

Nov 30 15:07:23 host kernel: usb 1-6: USB disconnect, address 15
Nov 30 15:07:23 host kernel: scsi13 (0:0): rejecting I/O to dead device
Looks like the device disconnected and "died".
Quote:

Nov 30 15:10:12 host kernel: Attached scsi disk sdb at scsi15, channel 0, id 0, lun 0
And was then reattached 11 seconds later. Strange.

Did you get anywhere with hdparm ?

Look carefully at the -B and -S options.

dkinfl 02-13-2009 11:35 AM

Solved!
 
I found the solution to this (at least for the Red Hat dirsto, 4 and 5). The hdparm command did not work on the disk since it was USB (at least that is my theory).

Instead, I made the following change, and so far no disconnects.

I modified the file /etc/modprobe.conf

I added this line to the end:
options usbcore autosuspend=-1

So far this seems to have worked. It has been implemented for two weeks and no HD disconnects. It does seem to require a reboot however to take effect.

Thanks for everyone's input on this.

tredegar 02-13-2009 12:02 PM

Thanks for the follow-up with your solution.


All times are GMT -5. The time now is 04:18 AM.