How to use bluetooth devices under two different operation systems?

6

6

I've got an magic mouse and an apple bluetooth keyboard.

I usually run ubuntu on my computer, but sometimes I need to use windows 7 from an external disk.

Whenever I boot into the other system I have to pair my devices again.

Is there a way to make this work? I've already tried setting the hostname to be the same, but this didn't work.

Georg Schölly

Posted 2012-05-09T14:12:20.407

Reputation: 1 146

Answers

5

Here I share what I learned about this, after struggled with it for quite a few days. I have a dual boot system with Windows 10 and up-to-date Debian testing, and would like to share the same Bluetooth mouse. Mine is a Razer Orochi mouse. I am giving all the credits for the following people and their work:

  1. http://forum.notebookreview.com/threads/dual-booting-and-bluetooth.739236/
  2. https://forums.solydxk.com/viewtopic.php?f=7&t=5251#p53746
  3. https://www.insanelymac.com/forum/topic/268837-dual-boot-bluetooth-pairing-solved/
  4. https://ubuntuforums.org/showthread.php?t=2390542&highlight=bluetooth+mouse+reboot (to obtain missing LinkKey in Ubuntu 18.04)

*EDIT: I discovered that a more consistent way is to pair it with Linux first, then go to Windows to change the pair key. Therefore, I am revising the answers here so it is a complete tutorial you can follow.

-- Linux First Method (so far so good!)

Before you start, I assume you have paired the mouse in both Windows and Linux at least once, so the corresponding registries are set. Boot to Linux and make sure the mouse works. I use Debian testing with KDE (Plasma 5), so it is pretty easy to pair it using the standard build-in Bluetooth packages. I am not too sure about Ubuntu, but I suppose the underlying processes are similar. Make sure the mouse is usable.

