Solve the Bluetooth Re-pairing Nightmare on Dual Boot Systems

Say Goodbye to Bluetooth Re-pairing on Dual Boot Systems : A Step-by-Step Guide

Ashwin Bhargava
4 min readSep 24, 2022

I am using dual boot systems for years now. Also, i am a fan of wired devices over wireless ones. Sometime ago i acquired a wireless headset and encountered a problem on dual boot systems, where whenever i use to switch OS, a re-pairing of bluetooth was required.

This is not a specific OS problem or device problem, this issue will persist on every dual boot system.

I tried to find its sollution in videos and articles but either the information was so old that it became irrelevent or it did not worked at all. So i did some miner tweaks in the provided solution to make it work.

Why does it happen ?

When you pair a bluetooth device, the OS and the bluetooth device both save each other’s mac addresses and same pairing key. When next time bluetooth device tries to connect, it searches for the mac address of your computer and automatically connects if the pairing keys are same.

When you pair your bluetooth again using another OS on the same computer, the pairing key is generated again. Now the problem here is that because mac address will stay the same for your computer’s bluetooth port irrespective of your OS, the bluetooth device will keep the same mac address but rewrite the pairing key with the newly generated one in its memory. And now when you try to connect the bluetooth device in the previous OS, it will fail as the pairing key in your bluetooth device has now changed and thus does not matches.

Solution

If one understood why it happens one can foresee the solution itself. What needs to be done here is copy the pairing key from the OS you last connected your bluetooth device and paste it in the other OS with the outdated key. Though the solution flow is simple, it can be an irritating process if ‘windows’ is involved.

Process

If you follow every point your bluetooth will automatically connect to your OS. No need of pairing everytime you switch OS. But if you need concise instructions you may check out this github link. Just make sure to follow first 3 points.

  • Pair the device on linux.
  • Log in and pair the device on windows. Bluetooth device will now rewrite the pairing key in its memory. Windows and BT device now have the latest key and linux has the outdated one.
  • Log back in to linux and DO NOT PAIR YOUR BLUETOOTH. Instead of generating a new key we will copy the windows’s one and paste it in linux.
  • Mount windows drive and cd into[windowsDrive]/Windows/System32/config
  • install ‘chntpw’ by sudo apt install chntpw to access windows registry values from linux.
  • chntpw -e systemcommand will now open a new environment.
  • cd ControlSet001\Services\BTHPORT\Parameters\Keys will get you to the bluetooth keys.
  • ls to get key name and cd into it.
  • ls again to get value names. Every value here defines a different bluetooth device. In my case it is 3. One of them is my headphone and two of them are my friend’s wireless speakers. cat command can be used to get pairing key for each of them.
  • Open a different terminal with root privileges. and cd into /var/lib/bluetooth
  • ls to get mac address and cd into address.
  • In there you will get all the bluetooth devices you connected in that OS. In my case its only one, which is my headphone. In windows we had 3 because i connected more wireless devices there. cd into the address and there will be a file name ‘info’. You will find the outdated key in ‘info’ file
  • use nano, vim or any editor to edit the info file.
  • Info file structure :

Name=Device Name
Class=class
SupportedTechnologies=BR/EDR;
Trusted=true
Blocked=false
Services=services;

[LinkKey]
Key=46C96C60B6D00DC92A2E6B72E2337F9E
Type=4
PINLength=0

  • From chntpw terminal copy the key of the device. In my case its only one in your case their may be more so copy and paste keys after matching addresses.
  • Key will have spaces when copied from chntpw like 42 10 2C 8F B3 AF 77 A0 1F E5 3B B0 34 54 67 21 . Remove the spaces before saving.
  • Restart bluetooth with systemctl restart bluetooth to make changes take effect.

Contact me at contact@ashwincodes.com if you need help with the instructions or want to report a problem with the article.

--

--