51

When dual booting Windows 7/10 and Linux Mint/Ubuntu, you may find yourself having to repair your Bluetooth devices again and again. This will happen every time you switch OS.

Now, how do you prevent this?

I'm answering my own question with the following guide, which has been tested on Ubuntu 14.4 and Linux mint 17.2, 17.3 and now Linux Mint 18.x.

95

Why does this happen?

Basically, 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 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 port will be the same on both Linux and Windows (it is set on the hardware level). However, when you re-pair the device in Windows or Linux, it generates a new key. That key overwrites the previously stored key on the Bluetooth device. Windows overwrites the Linux key and vice versa.

How to fix

Using the instructions below, we'll first pair your Bluetooth devices with Ubuntu/Linux Mint, and then we'll pair Windows. Then we'll go back into our Linux system and copy the Windows generated pairing key(s) into our Linux system.

  1. Pair w/ mint/ubuntu - all devices
  2. Pair all devices w/ windows
  3. Copy your windows pairing keys in 1 of 2 ways.

    • Use psexec -s -i regedit.exe from windows (harder)

      1. go to Device & printers in Control Panel and go to your bluetooth device's properties , then in the bluetooth sectione you can find the unique identifier , copy that (you will need it later ).
      2. download from Download psexec from: http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx.
      3. unzip the zip you download and open a cmd terminal as root. (click start, search for cmd, then right click the CMD and click Run as Administrator)
      4. cd into the folder where you unzipped your download.
      5. run psexec -s -i regedit.exe
      6. Navigate to find the keys at LOCAL_MACHINE\CurrentControlSet\services\BTHPORT\Parameters\Keys If no CurrentControlSet try Controlset001. On Windows 10, you'll find the keys at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\BTHPORT\Parameters\Keys\
      7. You should see a few keys labels with the MAC addresses - write down the MAC address associated with the unique identifier you copied before. You can't copy the MAC adddres then write that out by hand, saving in a place you could access in your linux OS.
    • use chntpw from your Linux distro (easier), start in a terminal then:

      1. sudo apt-get install chntpw
      2. mount your windows system drive
      3. cd /[windowsSystemDrive]/WINDOWS/System32/config - on windows 10 the root folder is "Windows", on Win7 it is "WINDOWS"
      4. chntpw -e SYSTEM opens up a console
      5. run these commands in that console

        > cd CurrentControlSet\Services\BTHPORT\Parameters\Keys
        > # if no CurrentControlSet then try ControlSet001
        > # on windows 7, "services" above is lowercased.
        > ls
        # shows you your bluetooth port's mac address
        Node has 1 subkeys and 0 values
          key name
          <aa1122334455>
        > cd aa1122334455  # CD into the folder
        > ls  
        # lists of existing devices' MAC addresses
        Node has 0 subkeys and 1 values
          size     type            value name             [value if type DWORD]
            16  REG_BINARY        <001f20eb4c9a>
        > hex 001f20eb4c9a
        => :00000 XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX ...ignore..chars..
        # ^ the XXs are the pairing key
        
      6. Make a note of which Bluetooth device MAC address matches which paring key. The mint/ubuntu one won't need the spaces in-between. Ignore the :00000

  4. Let's Go back to Linux (if not in Linux), and add our windows key to our Linux config entries. Just note that the Bluetooth port's mac address is formatted differently when moving from Windows to Linux - referenced as aa1122334455 in Windows in my example above. The Linux version will be in all caps and punctuated by ':' after every 2 characters - example: AA:11:22:33:44:55. Based on your version of Linux, you can do one of these:

    • Before Mint 18/16.04 you could do this:

      1. sudo edit /var/lib/bluetooth/[mac address of Bluetooth]/linkkeys - [the mac address of bluetooth] should be the only folder in that bluetooth folder.
      2. This file should look something like this

        [Bluetooth MAC]   [Pairing key]                 [digits in pin]  [0]
        AA:11:22:33:44:55 XXXXXXXXxxXXxXxXXXXXXxxXXXXXxXxX 5 0
        00:1D:D8:3A:33:83 XXXXXXXXxxXXxXxXXXXXXxxXXXXXxXxX 4 0
        
      3. Change the Linux pairing key to the windows one, minus the spaces.
    • In Mint 18 (and ubuntu 16.04) you may have to do this:

      1. switch to root su -
      2. cd to your bluetooth config location /var/lib/bluetooth/[bth port mac addresses)]
      3. Here you'll find folders for each device you've paired with. The folder names being the Bluetooth devices mac address and contain a single file info. In these files, you'll see the link key you need to replace with your windows ones like so.

        [LinkKey]
        Key=B99999999FFFFFFFFF999999999FFFFF
        
  5. Once updated, restart your bluetooth service sudo /etc/init.d/bluetooth restart or reboot into linux - it works!
  6. Reboot into windows - it works!
  7. Upvote if this worked for you!
  • 1
    This works thank you. Sad to say that Bluetooth in Windows works with no fuss. BT in Linux just sucks. I'm using Linux Mint 17.3 and my headset connects and then almost immediately disconnects. Every time I try BT in Linux it is a battle to get it to work. – RyanNerd Feb 24 '16 at 11:00
  • 2
    I came here having just installed Ubuntu 16.04LTS (dualboot with Windows) and having already paired my keyboard and mouse with it. Instead of copying the key from Windows to Ubuntu, I did it in reverse using chntpw: After mounting your windows partition and doing all the chntpw stuff @Mario Flores did, do ed "value name" in the chntpw terminal. Take the "Key=" in your bluetooth device's info file on Ubuntu and enter it like this in chntpw: ": XX XX XX XX XX ...." where XX is every 2 letters/numbers in the key. Then type s and it will be saved to the registry. Repeat if needed. – Sameer Puri Sep 17 '16 at 3:07
  • 3
    should it be: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\BTHPORT\Parameters (so HLKM) – TiloBunt Sep 18 '16 at 0:44
  • 2
    By the way, if you've got a Bluetooth LE device, there will be a few more things to do and unix.stackexchange.com/questions/402488 may help you. – Frederick Zhang May 20 '18 at 11:39
  • 4
    In Windows 10, you'll find your keys at "Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\BTHPORT\Parameters\Keys". – Thomas Aug 16 '18 at 22:27
0

Once you get the Key of the bluetooth device in windows, you can simply go to settings, bluetooth, and get they key, thats the easy part. The difficult part is to change it on linux, I use ubuntu and the way I did it was:

install gksu to get administrator permissions, just put this command: sudo apt-get install gksu

once installed you have to press ALT+F2 and type gksu nautilus (just be carefull to only change what you have to, otherwise you can damage you OS.)

Now, go to the specific location of the file following the above answer path, there you will find a file called Info, open it and change the key. restart the bluetooth or restart your pc and done. Sorry if bad english and grammar, I was too lazy to check it.

  • For Windows 10, where/how do you find the Key? – rickhg12hs Mar 8 '17 at 16:11

protected by Community Sep 21 '17 at 10:01

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.