Hard Reset USB in Ubuntu 10.04

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.


I have Ubuntu 14.04.4. I have no idea if this works in 10.04. I tested it on Cyborg Rumble Pad (and a generic USB flash drive).

Just after I connect the device:

dmesg | grep usb | tail -n 20

I get (maybe among other things):

[ 2875.790610] usb 2-1.2: new full-speed USB device number 7 using ehci-pci
[ 2875.887485] usb 2-1.2: New USB device found, idVendor=0738, idProduct=cb02
[ 2875.887489] usb 2-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 2875.887490] usb 2-1.2: Product: Cyborg Rumble Pad - PC/Xbox 360
[ 2875.887492] usb 2-1.2: Manufacturer: Saitek
[ 2875.887493] usb 2-1.2: SerialNumber: 0CFE6B97

The crucial part is 2-1.2 string. It identifies the USB port. Good news is it should not change unless I plug the device into another port, so I need to obtain the string just once.

Next I go to the right place:

cd /sys/bus/usb/drivers/usb

and invoke as root (e.g. sudo bash first):

echo 2-1.2 > unbind ; sleep 3 ; echo 2-1.2 > bind

The result is my Rumble Pad reinitializes itself as if it was plugged out and in again. I tested my USB flash drive as well. It (its LED) behaves as if nothing happened, still my KDE reacts and asks if I want to mount.

All the time the device is powered. This method will not work if your modem resets itself because of the lack of power.


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