linux系统怎么关闭usb端口,如何在linux中永久禁用特定的USB端口?

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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
linux系统USB键盘驱动源码+使用文档说明 如何编写Linux下的USB键盘驱动 1. 指定USB键盘驱动所需的头文件: #include /*内核头文件,含有内核一些常用函数的原型定义*/ #include /*定义内存分配的一些函数*/ #include /*模块编译必须的头文件*/ #include /*输入设备相关函数的头文件*/ #include /*linux初始化模块函数定义*/ #include /*USB设备相关函数定义*/ 2. 定义键盘码表数组: /*使用第一套键盘扫描码表:A-1E;B-30;C-2E…*/ static unsigned char usb_kbd_keycode[256] = { 0, 0, 0, 0, 30, 48, 46, 32, 18, 33, 34, 35, 23, 36, 37, 38, 50, 49, 24, 25, 16, 19, 31, 20, 22, 47, 17, 45, 21, 44, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 28, 1, 14, 15, 57, 12, 13, 26, 27, 43, 43, 39, 40, 41, 51, 52, 53, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 87, 88, 99, 70,119,110,102,104,111,107,109,106, 105,108,103, 69, 98, 55, 74, 78, 96, 79, 80, 81, 75, 76, 77, 71, 72, 73, 82, 83, 86,127,116,117,183,184,185,186,187,188,189,190, 191,192,193,194,134,138,130,132,128,129,131,137,133,135,136,113, 115,114, 0, 0, 0,121, 0, 89, 93,124, 92, 94, 95, 0, 0, 0, 122,123, 90, 91, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 29, 42, 56,125, 97, 54,100,126,164,166,165,163,161,115,114,113, 150,158,159,128,136,177,178,176,142,152,173,140 }; 3. 编写设备ID表: static struct usb_device_id usb_kbd_id_table [] = { { USB_INTERFACE_INFO(3, 1, 1) },/*3,1,1分别表示接口类,接口子类,接口协议;3,1,1为键盘接口类;鼠标为3,1,2*/ { } /* Terminating entry */ }; MODULE_DEVICE_TABLE (usb, usb_kbd_id_table);/*指定设备ID表*/ 4. 定义USB键盘结构体: struct usb_kbd { struct input_dev *dev; /*定义一个输入设备*/ struct usb_device *usbdev;/*定义一个usb设备*/ unsigned char old[8]; /*按键离开时所用之数据缓冲区*/ struct urb *irq/*usb键盘之断请求块*/, *led/*usb键盘之指示灯请求块*/; unsigned char newleds;/*目标指定灯状态*/ char name[128];/*存放厂商名字及产品名字*/ char phys[64]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值