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.

It is possible for a USB storage device to become logically disconnected: the device is still plugged in, but is invisible from the operating system (e.g. it's not listed under /proc/bus/usb). Maybe this can happen to other kinds of USB or other removable devices as well. This can happen for example:

  • after Nautilus has unmounted a USB storage device;
  • after VirtualBox has claimed a USB storage device (the device disappears from the Linux host when it is attached in the guest, and does not automatically reappear if it is detached from the guest).

What is going on in the driver or in the hardware, and most importantly, (how) can the device be logically reconnected (without physically plugging it out and back in)?

Note that this question is not about mounting. In the “logically disconnected” state, the kernel believes there is nothing on the USB bus (and so of course there is no entry under /dev).

share|improve this question

5 Answers 5

It is sometimes possible to do a power cycle on branch of the USB bus where the device is plugged :

# echo suspend > /sys/bus/usb/devices/1-1/power/level
# echo auto > /sys/bus/usb/devices/1-1/power/level

The 1-1 should be adjusted to your configuration. You can see to which part of the USB tree your device is plugged by running lsusb -t before ejecting it.

You can find detailed information on the linux-usb mailing-list, this thread for example.

share|improve this answer
    
+1 If this works, it's cool. A little bit of a blunt tool, but still useful in some cases :) –  Johan Feb 16 '11 at 8:30
    
"suspend" doesn't work on kernels after 2.6.36. –  alexisdm Jan 31 at 13:14
    
Assuming dmesg reports the correct device ID ("usb 9-4: USB disconnect [...]"), this does not work on latest Arch Linux. There is no path /sys/bus/usb/devices/9-4 afterwards. –  l0b0 Mar 21 at 7:07

I'm uncertain that I'm properly understanding your question, but on my system if a usb device is plugged in but not mounted I can 'see it' by

$> fdisk -l

That tells me what device it's associated with (i.e. /dev/sdd1 or something), then I manually mount it.

share|improve this answer
4  
Again: no, the question is not about a filesystem becoming inaccessible (i.e. unmounted), it's about a device becoming inaccesible (the kernel doesn't see a device, so of course there is no entry under /dev). –  Gilles Feb 16 '11 at 8:22

Reset the device, or the hub it is connected to, and the device should reappear. Here is a small program to do that:

http://marc.info/?l=linux-usb-users&m=116827193506484

It works for most USB drives I've tried, but there are exceptions, like my Kingston DT 101 II 4GB, which fails INQUIRY and READ CAPACITY commands after reset, and remains unusable until power-cycled.

You can power-cycle the device without unplugging if it gets power from the port, and your USB hub supports per-port power control. Here is a small program to control the power:

http://marc.info/?l=linux-usb-devel&m=113724451205634

Unfortunately, almost no USB hubs support this feature, and it's very difficult to find one that supports it. Manufacturers do not advertise it. Many hubs also lie about it, for example if you do "lsusb -v" you can see "Per-port power switching" advertised in "wHubCharacteristic", but in reality it does not work. The chipset may support it, but it was easier/cheaper for the manufacturer to connect port power pins directly to the power supply instead of going through the chipset.

share|improve this answer

I found this answer to work great on my Gentoo system. Please also remember to re-enable your device if it's an important piece of your system (e.g. mouse or keyboard).

sudo sh -c 'AUTHFILE="/sys/bus/usb/devices/5-2/authorized" ; echo 0 > "$AUTHFILE" ; sleep 1 ; echo 1 > "$AUTHFILE"'

To see what you're disabling/re-enabling:

cat /sys/bus/usb/devices/5-2/product
share|improve this answer

I have tried most of the above suggestions, but they didn't work for me. I found how to reset a USB device from the command line: http://askubuntu.com/a/290519

echo $i >/sys/bus/pci/drivers/ehci_hcd/bind

where $i you can use appropriate device ID from /sys/bus/pci/drivers/ehci_hcd.

share|improve this answer
    
Please post more than the link; include some detail so people don't have to click through to for an answer. –  jasonwryan Feb 21 at 22:37

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.