Skip to content

Instantly share code, notes, and snippets.

@diffficult
Last active November 11, 2024 19:31
Show Gist options
  • Save diffficult/574eb4807a7c61284dfe901f04382087 to your computer and use it in GitHub Desktop.
Save diffficult/574eb4807a7c61284dfe901f04382087 to your computer and use it in GitHub Desktop.
Bluetooth Pairing one device on Dual Boot of Windows & Linux - Stop having to Pair Devices

Bluetooth Pairing one device on Dual Boot of Windows & Linux - Stop having to Pair Devices

You may have experienced when dual booting that you need to re-pair your bluetooth devices (ie., Headphones, mouse, keyboard, etc) this usually happens because you have already paired the device with another operating system using the same bluetooth adapter when dual booting (either Linux or Windows).

Some devices cannot handle multiple pairings associated with the same MAC address (ie., bluetooth adapter). As per suggested on the ArchWiki you can fix this by re-pairing the device each time, but there's actually another solution to not do so each time you choose to use your device on a different OS.

How can we accomplish this?

Easy, just pair the device on a OS and copy the bluetooth keys generated to the other OS so our device doesn't notice the difference.

  1. Pair the devices on Linux
  2. Pair the devices on Windows
  3. Reboot to your Linux install and obtain the keys from Windows;
    • Install chntpw, we will use it to access the Windows install config registry values.
      1. Mount your Windows system drive,
      2. cd /[WindowsSystemDrive]/Windows/System32/config If you are using Nautilus probably it's mounted on /run/media/[username]
      3. chntpw -e SYSTEM, which in turn will open a new console
      4. while in that new console we need to navigate to the relevant registry key to extract the bluetooth key we need:
      >cd ControlSet001\Services\BTHPORT\Parameters\Keys
      >ls                           #to display the mac addresses of the bluetooth controller or dongle we use
      Node has 1 subkeys and 0 values
      key name
      <aa1122334455>
      >cd aa1122334455              #to get into our bluetooth controller
      >ls                           #again we use 'ls' to list all the currently associated bluetooth devices
      Node has 0 subkeys and 1 values
      size     type            value name             [value if type DWORD]
        16   REG_BINARY      <001f20eb4c9a>
      >hex 001f20eb4c9a            # we use 'hex' to display the value that belongs to this device mac address
      => :00000 XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX ...ignore..chars..
              # ^ the XXs after :0000 are the pairing key we are looking for, you can copy that for later
      1. You can now press q and press enter to quit chntpw and unmount your Windows system drive.
  4. Now in Linux let's just write the bluetooth key we got into our device config;
    • (This part of the process could vary from distro to distro, these instructions are working on Arch)
      • Open a terminal and switch to root with su
      • cd to your Bluetooth config location at /var/lib/bluetooth/BT:MA:CA:DD:RE:SS
      • Here you will find directories named after the MAC address of the devices you currently have associated, if you follow these instructions you can alreaddy see a directory named as your device MAC (ie.,AA:BB:CC:DD:EE:FF), what we want to do is to get into that directory as well and modify a file called info
      • using your favourite editor edit info and look for this at the end of the file
      [LinkKey]
      Key=YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
      • replace the key with the one we already got from Windows, no spaces and save the file.
  5. After updating the key, all we need to do is to restart the bluetooth service, sudo systemctl restart bluetooth will do
  6. To test it turn on bluetooth on your computer and also your device and just click connect.
  7. After rebooting do the same on Windows, remember, you don't need to re-pair it anymore.

Sources
@MatheusR42
Copy link

It worked! Thank you!

I also link to this video that show how to do it with devices that have different bluetooth config:
https://www.youtube.com/watch?v=BprSnu6KWTA

@dmitrychepel
Copy link

I used this trick at least two years. but now BTHPORT\Parameters\Keys in windows 11 is empty :(. new way to extract this key. I guess that keys was moved into trusted storage.

@bigelle
Copy link

bigelle commented Sep 13, 2024

Thanks for this tutorial, but i have one question. After i did all this steps my phone doesn't see my earphones, does it mean that now i should also repeat step 4 on my android using root? Or is there any workaround?

@sulyak
Copy link

sulyak commented Sep 29, 2024

incredible

@yugeshsivakumar
Copy link

Thank you so much😁; your solution and guidance helped me fix my bluetooth pairing issue on dual boot systems

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment