如何在linux中永久禁用特定的USB端口?

时间:2021-01-02 23:07:15

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

是否可以永久禁用linux中的USB端口?

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.

但又没有成功。我也认为我可以通过BIOS禁用它,但我可以看到我可以禁用整个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.

..我的操作系统是Debian 7.7 64bit。我想这样做的原因是我正在尝试配置我的系统实时功能和我的USB声卡与此端口共享相同的IRQ。

2 个解决方案

#1


1  

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

首先,您应该找到设备的USB编号,只需使用lsusb即可。

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

在Linux中,一切都是文件,因此您可以使用这些文件管理所有硬件。

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

正如它描述的那样,如果你的内核是> 2.6.38,你应该使用这个关键字:

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

echo“0”>“/ sys / bus / usb / devices / usb2 / power / autosuspend_delay_ms”然后:

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

echo“auto”>“/ sys / bus / usb / devices / usb1 / power / control”

#2


0  

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

对我来说,usb安装是由服务udisk2.service处理,如果你想停止USB安装然后停止服务

root@mahasan-Inspiron-5537:~# systemctl start udisks2.service
root@mahasan-Inspiron-5537:~# systemctl disable udisks2.service

#1


1  

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

首先,您应该找到设备的USB编号,只需使用lsusb即可。

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

在Linux中,一切都是文件,因此您可以使用这些文件管理所有硬件。

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

正如它描述的那样,如果你的内核是> 2.6.38,你应该使用这个关键字:

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

echo“0”>“/ sys / bus / usb / devices / usb2 / power / autosuspend_delay_ms”然后:

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

echo“auto”>“/ sys / bus / usb / devices / usb1 / power / control”

#2


0  

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

对我来说,usb安装是由服务udisk2.service处理,如果你想停止USB安装然后停止服务

root@mahasan-Inspiron-5537:~# systemctl start udisks2.service
root@mahasan-Inspiron-5537:~# systemctl disable udisks2.service