Bluetooth Pair AirPods on Windows/Ubuntu Dual Boot
The Problem
When switching between OSs in a dual boot setup, airpods constantly need to be re-paired.
The Problem (wearing spectacles)
- A Bluetooth connection is keyed by the bluetooth adapter’s MAC address: one link key per address
- Both OSes share the same physical bluetooth adapter, so they share one MAC
- Each OS pairs independently and generates its own key
- Whichever OS paired last overwrites the other’s key in the AirPods
- Booting the other OS then fails authentication, forcing a re-pair
The Solution
Sync the key between OSs
// chntpw: offline Windows registry editor. -e = interactive edit of the
// SYSTEM hive, read straight off the mounted Windows partition
sudo chntpw -e /media/elliot/726C27XXXXXXXXXX/Windows/System32/config/SYSTEM
// chntpw's own shell. backslashes = registry path, not filesystem
cd ControlSet001\Services\BTHPORT\Parameters\Keys
// the bluetooth adapter's MAC, no colons
cd 001a7ddXXXXX
// lists bonded peers as `hex <peer-mac>` entries
ls
// dump a peer's value: the 32-char link key Windows uses
hex 94d...
// this is the key to copy
B7090E4A0C23XXXXXXXXXXXXXXXXXXXX
hex ec4...
293B38CE6E1AXXXXXXXXXXXXXXXXXXXX
// /var/lib/bluetooth is root-only (0700)
sudo -i
// path is <adapter-mac>/<peer-mac>/info.
// backslashes escape the colons for the shell
root@elliot-desktop:/var/lib/bluetooth/00:1A:7D:XX:XX:XX# cat 3C\:4D\:BE\:XX\:XX\:XX/info
// paste the Windows key into the [LinkKey] Key= field
vim EC\:46\:54\:XX\:XX\:XX/info
// reboot, or: sudo systemctl restart bluetooth