You may have experienced when dual booting that you need to re-pair your bluetooth devices (ie., Headphones, mouse, keyboard, etc) this usually happens because you have already paired the device with another operating system using the same bluetooth adapter when dual booting (either Linux or Windows).
Some devices cannot handle multiple pairings associated with the same MAC address (ie., bluetooth adapter). As per suggested on the ArchWiki you can fix this by re-pairing the device each time, but there's actually another solution to not do so each time you choose to use your device on a different OS.
Easy, just pair the device on a OS and copy the bluetooth keys generated to the other OS so our device doesn't notice the difference.
- Pair the devices on Linux
- Pair the devices on Windows
- Reboot to your Linux install and obtain the keys from Windows;
- Install
chntpw
, we will use it to access the Windows install config registry values.- Mount your Windows system drive,
cd /[WindowsSystemDrive]/Windows/System32/config
If you are using Nautilus probably it's mounted on/run/media/[username]
chntpw -e SYSTEM
, which in turn will open a new console- while in that new console we need to navigate to the relevant registry key to extract the bluetooth key we need:
>cd ControlSet001\Services\BTHPORT\Parameters\Keys >ls #to display the mac addresses of the bluetooth controller or dongle we use Node has 1 subkeys and 0 values key name <aa1122334455> >cd aa1122334455 #to get into our bluetooth controller >ls #again we use 'ls' to list all the currently associated bluetooth devices Node has 0 subkeys and 1 values size type value name [value if type DWORD] 16 REG_BINARY <001f20eb4c9a> >hex 001f20eb4c9a # we use 'hex' to display the value that belongs to this device mac address => :00000 XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX ...ignore..chars.. # ^ the XXs after :0000 are the pairing key we are looking for, you can copy that for later
- You can now press
q
and press enter to quitchntpw
and unmount your Windows system drive.
- Install
- Now in Linux let's just write the bluetooth key we got into our device config;
- (This part of the process could vary from distro to distro, these instructions are working on Arch)
- Open a terminal and switch to root with
su
cd
to your Bluetooth config location at/var/lib/bluetooth/BT:MA:CA:DD:RE:SS
- Here you will find directories named after the MAC address of the devices you currently have associated, if you follow these instructions you can alreaddy see a directory named as your device MAC (ie.,
AA:BB:CC:DD:EE:FF
), what we want to do is to get into that directory as well and modify a file calledinfo
- using your favourite editor edit
info
and look for this at the end of the file
[LinkKey] Key=YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
- replace the key with the one we already got from Windows, no spaces and save the file.
- Open a terminal and switch to root with
- (This part of the process could vary from distro to distro, these instructions are working on Arch)
- After updating the key, all we need to do is to restart the bluetooth service,
sudo systemctl restart bluetooth
will do - To test it turn on bluetooth on your computer and also your device and just click connect.
- After rebooting do the same on Windows, remember, you don't need to re-pair it anymore.
-
StackExchange thread Bluetooth pairing on dual boot Windows Ubuntu
-
StackExchange thread Dual boot bluetooth device pairing
-
Arch Wiki Bluetooth headset entry
@AnkushMalaker I honestly didn't try to script it since I have setup this just a couple of times in my desktop. Seems that there's no way to automate the
chntpw
shell part since you leave your shell and you are into a new one once you load it.After a quick search, there seems to be a workaround to pull data from that shell and automating inputs using
expect
. Since we are only getting data out the shell and not making changes there's a chance this is doable if you input the Bluetooth mac address so the script goes straight to look for that and just outputs the key value stored.