如何在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服务实现安装后系统自动生效:
在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在Archiso的
profiledef.sh中添加启用服务的命令(或在chroot阶段执行):systemctl enable ble-supervision-timeout.service
制作完成的镜像安装后,系统每次启动都会自动设置超时值为200。
方案2:现有系统设置开机自动修改
无需重新制作镜像,直接在已安装系统中创建systemd服务:
创建服务文件:
sudo nano /etc/systemd/system/ble-supervision-timeout.service写入上述相同的ini内容。
启用并立即生效:
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
相关产品推荐
相关产品推荐

