Score:0

Bluetooth only works after reloading module btusb

ar flag

I have an ASUS PCE-AX3000 with Wifi and bluetooth, however, the bluetooth part is connected internally to a USB bus. Often when I boot/reboot, bluetooth is not working and I can only get it to work if I manually run the following command:

sudo modprobe -r btusb && sudo modprobe btusb

This removes the btusb module and loads it again afterwards. Once it has been loaded with this method it works until I may do another reboot or boot again some other time.

It is very annoying having to do this whenever I want to use my bluetooth headset or a bluetooth controller for gaming. For me it is doable, but I would like to get a method where it loads correctly on boot. Probably through systemd, because if I add the command in /etc/profile or similar it is not working. I have to wait just a very short while before I run the command.

My system is Ubuntu 20.04 LTS currently with kernel: 5.13.0-25-generic

Score:0
lu flag

You can do this with systemd-service. In order to do so, you have to create a .service file in /etc/systemd/system and a script that actually executes the command.

I am not sure if my instructions are best practice but maybe somebody can correct me.

We first need the .service file. I created it with this command: sudo nano /etc/systemd/system/reload-bt-mod.service

In this file we need to have a [Unit], a [Service] and a [Install] section:

[Unit]
Description=Reload Bluetooth Kernel module
#You can enter a custom description here

[Service]
Type=oneshot
#This type is used for services that normally run only once
RemainAfterExit=no
#If set to yes, the service will be shown as run after it finished
ExecStart=/usr/local/bin/reloadbtmod
#This points to the script that we want to be executed

[Install]
WantedBy=multi-user.target
#When this service will be started

(More information on the parameters in this file can be found here. More information on WantedBy=multi-user.target here)

Save it and next lets create the script file that is executed. I did that with this command: sudo nano /usr/local/bin/reloadbtmod

And there we just add the content we need:

#!/bin/bash
#sleep 30s #Delays the execution by 30 seconds
sudo modprobe -r btusb
sudo modprobe btusb

We need this file to be executable and therefore enter this command:

sudo chmod +x /usr/local/bin/reloadbtmod

You can try if the script works by calling it from the terminal.

Now we only need to enable the systemd service (by enabling it, it will be started on system start):

sudo systemctl enable reload-bt-mod.service

Finished!

Now you can reboot and try if it works. Execute systemctl status reload-bt-mod.service to get information on the service.

If it starts to early (however one would know that) you'd need to tinker with the WantedBy value or uncomment the #sleep 30s in the script.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.