#!/bin/SH# Usage:./resetusb ARGUMENT (the keyword for your USB device)
Var1=$1keyword=${var1:=Storage}debug=$ (LSUSB) bus=$ (lsusb|grep$keyword |Perl-ne"/\d+ (\d+) \d+ (\d+) +/; print QQ (\$1)") Device=$ (lsusb|grep$keyword |Perl-ne"/\d+ (\d+) \d+ (\d+) +/; print QQ (\$2)")Echo "/ * Usbreset--Send a USB port reset to a USB device * /#include<stdio.h>#include<unistd.h>#include<fcntl.h>#include<errno.h>#include<sys/ioctl.h>#include<linux/usbdevice_fs.h>intMainintargcChar**argv) {ConstChar*filename; intFD; intRC; if(ARGC! =2) {return1; } filename= argv[1]; FD=open (filename, o_wronly); if(FD <0) {return1; } RC= IOCTL (FD, Usbdevfs_reset,0); if(RC <0) {return1; } close (FD); Return0;}">/tmp/usbreset.c$(cc/tmp/usbreset.c-o/tmp/usbreset) $ (chmod+x/tmp/usbreset) $ (CD/tmp/;. /usbreset/dev/bus/usb/$bus/$device) Result=$?if[$result! =0]; Then Echo "Reset USB failed!" Echo "Please do sure inputted right device keyword: $keyword" Echo "You have chose Bus:${bus:=not found},device:${device:=not Found}" Echo "More Info:\n$debug"Else Echo "Reset Usb $keyword successfully!"fi
You can re-identify the USB device without having to pull the disk in Ubuntu