Change to root user (sudo won't do here) (just use command su or sux), navigate into the following location:

/var/lib/bluetooth/AA:AA:AA:AA:AA:AA/BB:BB:BB:BB:BB:BB

Where AAs are the adapter of your laptop, BBs are the mouse. There is one file in there called info. Edit this file with vi, nano or your favorite editor. Inside "info", you should see the following entry called LinkKey. The Key is a 32 character hex string. Copy and save this string in a text file somewhere in which both Linux and Windows can access, for example an external flash drive.

[LinkKey]
Key=XXXXXXXXXXXXXXXXXXXXXXXXXXXX
Type=4
PINLength=0

Now boot into Windows. Without using the Bluetooth mouse (turn it off or set aside), under an administrator terminal, run this: psexec -s -i regedit.exe. You will have to download psexec first.

Navigate to the following key:

(LM)\ControlSet001\Services\BTHPORT\Parameters\Keys\(ID_Adapter)

In there, you should be able to see another ID that matches with your mouse. Right-click on the key and choose "Modify Binary Data".

Now it is time to find that file you saved and enter the 32 characters in 16 groups in the "normal order". Don't reverse the order, which is a Mac thing.

After this, close the registry and turn on the mouse! Wolla!

--- Windows First Method (not consistent, only for the record here)

First, you need to pair the mouse with Windows 10, and obtain the linkkey. To achieve this, you can either use the chntpw method in Linux (see link 1), or the psexec method in Windows. In Windows, under an administrator terminal, run this: psexec -s -i regedit.exe. You will have to download psexec first.

Obtain and export the key from the following place. Save it to a text file you can access later in Linux.

(LM)\ControlSet001\Services\BTHPORT\Parameters\Keys

Then boot to Linux; in this case, you probably have attempted pairing the mouse at least once before. I am assuming you did.

Change to a root user, go into the following location:

/var/lib/bluetooth/AA:AA:AA:AA:AA:AA/BB:BB:BB:BB:BB:BB

Where AAs are the adapter of your laptop, BBs are the mouse. There is one file in there called info. Edit this file with vi, nano or your favorite editor.

[LinkKey]
Key=A7XXXXXXXXXXXXXXXXXXXXXXXXXXXX89
Type=4
PINLength=0

The goal is to sandwich your key (all spaces and commas removed) between A7 and 89. A7 and 89 are critical for making this work. Why the sandwich? Honestly, I have no idea, but without it, it won't work for me. The key is no longer 8 bytes, but 16 bytes! So you will have 32 characters to sandwich. The final key will have a total length of 36 characters.

Reboot your Linux with fingers crossed. Finally, yah!

GoJian

Posted 2012-05-09T14:12:20.407

Reputation: 151

I report back that after enjoying the initial success for 2 days. I lost the connection. I tried this procedure again and it won't work again, namely, I don't think we correctly understood the mechanism and why the A7 and 89 in the LinkKey, because the default length of keys are all 32 characters. – GoJian – 2015-08-25T17:04:25.920

I reversed the process by first pairing it in Linux, then going back to Windows to change the LinkKey by modifying the registry, following this link. I think I solved it this time, for now.

– GoJian – 2015-08-25T17:08:27.173

Just a quick note for the uninitiated: (LM) = HKEY_LOCAL_MACHINE\SYSTEM\ and I have to enable/disable my Bluetooth adapter in Windows for my mouse to connect. – Arya S. – 2017-03-07T10:49:32.550

This guide seems outdated. In the Windows registry as well as on Linux, there are 3 keys. The info file on contains the IdentityResolvingKey, the LocalSignatureKey, and the LongTermKey. Each of these keys is 16 bytes long. In the info file, the LongTermKey is accompanied by values called EDiv and Rand, which are also present in the Windows Registry. I assume that I have to copy at least these 5 values. – Sven – 2018-01-27T01:03:07.703

2

Probably you've already found an answer. But for the sake of completeness here is the link where it is explained http://ubuntuforums.org/showpost.php?p=9363229&postcount=5 . The pin code used for pairing is used to generate a another key. This key is different even each time for the same pin. That is why same pin does not work. You have to copy the key from WIndows to Ubuntu machine.

mlt

Posted 2012-05-09T14:12:20.407

Reputation: 261

1

Bluetooth Mouse with Windows 10 and K/Ubuntu 17.10 Dual Boot – HP Z5000 Bluetooth Mouse

There is a long list of suggestions on this topic most are old and are complicated to follow. This is an alternative to enable the same bluetooth mouse to work on both Windows 10 and Kubuntu 17.10. It’s fairly simple. This should work in other Debian systems and perhaps for other bluetooth devices.

FIRST STEPS:

1/. First pair in Windows. Save a copy of the bluetooth keys to a USB stick then print it. This is helpful in determining the computer and device addresses for use in changing the Windows LinkKey. Using regedit (In the result left click to enable administrator rights) go to - HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\BTHPORT\Parameters\keys\computer MAC\device MAC.

2/. Reboot to Linux then pair in linux.

3/. Open Nautilus via terminal with su for full root:

4/. Using Nautilus navigate to bluetooth via file system ROOT - var – lib - bluetooth

5/. From Bluetooth open the 12 digit number (machine MAC address) opens up to device MAC address

6/. Open device MAC

7/. Opens to Info folder

8/. Open Info – displays Linux LinkKey data - either save a copy or print screen / file or print a copy to use later in this process. It makes inputting the Linux LinkKey much easier.

WINDOWS 10:

Swithch off mouse before starting Windows and do not reconnect. The finger/touch pad will be the only means to proceed.

1/. Login with normal user password

2/. Search for regedit

3/. In the result left click to enable administrator rights.

4/. Go to HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\BTHPORT\Parameters\keys\computer MAC\device MAC

The the computer and device address will at least be similar or even identical in Linux and Windows. This can be ckecked from the printed copies (if made). 5/. To gain access to the Keys files elevated privilages are needed (see https://www.howtogeek.com/262464/how-to-gain-full-permissions-to-edit-protected-registry-keys/).

6/. Click on keys and then Device Mac

This will open up a binary value editor:

1/. Input the 32 pair linux key that was obtained using Nautilus.

2/. The original LinkKey will be seen as two lines of 8 paired digits. There will be three lines visible.

3/. Place the curser at the start of the first line and input the Linux LinkKey. The curser will automnatically move to the next pair.

4/. The input will appear in capitals, however it will be automatically be converted to lowercase on completion. Windows will convert the key characters to HEX values during this process this will be seen to the right of the new LinkKey.

5/. When the new key input is complete, place the curser at the start of the original Key and delete the original two lines. This will leave three lines as originally.

6/. Close the editor which will save the changes if it’s reopened the key appear in lower cass and in Windows format (separeated by commas not colons)

7/. Collapse HKEY-L_M and exit Window registry editor.

FINALLY:

Close down Windows 10 and reboot to Windows again without turning on the mouse. Once fully booted turn on the mouse – it should now work in both Kubuntu 17.10 and Windows 10.

A Beskine

Posted 2012-05-09T14:12:20.407

Reputation: 11

0

Every time you load an operating system, that OS needs to load the hardware drivers. Even if you are loading from hibernation, it still loads/refreshes the drivers again. Try it... uninstall a driver in Device Manager, and immediately hibernate. When you restore from hibernation, the driver is there in Device Manager again as if you had restarted.

You need to pair the bluetooth devices after the drivers have been loaded.

The only way to keep the bluetooth devices connected, is to keep the bluetooth receivers active. The only way to keep them active, is to not unload them from the system. The only way to not unload them from the system, is not to shut down the operating system that is accessing them.

Now, if you were running one of the operating systems in a virtual machine, that's a whole different ball game. But since you are not, and since you actually reboot between changes, then no. There is no way with your current usage choices to make the bluetooth devices avoid having to be re-paired each time.

Bon Gart

Posted 2012-05-09T14:12:20.407

Reputation: 12 574

I'm not sure we're talking about the same thing. If I reboot the system I don't have to re-pair the devices, they connect automatically. If I, however, switch the operation system, they aren't able to connect automatically. – Georg Schölly – 2012-05-09T14:49:58.550