The answers to this question give you the general idea, though a bit vague on the macOS side, so I'll spell out the procedure I used.
OS versions as follows. The file names and locations appear to be subject to change according to versions, so this is what worked for me.
- MacOS High Sierra 10.13.1
- Ubuntu 17.04
I am assuming that you have a filesystem (USB key or whatever) that is at least read-write in MacOS and readable in Ubuntu.
The general idea is that when you pair a device to an OS, a unique link key is generated, which is necessary for authentication next time the pairing is active. You can transfer these link keys from MacOS pairings to Ubuntu pairings such that the pairings work in both OSes.
- Boot Ubuntu
- Pair device(s) as usual
- Reboot into MacOS
- Pair device(s) as usual
- In a terminal window type:
sudo defaults read com.apple.bluetoothd.plist LinkKeys
. This will give you output something like:
{
"a0-99-9b-16-43-d2" = {
"00-1f-20-47-e5-22" = <4d6b002f 37584c09 ee219365 b78ba03e>;
"04-0c-ce-3d-15-4d" = <fe998c62 4bb29a7c 40b2e670 10db71ed>;
};
}
Here a0-99-9b-16-43-d2
is the MAC address of the bluetooth adapter on my system.
Following that are the MAC addresses of devices that I have paired (00-1f-20-47-e5-22
and 04-0c-ce-3d-15-4d
and the link keys associated with those pairings (4d6b002f 37584c09 ee219365 b78ba03e
and fe998c62 4bb29a7c 40b2e670 10db71ed
respectively).
- Redirect this output to a file visible to both MacOS and Ubuntu:
sudo defaults read com.apple.bluetoothd.plist LinkKeys > /Volumes/4T/linkkeys.txt
- Switch off all devices that you have paired
- Reboot into Ubuntu. Do not turn on your bluetooth devices yet. Hopefully you have a wired keyboard and mouse to use at this point
- Open a terminal window
- Stop the bluetooth service:
sudo service bluetooth stop
- Look in the directory
/var/lib/bluetooth
. You should see a subdirectory entry for the bluetooth adapter MAC address, formatted like A0:99:9B:16:43:D2
. Inside that you should see subdirectories for each device MAC address, like 00:1F:20:47:E5:22
and 04:0C:CE:3D:15:4D
. Inside those directories you will find files named info
. Edit these files with your favourite editor:
sudo gedit /var/lib/bluetooth/A0:99:9B:16:43:D2/00:1F:20:47:E5:22/info
sudo gedit /var/lib/bluetooth/A0:99:9B:16:43:D2/04:0C:CE:3D:15:4D/info
- In these files you'll find a
Key
entry. This key needs to be made the same as what you found in MacOS, but with some important formatting differences:
- spaces removed
- hex digits in uppercase
- byte-swapped 128-bit integer (i.e. split into 2 hex digit chunks and reversed)
You can achieve this as follows:
$ echo 4d6b002f 37584c09 ee219365 b78ba03e | sed 's/ //g;s/../\U&\n/g' | tac | tr -d '\n' ; echo
3EA08BB7659321EE094C58372F006B4D
$ echo fe998c62 4bb29a7c 40b2e670 10db71ed | sed 's/ //g;s/../\U&\n/g' | tac | tr -d '\n' ; echo
ED71DB1070E6B2407C9AB24B628C99FE
$
Edit these reformatted keys into the Key entry of the appropriate info files. Most likely sudo
will be required.
- Re-start the bluetooth service:
sudo service bluetooth start
- Now turn on your bluetooth devices. They should be recognised and the pairings active/valid in both MacOS and Ubuntu.
Update: The pairings seem to have persisted through upgrades on both MacOS and Ubuntu. I'm now running 10.13.6 and 18.04 respectively and have not yet had to redo this procedure.
Obviously, the KISS (Keep It Simply Stupid) answer is:
- Shut down Windows
- Press the power button to boot into Ubuntu.
Why?
The Windows driver leaves the mouse in an unstable state and none of the really smart answers seem to work, which leads me to the conclusion that Ubuntu cannot solve this Windows problem.
You can still file a bug to the developers of the driver (which is off-topic here), but this is a side-effect and notoriously difficult to debug. Expect to spend a lot of time on this if you go that way
Best Answer
Make sure to have your device turned off when booting linux.
Otherwise it will try to connect to the device repeatedly with the old (and now invalid) link key. This might trigger anti brute-forcing measures rendering the device unreachable.
Go to the subfolder that is named after the device's address. You should find a file named 'info' there. Open that.
In the
[LinkKey]
section set the Key. Example:Now check the
[General]
section and setSave, and restart bluetoothd:
When you turn on the device, a popup should appear, asking if you want to authorize the connecting bluetooth device. Of course you do!
If you extracted the link key from Mac OS you'll need to reverse the byte order of the key. Mac OS saves it in reverse endianness.