2

Is it possible to permanently disable a usb port in linux?

I have already figured out how to disable it:

echo -n "0000:00:12.0" > /sys/bus/pci/drivers/ohci_hcd/unbind

BUT after restart it is enabled.

I have placed this script :

#!/bin/sh
case "$1" in
    resume|thaw)
            echo -n "0000:00:12.0" > /sys/bus/pci/drivers/ohci_hcd/unbind
            ;;
esac

in /etc/pm/sleep.d/0_disable_usb2

But again without success. I also thought that i could disable it through bios but as i could see i can disable the whole pci.

Is there any way of doing this?

.. My Operating system is Debian 7.7 64bit. The reason i want to do this is I am trying to configure my system for realtime capabilities and my usb soundcard sharing the same IRQ with this port.

gabriel
  • 257
  • 2
  • 4
  • 12
  • Did you try anything from this http://unix.stackexchange.com/questions/16476/disabling-usb-ports-in-linux ? – midori Nov 20 '14 at 19:42
  • @SandyElms when i execute 'echo suspend >/sys/bus/usb/devices/usb2/power/control' I am getting 'bash: echo: write error: Invalid argument ' – gabriel Nov 20 '14 at 19:57
  • @gabriel Do `lsmod`. Find your driver module for USB and add the module name in `/etc/modprobe.d/blacklist` – muradin Nov 20 '14 at 20:11
  • @muradin If the driver module for my usb is ohci_hcd and will disable it will i be able to use my other usb ports? – gabriel Nov 20 '14 at 20:17
  • @gabriel No you will not! I got your point. What is output of `lsusb | cut -f 2 -d' '` – muradin Nov 20 '14 at 21:03
  • @muradin sorry for late response.. this is my output: – gabriel Nov 20 '14 at 22:26
  • 001 002 003 004 005 006 007 004 006 – gabriel Nov 20 '14 at 22:27
  • And my usbcard is in 004 – gabriel Nov 20 '14 at 22:27
  • Well, what about doing this `echo suspend | sudo tee /sys/bus/usb/devices/usb4/power/level ` and put this script in some kind of start-up script? – muradin Nov 21 '14 at 00:42
  • @muradin when i execute 'echo suspend >/sys/bus/usb/devices/usb2/power/control' I am getting 'bash: echo: write error: Invalid argument ' – gabriel Nov 21 '14 at 02:39
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/65327/discussion-between-muradin-and-gabriel). – muradin Nov 21 '14 at 03:49

3 Answers3

1

For me usb mounting is handle by a service udisk2.service if you would like to stop usb mounting then stop below service

root@mahasan-Inspiron-5537:~# systemctl start udisks2.service
root@mahasan-Inspiron-5537:~# systemctl disable udisks2.service
Mansur Ul Hasan
  • 2,898
  • 27
  • 24
0

First of all you should find your USB number of your device, Simply by using lsusb.

And in Linux everything is a file, So you can manage all of your hardware using the files.

As it describes Here if your kernel is > 2.6.38 you should use this keywords:

echo "0" > "/sys/bus/usb/devices/usb2/power/autosuspend_delay_ms"
Then:

echo "auto" > "/sys/bus/usb/devices/usb1/power/control"

Community
  • 1
  • 1
muradin
  • 1,249
  • 2
  • 14
  • 34
  • Hey, this actually worked my usbport usb2 is disabled after reboot. And this was the question So I can mark it as solved. But what i was willing to do was to have only my usb soundcard in IRQ 16. Now The usb2 has gone but in its place usb3 appeared. Have you any idea about this? – gabriel Nov 21 '14 at 10:30
  • Let us continue this discussion in chat. – gabriel Nov 21 '14 at 10:36
  • note this does not actually disable the *port* itself, but tells the *device driver* to disable the *device*. i currently have an issue where the kernel mistakes an empty port for a device and endlessly keeps trying to handshake it, where this wouldn't work, because there's no device driver assigned yet before the (literally impossible to complete) handshake. – nonchip Jul 24 '21 at 09:23
0

echo "0" > /sys/bus/usb/devices/usb{x}/authorized

Ken Hu
  • 1