Linux – Simpler method of pairing Bluetooth Devices for both Windows & Linux

bluetoothdual-bootlinuxlinux-mint

I have a Dell XPS-13 configured for dual boot in Windows 10 Home and Linux Mint 19.3 MATE edition. I've run into the same issue others have, of wanting my Bluetooth mouse and keyboard to work on both OS without having to re-pair each time. I found the guide at Bluetooth Pairing on Dual Boot of Windows & Linux Mint/Ubuntu – Stop having to Pair Devices helpful for the principles, but it strangely relies on downloading additional software on both the Windows and Linux sides, which are completely unnecessary (mods, feel free to combine with that thread if you wish; I can't b/c of insufficient rep).

The same goal can be accomplished with tools that are native to both OS … on the Windows side, regedt32.exe; and on the Linux side, your native file manager and text editor. Answer below.

Best Answer

  1. Pair your bluetooth device(s) in Linux.

  2. Reboot into Windows, and pair your same bluetooth device(s) in Windows.

  3. Run regedt32.exe. Navigate to "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\BTHPORT\Parameters\Keys"

  4. Right-click on the "Keys" folder in the lefthand pane of the path above, and select "Export." In the pop-up dialog, change "Save as type" to "Text files," be sure that the "Export range" radio button "Selected branch" is selected, and save the file to your choice of name and location. For this purpose it's convenient if you've already configured a drive partition that's shared between your two OS, but it's not absolutely necessary, as you can use a thumb drive to transfer the file as well. If you have trouble exporting the folder, right click on it, select Permissions, and add Users to the groups that can read and edit the folder.

  5. Now reboot into Linux.

  6. Open a command prompt in Linux type sudo caja (if you're not running Linux with MATE, you may have a different file manager; substitute as necessary) and enter your password at the prompt. This will open a file manager with SU rights, so handle with care ... I'm not responsible if you brick your system!

  7. Navigate to /var/lib/bluetooth. Inside of this folder you will see one or both of two things -- either a single folder named with a single MAC address (of your computer's bluetooth adapter) or multiple folders, each with its own MAC address, for each paired bluetooth device (the MAC address will be in the format XX:XX:XX:XX:XX:XX). If you find only the single folder, folders with those individual MAC addresses will be inside the first adapter folder.

  8. Open the folder containing the MAC address of the device you wish to pair in dual-boot mode. Inside that folder will be one or two files ... the one you care about is the "info" file. Double-click on it and it will open in a text editor with SU rights -- that is, you'll be able to edit it and save it. (by the way, if you're not sure which device you're looking for, the "info" file contains the plain-English device name, so just open each one in turn till you find the right one).

  9. Open a separate (non-SU) instance of your file manager, and use it to open the text file you saved from Windows in another pane. When you double-click on that file, Linux may ask if you want to execute or edit it ... choose to edit.

  10. The Windows registry export will contain multiple stanzas (one for each device) that look like this (don't worry, I've changed to a bogus MAC and key):

Value 1  
  Name:            0008e024d45e  
  Type:            REG_BINARY  
  Data:              
00000000   31 c0 08 fa 4f 7b d2 4c - 6f e1 7d ba 32 29 a9 a7  1À.ïO{ÒLoá}ºQ)©§  
  1. Find the stanza containing the value on the "Name:" line which corresponds the MAC address of the file you have open in the first (SU) pane. Note that in the Windows files, the format of the MAC address uses lower-case letters instead of upper-case, and there are no colons.

  2. Your Bluetooth pairing key is the string in the line that begins "00000000" and ends with a bunch of gibberish. Don't copy either the zeros or the gibberish, just the string in-between containing the 16 hex codes with the dash in the middle.

  3. Insert that key into the "Key=" line in your "info" file. You can copy and paste if you want (I did), but you need to change lower-case letters to upper-case, and delete all spaces and dashes. In the example above, the resulting line will look like this:

Key=31C008FA4F7BD24C6FE17DBA3229A9A7
  1. Now save the file, repeat for any additional devices. Reboot into Windows, your device should now work. Reboot into Linux, it should also work.

One final note: I did this with an old Lenovo diNovo setup that includes a mouse, a keyboard, and a separate keypad. The set comes with a Bluetooth dongle, but I could not get them to work with that dongle because Windows sees the dongle as a single device (meaning only one pairing key in the registry), while Linux sees through the device and pairs each individual piece. To solve this problem, I paired each device individually through the Bluetooth adapter on the laptop itself. The downside of this is that the Bluetooth keyboard does not work in Grub or BIOS, only within the OS. But it's the only way I succeeded with this setup.

Related Question