Skip to content

Instantly share code, notes, and snippets.

@madkoding
Last active October 25, 2025 12:00
Show Gist options
  • Save madkoding/f3cfd3742546d5c99131fd19ca267fd4 to your computer and use it in GitHub Desktop.
Save madkoding/f3cfd3742546d5c99131fd19ca267fd4 to your computer and use it in GitHub Desktop.
Pairing bluetooth devices in dual boot with Linux Ubuntu and Windows 10/11

Pairing Bluetooth Devices in Dual Boot with Linux Ubuntu and Windows 10/11

Introduction

This guide provides updated instructions for pairing Bluetooth devices (such as keyboards or mice) in a dual-boot environment with Linux Ubuntu and Windows 10/11, incorporating community feedback and suggestions.

Instructions

1. Pair in Linux First

  • Pair your Bluetooth device in Linux. This is crucial to ensure the LinkKey remains consistent.
  • Note: Do not re-pair the device in Linux after completing the pairing in Windows.

2. Pair in Windows

  • Pair the Bluetooth device in Windows. Note the MAC address of the device for later steps.

3. Install chntpw in Linux

  • Install the chntpw package to read Windows registry keys:
    sudo apt-get install chntpw

4. Access Windows System Drive in Linux

  • Mount your Windows system drive and navigate to the System32 config folder:
    cd /[MountedDrive]/Windows/System32/config

5. Use chntpw to Access Registry

  • Execute the following command in the config folder:
    chntpw -e SYSTEM

6. Navigate to Bluetooth Registry Keys

  • In the chntpw console, navigate to the Bluetooth registry keys:
    cd \ControlSet001\Services\BTHPORT\Parameters\Keys

7. Find and Copy the Pairing Key

  • Use ls to list unique IDs and find your device's MAC address.
  • Retrieve the pairing key (hex code) associated with your device.

8. Edit Linux Bluetooth File

  • Edit the corresponding file in your Linux drive:
    sudo nano /var/lib/bluetooth/[Unique ID]/[Mac Address]/info
  • Replace the Key value in the [LinkKey] section with the pairing key from Windows.
  • If the [LinkKey] section is missing, add it manually.

9. Restart Bluetooth Service in Linux

  • Save the changes and restart the Bluetooth service:
    sudo service bluetooth restart

Additional Methods and Tips

  • Simplification with reged: Use reged to export Bluetooth pairing keys directly into a file for easier identification and copying.
  • Bluetooth LE Devices: For Bluetooth LE devices, the data storage might differ. Users should research specific steps for these devices.
  • Windows 11 Compatibility: This method is also compatible with Windows 11.
  • Multiple Bluetooth Receivers: If you have multiple Bluetooth receivers, ensure you identify and use the correct pairing key.
  • Changing Bluetooth MAC Address in Linux: If necessary, you can change the Bluetooth MAC address in Linux using the following commands:
    sudo hciconfig hci0 down
    sudo bluemoon -A
    sudo hciconfig hci0 up
    sudo systemctl restart bluetooth.service
  • Adding Missing [LinkKey] Section: If the [LinkKey] section is missing in the info file, you should add it manually.

Acknowledgements

Special thanks to the community members who provided valuable insights and suggestions, including nnnnicholas, kna0085, lguangyu, KeyofBlueS, bjoern-vh, Nielius, IgorRodriguez, princeofguilty, and others.

If this helps u:

Please consider donate a little in this humble bitcoin wallet: bc1qrd3mexqu43qn0597d248725kdp3tr28252q64p

@alexkuz
Copy link

alexkuz commented May 24, 2025

If anyone interested, I wrote a script that automates this process.
I made it for my Logitech Pebble, but it shouldn't be too hard to update it for your device
(use it at your own risk though, obviously)
https://gist.github.com/alexkuz/9beb6ddba835f73d2215f9819f18fff5

@bartgrefte
Copy link

Does being able to obtain the info from the Windows registry require a specific version / edition of Windows and / or a specific bluetooth adapter?

I've been trying the psexec-method shown on home-assistant/home-assistant.io#33676 and https://www.home-assistant.io/integrations/private_ble_device/#on-windows---for-any-devices-that-will-connect-to-a-computer to try to obtain the IRK of my Nothing Watch Pro 2, this so that I can add it in HASS under Private BLE Device for presence detection.

I have tried 6 different BT adapters (some on wifi module), different Windows versions, no luck. When trying on Ubuntu, I can see a bunch of info in /var/lib/bluetooth/bluetoothcontroller-MAC/*smartwatch-MAC/info , PeripheralLongTermKey SlaveLongTermKey and LinkKey for example (which I cannot see in Windows) but no IRK.

For my Galaxy S20 FE 5G I ended up using the ESP32-method to obtain it, which worked, but I cannot connect my smartwatch to that.

@JustVzyt
Copy link

Hey everybody. What should I do if part of my LinkKey in Windows looks corrupted (see screenshot):
image

@A1exan10er
Copy link

Hey everybody. What should I do if part of my LinkKey in Windows looks corrupted (see screenshot): image

B9 is the end of the key. The rest is unrelated.
I asked ChatGPT for explaining: that part in the red box is just the ASCII interpretation of the hex bytes on the left.
So it's completely normal. Nothing to worry about. ;)

@JustVzyt
Copy link

Hey everybody. What should I do if part of my LinkKey in Windows looks corrupted (see screenshot): image

B9 is the end of the key. The rest is unrelated. I asked ChatGPT for explaining: that part in the red box is just the ASCII interpretation of the hex bytes on the left. So it's completely normal. Nothing to worry about. ;)

Thank you very much!!!

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