永久禁用内置蓝牙并使用 USB

永久禁用内置蓝牙并使用 USB

5 年后,我的笔记本电脑状况良好(仍然)。

但我的内置蓝牙不再像以前那样了(由于它的广泛使用)并且在启动时几乎无法加载。由于广泛使用,我选择购买一个 10 美元的蓝牙棒,它接替了内置蓝牙棒的工作。

然而,内置的大多不亮,但有时仍会发出火花。有时候它真的很烦人,因为它只会破坏我的设置并覆盖一些东西。

我的问题:如何确保内置蓝牙永久禁用,而 USB 设备仍然能够发送我的音频/指点设备/...。

系统:Linux Mint 18(基础:Ubuntu 16.04)

lsusb 输出:

jeroen@laptop ~ $ lsusb
Bus 002 Device 002: ID 5986:02ac Acer, Inc 
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 002: ID 138a:0018 Validity Sensors, Inc. Fingerprint scanner
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
(Built-in BT) Bus 003 Device 004: ID 0a5c:21b4 Broadcom Corp. BCM2070 Bluetooth 2.1 + EDR
(USB-BT) Bus 003 Device 006: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 008 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 007 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 006 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

更新:测试输出

(根据德克特的要求)

jeroen@laptop ~ $ sudo hcitool dev
Devices:
    hci0    00:1B:DC:0F:73:5D
    hci1    CC:52:AF:A8:71:B5
## Plugged out the USB-BT dongle
jeroen@laptop ~ $ sudo hcitool dev
Devices:
    hci1    CC:52:AF:A8:71:B5
## Plugged in the USB-BT dongle
jeroen@laptop ~ $ sudo rfkill list
0: phy0: Wireless LAN
    Soft blocked: no
    Hard blocked: no
1: brcmwl-0: Wireless LAN
    Soft blocked: no
    Hard blocked: no
4: hp-wifi: Wireless LAN
    Soft blocked: no
    Hard blocked: no
5: hp-bluetooth: Bluetooth
    Soft blocked: no
    Hard blocked: no
6: hci1: Bluetooth
    Soft blocked: no
    Hard blocked: no
8: hci0: Bluetooth
    Soft blocked: no
    Hard blocked: no
jeroen@laptop ~ $ sudo rfkill block 5
jeroen@laptop ~ $ sudo rfkill list
0: phy0: Wireless LAN
    Soft blocked: no
    Hard blocked: no
1: brcmwl-0: Wireless LAN
    Soft blocked: no
    Hard blocked: no
4: hp-wifi: Wireless LAN
    Soft blocked: no
    Hard blocked: no
5: hp-bluetooth: Bluetooth
    Soft blocked: no
    Hard blocked: no
6: hci1: Bluetooth
    Soft blocked: no
    Hard blocked: no
8: hci0: Bluetooth
    Soft blocked: no
    Hard blocked: no
jeroen@laptop ~ $ sudo rfkill block 6
jeroen@laptop ~ $ sudo rfkill list
0: phy0: Wireless LAN
    Soft blocked: no
    Hard blocked: no
1: brcmwl-0: Wireless LAN
    Soft blocked: no
    Hard blocked: no
4: hp-wifi: Wireless LAN
    Soft blocked: no
    Hard blocked: no
5: hp-bluetooth: Bluetooth
    Soft blocked: no
    Hard blocked: no
6: hci1: Bluetooth
    Soft blocked: yes
    Hard blocked: no
8: hci0: Bluetooth
    Soft blocked: no
    Hard blocked: no
jeroen@laptop ~ $ sudo rfkill block 8
jeroen@laptop ~ $ sudo rfkill list
0: phy0: Wireless LAN
    Soft blocked: no
    Hard blocked: no
1: brcmwl-0: Wireless LAN
    Soft blocked: no
    Hard blocked: no
4: hp-wifi: Wireless LAN
    Soft blocked: no
    Hard blocked: no
5: hp-bluetooth: Bluetooth
    Soft blocked: no
    Hard blocked: no
6: hci1: Bluetooth
    Soft blocked: yes
    Hard blocked: no
8: hci0: Bluetooth
    Soft blocked: yes
    Hard blocked: no
jeroen@laptop ~ $ sudo rfkill unblock 8
jeroen@laptop ~ $ sudo rfkill list
0: phy0: Wireless LAN
    Soft blocked: no
    Hard blocked: no
1: brcmwl-0: Wireless LAN
    Soft blocked: no
    Hard blocked: no
4: hp-wifi: Wireless LAN
    Soft blocked: no
    Hard blocked: no
