Laptop USB ports stop working: how to restart them without restarting the PC?

73,841

Solution 1

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.

Solution 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
Share:
73,841

Related videos on Youtube

Community
Author by

Community

Updated on September 18, 2022

Comments

  • Community
    Community over 1 year

    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.

    • Admin
      Admin over 11 years
      See if there is Legacy USB Support in your BIOS, and enabled it if its disabled.
    • Admin
      Admin over 11 years
      What's your Laptop brand?
    • Admin
      Admin over 11 years
      @Mitch - HP Compaq nx8220. I was asking about whether I should go into bios etc now I see that's what you ment
    • Admin
      Admin over 11 years
      @Rinzwind: did you mean the /sys/module/usbcore/parameters/autosuspend parameter?
    • Admin
      Admin over 11 years
      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
    • Admin
      Admin over 11 years
      @Mitch, I do not see Legacy USB Support in BIOS, see edit
    • Admin
      Admin over 11 years
      @izx, please see edit
    • Admin
      Admin over 11 years
      @izx, please look at my new question (askubuntu.com/q/206614/47206)
    • Admin
      Admin over 11 years
      @Mitch please look at my new question (askubuntu.com/q/206614/47206)
    • Admin
      Admin over 11 years
      @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?
    • Admin
      Admin over 11 years
      @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
    • Admin
      Admin over 11 years
      @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.
    • Admin
      Admin almost 10 years
      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 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.
  • Admin
    Admin over 11 years
    sorry, nothing happens
  • Admin
    Admin over 11 years
    no, nothing happens
  • Admin
    Admin over 11 years
    laptop-mode-tools is not installed here
  • Admin
    Admin over 11 years
    happened again. reboot did not solve it, restart will. but before that (after reboot) i ran dmesg | tail and got this : pastebin.com/4GKkTZRt
  • IcyFlame
    IcyFlame about 7 years
    You are the best! :D
  • Pablo Bianchi
    Pablo Bianchi over 6 years
    Doesn't work now that Ubuntu use systemd: restart: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused.
  • Kostanos
    Kostanos over 6 years
    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
  • soger
    soger over 5 years
    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.
  • Saren Tasciyan
    Saren Tasciyan almost 5 years
    Getting "modprobe: FATAL: Module usb_storage is in use." for "sudo modprobe -r usb-storage", how to deal with it?
  • Skippy le Grand Gourou
    Skippy le Grand Gourou almost 5 years
    @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.
  • Admin
    Admin about 2 years
    It doesn't work in Ubuntu 20.04 sudo: restart: command not found