是否可以关闭特定的USB端口,使其不接受任何设备?

我的电脑上有很多端口。 我想关闭其中一个,所以当我将手机连接到该端口时,它只会收费。 我确实希望我的手机在某些情况下可以使用我的电脑,所以我希望其他端口不受影响。

我想知道这是多么可能。

首先,运行lsusb

输出应该像:

 Bus 001 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub Bus 002 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 001 Device 003: ID 2232:1020 Bus 002 Device 009: ID 0bc2:a013 Seagate RSS LLC Bus 002 Device 003: ID 0a5c:219c Broadcom Corp. 

在输出中,找到要禁用的端口的设备编号。 例如,示例中的Seagate驱动器具有Device 009 – 即其设备编号。 然后id将是usb[device number] – 例如usb9

然后,禁用USB唤醒(仅执行一次):

务必将usbX中的X替换为设备编号。

 echo disabled | sudo tee /sys/bus/usb/devices/usbX/power/wakeup 

然后将其关闭:

 echo suspend | sudo tee /sys/bus/usb/devices/usbX/power/level 

撤消这个:

 echo enabled | sudo tee /sys/bus/usb/devices/usbX/power/wakeup echo on | sudo tee /sys/bus/usb/devices/usbX/power/level