SrcBits

Bluetooth & Triple Booting

Bluetooth

Isn’t this supposed to be easy?

The Problem

Are you crazy like me and love to fit as many Operating Systems on one machine as possible in the rare case you need to test something out in Windows, OS X and Linux all at the same time? Well, if you’re not, then this article is probably not for you. For the 5 people in the world who can relate, this read will solve a problem that’s been driving me nuts for the last few months…constantly re-pairing (not repairing) my Bluetooth mouse every time I switch OS’s.

The majority of the people who own a Bluetooth mouse will only need to pair their mouse once and will never have to think about it again. They turn on their PC and the mouse just works. This isn’t the case when you dual or, in my case, triple boot your machine. Each OS pairs your mouse with its own key which the mouse then saves. That means when you pair it in Windows and then boot to OS X, the mouse needs to re-paired for it to work. Boot back to Windows and you’ll need to re-pair it again. This is an on-going process that will eventually lead to a Prozac addiction if you frequently switch OS’s.

The Answer

The Key to Bluetooth

I triple boot Ubuntu 15.10, OS X 10.11 & Windows 10 on my Macbook Pro Retina so these are the 3 OS’s I’ll focus on. If you run other versions of these OS’s, this guide will at the very least point you in the right direction.

Start off by pairing your Bluetooth mouse in Ubuntu, then Windows and finally OS X. While still in OS X, open System Preferences and click on Bluetooth. Under Devices, you should see the Bluetooth mouse you just paired. Right-Click on it and take note of the MAC Address which is grayed out but still visible. Now we’re going to recover the Bluetooth Linkkey which we’ll then copy to Ubuntu & Windows to end our Bluetooth Pairing nightmare.

Launch Terminal in OS X and run the following command:

You should a section in blued.plist that looks like this:

The Linkkey in our example is the 24-character hexkey, bbc5243e ac965f78 6539345b 4fa6df9f. Keep in mind that the MAC addresses and Linkkey in my blued.plist will differ from yours. You may also have multiple Linkkeys listed if you’ve paired other Bluetooth devices in OS X as well. Look for the MAC address of your mouse which we grabbed earlier to find the corresponding Linkkey or complete the steps for every Linkkey if you want to have all your Bluetooth devices paired in Windows and Ubuntu.

OS X does something weird and stores its key in reverse ordered pairs. We’re going to have to reorder the key pairs moving from last to first before we can copy the Linkkey to Windows and Ubuntu.

We start with the last Octet and reverse the order of its pairs. The last pair will become first, the 3rd pair will become second and so forth. Then we’ll work our way backwards on each successive Octet.

Converting Your Linkkey Original Octet Converted Octet
Octet 4 4fa6df9f 9fdfa64f
Octet 3 6539345b 5b343965
Octet 2 ac965f78 785f96ac
Octet 1 bbc5243e 3e24c5bb

Please take note that we are taking each pair and putting them in reverse order and not flipping the characters of each individual pair. Look at the chart closely or you’ll cause yourself a lot of frustration going forward.

Now that the heavy lifting is completed, we then combine all of our Octets together in reverse order to get our final Linkkey.

Converted Linkkey
9fdfa64f5b343965785f96ac3e24c5bb

You’ll either want to write down this converted Linkkey on a piece of paper…you know that white thing with lines on it that old people used before computers…or copy it to a partition that your Windows and Ubuntu installations have access to.

Don’t Fear the Registry

Now that we have our magical Bluetooth Linkkey, our next stop is Windows. Once booted into Windows 10, we’re going to need to edit the Registry in order to copy our Converted Linkkey into our existing Bluetooth registry entry. This regkey is different from most in that only the System has access to it. If you try to view this key as a user, even an Administrator, you’ll be met with an error. This means we’ll need to launch regedit as the System account.

First we’ll need to download PSexec from Microsoft’s PsTools kit.

After downloading and unzipping PsTools, launch a Command Prompt as Administrator by typing cmd in the Windows Search Box. The first search result you should see is Command Prompt. Right-click Command Prompt and select Run as administrator.

Assuming you downloaded and unzipped PsTools to your user’s Download folder, run the following in the Command Prompt window to launch PSexec as the System account. Make sure to change “username” to your User’s name.

In the Registry Editor, drill down to Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\BTHPORT\Parameters\Keys. In this regkey, you’ll find the MAC addresses of all of your machine’s Bluetooth Adapters. You’ll most likely only have 1 listed. Click on the MAC address of your Bluetooth Adapter and you should see the MAC address of your Bluetooth mouse along with its corresponding Linkkey. As you might have already guessed, we’re going to replace that Linkkey, with the Linkkey we converted in the previous step.

Double-Click the regkey for your Bluetooth mouse, delete the current Linkkey and type in your Converted Linkkey. Don’t worry about the spaces as they are automatically added in as you type. Now give your machine the old reboot and when you’re logged back into Windows 10, your Bluetooth mouse should be automatically paired.

Linux: The Final Frontier

We’ve got OS X & Windows squared away. The last step is to get Ubuntu paired up with our Linkkey. There’s a lot of information on the net that applies to older versions of Ubuntu that doesn’t apply to 15.10. The file where our Linkkey is stored is actually in /var/lib/bluetooth/btMACaddress/mouseMACaddress/info. Note that btMACaddress will be the MAC address of your Bluetooth Adapter and mouseMACaddress is the MAC Address of your Bluetooth Mouse. One last curveball before we pwn Bluetooth is the entire Bluetooth Mouse’s directory is only accessible by root so we’ll need to edit the info file with Sudo privileges.

Edit info with Sudo rights

Remember to replace btMACaddress and mouseMACaddress with the MAC Addresses listed on your machine. Hitting Tab as you type the path will auto-fill those addresses for you and save you the hassle of having to escape every colon.

While in the info file, we’ll want to replace the key listed next to “Key=” with our converted Linkkey.

After making your changes, Save the info file and go ahead and reboot Ubuntu. When you log back in you should have a working paired Bluetooth mouse. Go ahead and reboot to OS X and Windows and you should find your mouse works without needing to re-pair it.

Final Words

I’ve been living with this issue for a long time and finally decided to track down the answer. It was a lot more complicated than I first thought so I decided to create this little guide to save others some time. If you have any issues getting it to work on your machine, feel free to post in the comments and I’ll do my best to help you out. Thanks for reading!


Share on Facebook
Facebook
Tweet about this on Twitter
Twitter
Share on Google+
Google+
Share on Reddit
Reddit
Email this to someone
email
Print this page
Print

Please Share Me...I'm Lonely