5: hp-bluetooth: Bluetooth
    Soft blocked: no
    Hard blocked: no
6: hci1: Bluetooth
    Soft blocked: no
    Hard blocked: no
8: hci0: Bluetooth
    Soft blocked: no
    Hard blocked: no
jeroen@laptop ~ $ sudo rfkill unblock 6
jeroen@laptop ~ $ sudo rfkill list
0: phy0: Wireless LAN
    Soft blocked: no
    Hard blocked: no
1: brcmwl-0: Wireless LAN
    Soft blocked: no
    Hard blocked: no
4: hp-wifi: Wireless LAN
    Soft blocked: no
    Hard blocked: no
5: hp-bluetooth: Bluetooth
    Soft blocked: no
    Hard blocked: no
6: hci1: Bluetooth
    Soft blocked: no
    Hard blocked: no
8: hci0: Bluetooth
    Soft blocked: no
    Hard blocked: no
jeroen@laptop ~ $ sudo rfkill unblock 5
jeroen@laptop ~ $ sudo rfkill list
0: phy0: Wireless LAN
    Soft blocked: no
    Hard blocked: no
1: brcmwl-0: Wireless LAN
    Soft blocked: no
    Hard blocked: no
4: hp-wifi: Wireless LAN
    Soft blocked: no
    Hard blocked: no
5: hp-bluetooth: Bluetooth
    Soft blocked: no
    Hard blocked: no
6: hci1: Bluetooth
    Soft blocked: no
    Hard blocked: no
8: hci0: Bluetooth
    Soft blocked: no
    Hard blocked: no

答案1

您可以创建udev规则来禁用内部蓝牙。

首先通过运行并找到正确的行来找到您想要禁用的 USB 设备idVendor。例如,在我的系统上,这是我想要禁用的适配器的匹配行:idProductlsusb

Bus 004 Device 006: ID 0b05:179c ASUSTek Computer, Inc. Bluetooth Adapter

然后将以下内容放入 中/etc/udev/rules.d/81-bluetooth-hci.rules,记下上面的0b05和值:179c

SUBSYSTEM=="usb", ATTRS{idVendor}=="0b05", ATTRS{idProduct}=="179c", ATTR{authorized}="0"

此时,您可以重新启动,您的设备不应再显示在 的输出中hciconfig -a,并且您插入的任何其他蓝牙设备(假设它不是同一供应商+产品ID!)将显示为hci0

如果您不想重新启动,您可以尝试重新初始化设备,首先拔掉任何其他蓝牙适配器,然后以 root 身份运行:

udevadm trigger
rmmod btusb

现在插入新的蓝牙适配器并享受保留的正常运行时间(或者如果不起作用,请重新启动!)。

解决方案找到于询问Ubuntu

答案2

选项 1:使用rfkill.

这将禁用被阻止的设备上的传输,并且通常还会使驱动程序处于“关闭”状态。rfkill help对于命令,rfkill list列出可以 rfkill 的设备,rfkill block <index>|<type>以阻止它。您可能需要一个索引,并且我不知道索引是否在引导之间保持一致,因此您可能需要使用 等编写一个小脚本grepcut确保安全。您可能需要安装该rfkill命令的包。

编辑:如果您担心更改索引,请执行以下操作

HCI=`hcitool dev | grep '00:11:22:33:44:55' | cut -f2`
INDEX=`rfkill list | grep $HCI | cut -d: -f1`

(但当然是你的内部蓝牙适配器的MAC地址),并且$INDEX应该包含它的索引。我无法对此进行测试,因为我没有具有多个蓝牙适配器的硬件。

另一种方法是使用乌德夫为已知适配器创建特殊名称的规则,但这可能比使用上面两行更难弄清楚。

最后,除了使用之外别无选择rfkill内核功能可以完全禁用蓝牙无线电,尽管我不知道可能还有其他命令行界面。

选项2:黑名单内核模块

如果启动后内置蓝牙设备处于禁用状态,并且内核驱动程序被编译为模块,则可以通过将其列入黑名单来阻止驱动程序加载和启用该设备。用于lsmod列出当前加载的模块,并在启动后查看dmesg系统日志以识别内置蓝牙设备的驱动程序。将其列入黑名单取决于您使用的发行版,例如在 Debian(也可能是 Ubuntu)上,创建一个/etc/modprobe.d/包含行blacklist <modulname>.man modprobe.d详情请参阅。

如果内置蓝牙设备在启用状态下启动,将驱动程序列入黑名单将阻止您使用它,但如果它损坏,它仍可能传输内容。

相关内容