30

Possible Duplicate:
USB slots stop working suddenly from time to time

The usb ports of my laptop fail for some reason from time to time. This concerns apparently mainly the external mouse and keyboard connected by usb, while connecting an external hard disk to the same ports may activate them. All gets back to normal after restart. How could I get the same effect without restart?

Since the issue reemerges after reinstalling OS and due to random variations I have created a new question asking for a permanent solution.. In case I get an answer I will close this one.

EDIT: /sys/module/usbcore/parameters/autosuspend contais only the line 2. /sys/bus/usb/devices/usb2/power/autosuspend and /sys/bus/usb/devices/usb3/power/autosuspend contain 0 (This was verified after solving the problem by restart, not before..)

I do not see Legacy USB Support in BIOS

I have edited and updated this question because I have some answers and comments here: but for new solutions please try answering my new question.

  • See if there is Legacy USB Support in your BIOS, and enabled it if its disabled. – Mitch Aug 20 '12 at 08:56
  • What's your Laptop brand? – Mitch Aug 20 '12 at 09:27
  • @Mitch - HP Compaq nx8220. I was asking about whether I should go into bios etc now I see that's what you ment –  Aug 20 '12 at 09:39
  • @Rinzwind: did you mean the /sys/module/usbcore/parameters/autosuspend parameter? – ish Aug 20 '12 at 09:41
  • Oh OK, sorry. To test @Rinzwind 's suggestion, type this one line and run it, twice -- this disables autosuspend. See if this is the issue: for i in /sys/bus/usb/devices/*/power/autosuspend_delay_ms;do sudo sh -c "echo -1 > $i"; done – ish Aug 20 '12 at 09:59
  • @Mitch, I do not see Legacy USB Support in BIOS, see edit –  Nov 06 '12 at 07:46
  • @izx, please see edit –  Nov 06 '12 at 07:46
  • @izx, please look at my new question (http://askubuntu.com/q/206614/47206) –  Nov 06 '12 at 08:02
  • @Mitch please look at my new question (http://askubuntu.com/q/206614/47206) –  Nov 06 '12 at 08:02
  • @cipricus I'm guessing you don't want the new question to be made a duplicate of this. But is there any reason this question shouldn't be made a dupe of the newer one that's currently active? – Eliah Kagan Dec 28 '12 at 16:53
  • @Eliah Kagan: the title is too different i guess. but it could be edited. we could keep this one here too, as a duplicate, don't see no major reason against it –  Dec 28 '12 at 21:19
  • 1
    @cipricus Yeah, questions that are closed as duplicates are usually not deleted (whereas most other questions are deleted eventually). I'm out of close votes until the end of the day, but if you think it's a good idea for this question to be closed as a duplicate, I recommend flagging it for closure. – Eliah Kagan Dec 28 '12 at 21:35
  • 3
    Posting here because I have a similar issue in trusty (hence the newer question that this is marked duplicate of is not relevant, but I can't post an answer, because this one is closed). I got USB restarted with the script at http://billauer.co.il/blog/2013/02/usb-reset-ehci-uhci-linux/ - I just used sudo -s and pasted the main for loop of that script. Spits out some file-not-found errors, but still works. – naught101 Jul 20 '14 at 10:56

3 Answers3

17

Make sure that all USB devices are unplugged/safely removed and then try:

sudo modprobe -r usbhid && sleep 5 && sudo modprobe usbhid

and

sudo modprobe -r usb-storage
sudo modprobe usb-storage

This will reload the kernel modules for USB keyboards/mice and usb hdd's, and might emulate whatever it is about restarting that is fixing your problem. Good luck.

ish
  • 139,926
adempewolff
  • 11,958
  • 2
    sorry, nothing happens –  Nov 06 '12 at 07:28
  • 2
    You are the best! :D – IcyFlame Mar 25 '17 at 19:17
  • Just give it a time, in my case, I needed to wait extra 15 seconds until all my USB devices re-connected. You always can see the /var/log/syslog – Kostanos Oct 08 '17 at 00:14
  • I upvoted the answer but then I realised it doesn't work correctly. After the modprobe -r commands I can mount my external hard disk but it works painfully slowly, I still have to restart my computer. Maybe I'd have to also remove usbcore but that's built into the ubuntu kernel. – soger Oct 27 '18 at 12:44
  • Getting "modprobe: FATAL: Module usb_storage is in use." for "sudo modprobe -r usb-storage", how to deal with it? – Saren Tasciyan Jun 02 '19 at 10:23
  • @Genom Search for loaded modules depending on usb-storage (lsmod|grep usb-storage) and unload them with modprobe -r. Also make sure to close any program using whatever was on the USB device. Then you should be able to unload the usb-storage module. Nevertheless, this answer only seemed to work once for me. – Skippy le Grand Gourou Jul 22 '19 at 20:15
2

Another thing worth trying: restart the udev subsystem:

sudo restart udev

Tell us whether that one worked.

As for finding out what happens, I would start by going through the system logs. For example, when something like that happens, try

dmesg | tail

Otherwise, record the exact time, and later see in

/var/log/syslog

for example by

gksudo gedit /var/log/syslog
January
  • 35,952
  • no, nothing happens –  Nov 06 '12 at 07:29
  • happened again. reboot did not solve it, restart will. but before that (after reboot) i ran dmesg | tail and got this : http://pastebin.com/4GKkTZRt –  Nov 22 '12 at 15:24
  • 1
    Doesn't work now that Ubuntu use systemd: restart: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused. – Pablo Bianchi Sep 18 '17 at 11:59
  • 1
    It doesn't work in Ubuntu 20.04 sudo: restart: command not found – lefterav May 18 '22 at 07:55
0

a while ago I had the same problem with my openbox in Archlinux. This was due to laptop tools (or laptop mode tools) disabled the usb's after a few minutes of inactive.

The solution was to uninstall the package.