How do I reset an USB device without unplugging it in Linux?
Solution 1:
You could try Benjamin Close's resetusb
program to reset all devices — there are no binaries available, but compiling it is rather easy. Save the source code as resetusb.c
, then run:
gcc -lusb resetusb.c -o resetusb
You can now run the tool as resetusb
. Alternatively, @unhammer points to Alan Stern's single-device version (plus some hints on how to use it).
Some people have also had luck just removing and modprobe
-ing the relevant modules:
modprobe -vr ehci_hcd
modprobe -v ehci_hcd
(you could of course script this)
Some distributions may also have their own tools to restart the USB subsystem; Mandrake apparently has /etc/init.d/usb
.
Solution 2:
Let's say I want to reset /dev/sdc
.
# udevadm info -q all /dev/sdc | grep DEVPATH
E: DEVPATH=/devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1.4/2-1.4:1.0/host2/target2:0:0/2:0:0:0/block/sdc
I take the 2-1.4
above (yours might just be 2-1
- my device is plugged into a hub) and do:
# echo 2-1.4 > /sys/bus/usb/drivers/usb/unbind
# echo 2-1.4 > /sys/bus/usb/drivers/usb/bind
Solution 3:
You can restart the hardware abstraction layer: sudo /etc/init.d/hal restart