You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Arch Linux启动时修改蓝牙supervision_timeout参数?

解决BLE连接supervision_timeout默认值重置及Archiso预置问题

核心背景

/sys/kernel/debug/bluetooth/hci0/supervision_timeout是内核debugfs提供的蓝牙驱动参数,并非Bluez生成,仅当debugfs挂载且蓝牙设备初始化后才会存在,系统重启后会恢复内核默认值42。


方案1:自定义Archiso中预置启动配置

Archiso的chroot阶段未加载蓝牙硬件、未挂载debugfs,无法直接修改该文件,需通过预置systemd服务实现安装后系统自动生效:

  1. 在Archiso工作目录的airootfs下创建服务文件:

    touch airootfs/etc/systemd/system/ble-supervision-timeout.service
    

    写入以下内容:

    [Unit]
    Description=Set BLE Supervision Timeout
    After=bluetooth.service
    Requires=bluetooth.service
    
    [Service]
    Type=oneshot
    # 先确保debugfs挂载(部分系统可能默认未挂载)
    ExecStartPre=/bin/mount -t debugfs debugfs /sys/kernel/debug
    # 设置超时值为200
    ExecStart=/bin/sh -c "echo 200 > /sys/kernel/debug/bluetooth/hci0/supervision_timeout"
    RemainAfterExit=yes
    
    [Install]
    WantedBy=multi-user.target
    
  2. 在Archiso的profiledef.sh中添加启用服务的命令(或在chroot阶段执行):

    systemctl enable ble-supervision-timeout.service
    

制作完成的镜像安装后,系统每次启动都会自动设置超时值为200。


方案2:现有系统设置开机自动修改

无需重新制作镜像,直接在已安装系统中创建systemd服务:

  1. 创建服务文件:

    sudo nano /etc/systemd/system/ble-supervision-timeout.service
    

    写入上述相同的ini内容。

  2. 启用并立即生效:

    sudo systemctl enable --now ble-supervision-timeout.service
    

扩展:适配多蓝牙设备

如果系统存在多个蓝牙适配器(如hci0、hci1),修改ExecStart为遍历所有设备:

ExecStart=/bin/sh -c "for hci in /sys/kernel/debug/bluetooth/hci*; do echo 200 > \$hci/supervision_timeout; done"

内容的提问来源于stack exchange,提问作者Hunter1210

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.18 05:50:57