Skip to content

awsl1414/bt-dualboot

 
 

Repository files navigation

Sync Bluetooth for dualboot Linux and Windows

User-friendly tool making your bluetooth devices working both in Windows and Linux without re-pairing chore. more about dualboot Bluetooth issue

Fork of x2es/bt-dualboot — maintained on the dev branch with Clean Architecture refactoring (v2.0.0+). PyPI package: bt-dualboot-ng · CLI command: bt-dualboot

bt-dualboot

  • doesn't require to reboot 3 times
  • ask you as much fewer details as possible
  • multi-adapter support (Issue #10)
  • preserves Windows-only BLE registry fields (Issue #33)
  • ... see all advantages and alternatives

How to install

For developers: checkout the Developer Guide for development and testing instructions.

Usage: shortest way

Assuming you have paired devices in Windows already, boot to Linux and paired them too. Syncing would be simple as following 2 steps:

1. Mount Windows partition

Application will probe and use mounted Windows partition automatically. Otherwise use --win /mnt/win/path/. Partition should be mounted with write access.

2. Sync all devices available for sync

$ bt-dualboot -a

Elevating privileges via sudo...
Syncing...
==========
 [C2:9E:1D:E2:3D:A5] Keyboard K380
...done

NOTES: (i) Auto sudo: the tool automatically elevates via sudo when root is needed. Use --no-elevate to disable. (ii) --backup vs --no-backup: you will be asked about your Windows Registry backup strategy (iii) use -d / --dry-run to preview any command effects (iv) Short options: -a (sync-all), -s (sync), -d (dry-run), -w (win mount)

Usage: choose device manually

  1. List devices info
$ bt-dualboot -l

Works both in Linux and Windows
===============================
 [A4:BF:C6:D0:E5:FF] WH-1000XM4

Needs sync
==========

Following devices available for sync with `--sync-all` or `--sync MAC` options.

 [C2:9E:1D:E2:3D:A5] Keyboard K380

Have to be paired in Windows
============================

Following devices unavailable for sync unless you boot Windows and pair them

 [E9:1D:FE:2A:C3:C8] JBL GO
  1. Sync devices using MAC
$ bt-dualboot -s C2:9E:1D:E2:3D:A5

Syncing...
==========
 [C2:9E:1D:E2:3D:A5] Keyboard K380
...done

See bt-dualboot -h and chapters below for details.

Prerequisites

  • Python 3.13+ installed.
  • chntpw package installed:
Ubuntu $ sudo apt install chntpw
...

see https://pogostick.net/~pnh/ntpasswd/

Install

$ uv tool install bt-dualboot-ng

or with pipx:

$ pipx install bt-dualboot-ng

NOTES: The tool automatically elevates to root via sudo when needed. Use --no-elevate to run without auto-elevation.

Supported OS

Tested with Linux Mint 19.3, 20.3 (Ubutntu 18.04 bionic, 20.04 focal), Windows 10

Supported:

  • Potentially any Linux-based systems keeping bluetooth configuration in similar format as Ubuntu
  • Windows 10+

With next releases more OSes will be tested, Mac OS support will be added. If you get success or fail results for any OS not listed as supported, please share your experience at https://github.com/awsl1414/bt-dualboot/issues.

Advanced usage

--backup vs --no-backup

Windows Registry update performed in the safe way using chntpw/reged without changing Hive-file's size (reged -N -E). Nevertheless chntpw is non-official tool hence backup is not bad idea. Application would perform it as you prefer.

You have to choose your backup strategy explicitly.

$ bt-dualboot -a
usage: ....
bt-dualboot: error: Neither backup option given!

    Windows Registry Hive file will be updated!
    chntpw/reged tool is non-official and hackish Hive file editing tool.
    It is recommended to do backup prior writing into Hive file.

    Use:
      -b [path], --backup [path]    [default: /var/backup/bt-dualboot]
      -n, --no-backup               process without backup

    WARNING:
        Windows Registry Hive file may contain sensitive data. You shouldn't keep this file
        on a storage which may be accessed by others. Consider to remove backup files as soon
        as possible after ensure Windows boots and works correctly.

Restoring from backup

If Windows fails to boot after a sync, restore the backup:

1. Boot into Linux and find your backup file

$ ls /var/backup/bt-dualboot/
SYSTEM-2026-06-07--14-30-00

2. Mount your Windows partition

$ sudo mount /dev/sdXn /mnt/windows

Use lsblk -f to find the correct partition if unsure.

3. Replace the Windows registry hive

$ sudo cp /mnt/windows/Windows/System32/config/SYSTEM /mnt/windows/Windows/System32/config/SYSTEM.broken
$ sudo cp /var/backup/bt-dualboot/SYSTEM-2026-06-07--14-30-00 /mnt/windows/Windows/System32/config/SYSTEM

4. Reboot into Windows

If Windows still does not boot, use the Windows Automatic Repair environment to restore from a System Restore point.

--win /mnt/win/path/

By default application will recognize and use mounted Windows partition. If multiple Windows partitions are found, you will be prompted to select which one(s) to use (supports multi-select). Use -w / --win to specify a mount point directly.

Use --list-win-mounts to list recognized Windows partitions.

$ bt-dualboot --list-win-mounts

Windows locations:
==================
 /media/user/win_foo
 /media/user/win_bar

$ bt-dualboot -w /media/user/win_foo -l

When multiple Windows partitions are mounted, the tool will prompt for selection:

$ bt-dualboot -a

Multiple Windows locations found:
  [1] /media/user/win_foo
  [2] /media/user/win_bar

Select (e.g. 1 or 1,3 or all): 1

Troubleshooting: Windows partition write access

In case when Windows partition mounted in read-only mode, you have to remount it for read-write:

$ sudo mount -o remount,rw /mnt/win/path

Machine processing

--bot flag enables better parsable output for usage in scripts.

Dualboot Bluetooth issue

Every time when a Bluetooth device paired in one dualboot OS it stop working in another one. It happens because both OS uses the same Bluetooth adapter with the same MAC. Each pairing process generates new pairing keys for adapter's MAC. This way previous pairing key which saved in another OS becomes obsolete.

The solution is to sync saved pairing keys for both OS. This answer describes ways to handle this manually: https://unix.stackexchange.com/a/255510/411221

This application implements the way suggested by the comment which copies pairng keys directly from Linux to Windows avoiding multiple reboots.

Advantages and alternatives

bt-dualboot:

  • doesn't require to reboot multiple times
  • simple install
  • provides single simple cli, doesn't require invoke additional scripts
  • discower mounted Windows partition automatically
  • safe update of Windows Registry without changing file size (rewrite only)
  • backup Windows Registry prior update
  • doesn't require import/export files, handle encoding issues
  • allows --dry-run prior actual changes

alternatives

checkout "bluetooth dualboot" on github

solved by invoke single tool under Linux: sync keys from Linux into Windows registry:

(similar approach to bt-dualboot)

solved by invoke multiple tools under Windows and Linux: sync keys from Windows registry into Linux configs:

(requires more steps and reboots, involves using windows tools, manage import/export files)

Most soulutions is kind of import tool of Windows *.reg file into Linux bluetooth configuration.

Mac OS:

Cli reference

$ bt-dualboot -h
usage: bt-dualboot [-h] [-l] [--list-win-mounts] [--bot] [-d] [-w MOUNT] [-s MAC [MAC ...]] [-a] [-n] [-b [path]] [--no-elevate]

Sync bluetooth keys from Linux to Windows.

optional arguments:
  -h, --help            show this help message and exit

List resources:
  -l, --list            [root required] list bluetooth devices
  --list-win-mounts     list mounted Windows locations
  --bot                 parsable output for robots (supported: -l)

Sync keys:
  -d, --dry-run         print actions to do without invocation
  -w MOUNT, --win MOUNT
                        Windows mount point (advanced usage)
  -s MAC [MAC ...], --sync MAC [MAC ...]
                        [root required] sync specified device
  -a, --sync-all        [root required] sync all paired devices

Backup Windows Registry:
  -n, --no-backup       process without backup
  -b [path], --backup [path]
                        path to backup directory, default: /var/backup/bt-dualboot

  --no-elevate          do not auto-elevate to root via sudo

Next releases

First priority is to extend list of tested and supported OS.

General roadmap assumes creating GUI and background service versions, adding sync Linux to Linux ability. It will be implemented on demand - give a voice at https://github.com/awsl1414/bt-dualboot/issues.

About

Sync Bluetooth for dualboot Linux and Windows

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Python 100.0%