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 superuser.com as I didn't know which was more appropriate. I will delete and/or link whichever one is answered first.

  • This question seems abandoned, there is no visible activity or information added to it for several months. I have flagged a moderator and am voting for it to be closed. If you feel that the question is not abandoned and that you still suffer from this issue please flag a moderator so that it can be re-opened. – Bruno Pereira Feb 1 '12 at 18:50

Your modem driver might still be loaded. check with "sudo lsmod" which modules are using usb_storage or any other usb modules. You have to "sudo modprobe -r the other modules" first.

  • The entry for usb_storage reads: usb_storage 39425 1 Doesn't seem to indicate any dependencies? – Cory Aug 16 '10 at 12:30
  • the 1 means one module is using it. go through the lsmod list and check next to which module usb_storage appears. – Fortinator Aug 16 '10 at 12:47
  • f.e scsi_mod might use it: scsi_mod 101301 6 usb_storage,firewire_sbp2,sg,sd_mod,sr_mod,libata – Fortinator Aug 16 '10 at 12:48

Try to close any relevant service and afterwards try to remove the dependencies first.

There is always the cruel way of rmmod but i don't suggest because it could crash your system

You could also make a script that disable usb power on such cases

  • How would I disable USB power? – Cory Aug 16 '10 at 13:22
  • 1
    Either by writing a udev rule or by modifying /sys/bus/usb/devices/USBNUM/power/level With a little googling you can find it {i 'm sorry but i can't have a look at it this moment :<} – Nikolaidis Fotis Aug 16 '10 at 14:13

Not the answer you're looking for? Browse other questions tagged or ask your own question.