If you are dual booting between Windows and Linux you may have noticed that your Bluetooth device stops working in one of the two operating systems right after you boot into it if you were previously logged into the other OS.
I had this issue happen to me with my Xbox One Bluetooth controller when I was gaming in Windows and after logging in to Linux it would constantly connect and reconnect every 1 second becoming unusable.
This is the case with all Bluetooth devices that don’t support multiple Bluetooth profiles (keyboards usually have multiple profiles that you can use to pair with different devices and change between them).
I use to pair and unpair the device each time I logged into Windows or Linux as a workaround to this issue. Until I came across a solution in a forum post which sadly I no longer have the link to. All credit however goes to the great Linux community which once again offered a solution.
Why does this happen?
In a nutshell, when you pair your device, your Bluetooth service generates a unique set of pairing keys. First, your computer stores the Bluetooth device’s MAC address (hardware address) and pairing key. Second, your Bluetooth device stores your computer’s MAC address and the matching key. This usually works fine, but the MAC address for your Bluetooth device will be the same on both Linux and Windows (as it is set on the hardware level). Thus, when you re-pair the device in Windows or Linux and it generates a new key, that key overwrites the previously stored key on the Bluetooth device. Windows overwrites the Linux key and vice versa. Thus each time you boot into an OS after you previously were logged into another OS the Bluetooth device is no longer identified (as the key was overwritten by the previous OS) and can no longer pair correctly.
How to fix
Using the instructions below, we’ll first need to pair your Bluetooth devices with Linux, and then we’ll pair Windows. Then we’ll go back into our Linux system and copy the Windows generated pairing key into the Linux system.
1. Enable Bluetooth and pair your device in Linux. Then boot into Windows and pair device in Windows.
2. You then need to copy your Windows pairing keys:
- First go to “Device & Printers” in the Control Panel and go to your Bluetooth device’s properties. In the Bluetooth section, you can find the unique identifier (MAC address). It should look like something like xxXXXXXXXXXX where the xx and XX are made of numbers and characters. Write than down (you will need it later).
- Download PsExec from this link here.
- Unzip the zip you downloaded and open a cmd window with elevated privileges. (Click the Start menu, search for “cmd”, then right-click the CMD and click “Run as Administrator“).
- Navigate to the folder where you unzipped your download and run psexec -s -i regedit.exe
- Navigate to find the keys at: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\BTHPORT\Parameters\Keys If there is no CurrentControlSet, try ControlSet001
- Write down the key associated with the unique identifier you copied in the first step above.
3. Reboot back to Linux and add your Windows key to your Linux config entries. Note: Bluetooth MAC addresses in Windows are formatted differently – referenced as xxXXXXXXXXXX as noted above. The Linux version will be in all caps and punctuated by ‘:’ after every two characters – XX:XX:XX:XX:XX:XX.
- Open a terminal and switch to root by entering su (sudo does not work)
- Find your Bluetooth config location in /var/lib/bluetooth/[Device MAC Address]
- Here you’ll find folders for each device you’ve paired with. The folder names being the Bluetooth devices’ MAC addresses and contain a single file called info. In this info file, you’ll see the link key you need to replace with your Windows one, like so:
[LinkKey]
Key=B99999999FFFFFFFFF999999999FFFFF
4. Save the file and reboot your system. That’s it. Now every time you reboot into Windows or Linux your Bluetooth device should connect and work fine.