Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a USB device (a modem) that is really finicky. Sometimes it works fine, but other times it refuses to connect. The only solution I have found to fix it once it gets into a bad state is to physically unplug the device and plug it back in. However, I don't always have physical access to the machine it is plugged in on, so I'm looking for a way to do this through the command line.

This post suggests running:

$ sudo modprobe -w -r usb_storage; sudo modprobe usb_storage

However I get an "unknown option -w" output. This slightly modified command:

$ sudo modprobe -r usb_storage

Fails with the message FATAL: Module usb_storage is in use. If I try to kill -9 the processes marked [usb-storage] before running they refuse to die (I think because they are deeply tied to the kernel).

Anyone know of a way to do this?

NOTE: I cross-posted this on serverfault as I didn't know which was more appropriate. I will delete and/or link whichever one is answered first.

share|improve this question
    
i guess, if you don't have physical access to a machine i'll classify it as a server of some sort. there is little point keeping failing hardware on a server. –  bubu Dec 23 '10 at 9:35
    
bubu, it depends on what you mean by "failing". It sounds to me like the device is working fine, but has poor Linux support. –  nitro2k01 Nov 25 '13 at 13:08
    
@nitro2k01 This question is 3 years old... Anyways the device is failing as it can connect sometimes but not always... The asker is trying to reset the wrong device so it can't work and has nothing to do with linux support... –  laurent Nov 25 '13 at 13:55
add comment

4 Answers 4

Why are you trying to unload the usb_storage module, when your device is a usb modem?

run sudo lshw and find the entry for your usb modem. There should be a configuration: line like this (your driver will be different, obviously):

configuration: ... driver=iwlagn ...

confirm that the module is loaded (substituting in the correct driver name):

lsmod | grep iwlagn

then just do:

sudo modprobe -r iwlagn && sleep 2 && sudo modprobe iwlagn

I like to put the sleep in there just in case the device takes some time to power down.

share|improve this answer
    
lshw seems to indicate that the driver is using usb_storage (the modem also mounts itself as a disk). I can't find a separate entry for the modem part of it. How could I kill the process so that I can reload the driver? –  Cory Aug 16 '10 at 12:27
add comment

This is a "way out there" solution, but it might work.

  • Get a second, old, not-very-powerful PC. Install Debian on it. Install usbip on it.
  • Then, install usbip on your server.
  • Connect the modem to the second PC. Configure usbip on both machines so that the modem, plugged into the second PC, is reachable via VHCI from the server.
  • Configure ssh on the second PC or other means that you can remote into it and issue commands.
  • When the device fails, log in and reboot the second PC via the reboot command, then once it comes back up, reconnect using whatever facilities usbip provides (I've never actually used usbip). That should reset the device. You probably could script this.
share|improve this answer
add comment

easiest way to power off arbitrary USB devices from the command line (i.e. with real power cycle to USB):

  1. buy a 4-port DELOCK 87445 USB hub (google for < DELOCK 87445 >)
  2. this piece of hardware is compatible with hub-ctrl.c (google for < hub-ctrl.c>). So arbitrary ports can be switched on/off. For further reference also see: http://code.google.com/p/wl500g/source/browse/branches/rt-n/utils/hub-ctrl.c?r=2235
share|improve this answer
add comment

You can try to reset the usb device by using usbreset. Here's a link to the source -- http://marc.info/?l=linux-usb&m=121459435621262&w=2

You just look for a device you want to reset (lsusb):

# lsusb
Bus 005 Device 004: ID 0951:1642 Kingston Technology DT101 G2

and then:

# usbreset /dev/bus/usb/005/004
share|improve this answer
add comment

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.