Trying to enable bluetooth before decrypting disk

Hi,

I see that bluetooth support is now available for initramfs generation so wanted to give it a try on my Fedora Silverblue 35 installation since it’s annoying to switch to the laptop’s keyboard everytime I boot up my computer.

So I added bluetooth module to dracut by creating below file:

# cat /etc/dracut.conf.d/ble.conf
add_dracutmodules+=" bluetooth "

Then I enabled local initramfs generation:

# rpm-ostree initramfs --enable

And generated one:

# dracut --regenerate-all --force --verbose

Now, when I list files inside the initramfs image, I can see that lots of bluetooth files including files about my keyboard and other BLE devices exist inside it. However my bluetooth fails to pair with my computer.

Checking logs via journalctl -ab revealed the following error:

...
Mar 21 01:42:37 fedora kernel: Bluetooth: Core ver 2.22
Mar 21 01:42:37 fedora kernel: NET: Registered PF_BLUETOOTH protocol family
Mar 21 01:42:37 fedora kernel: Bluetooth: HCI device and connection manager initialized
Mar 21 01:42:37 fedora kernel: Bluetooth: HCI socket layer initialized
Mar 21 01:42:37 fedora kernel: Bluetooth: L2CAP socket layer initialized
Mar 21 01:42:37 fedora kernel: Bluetooth: SCO socket layer initialized
Mar 21 01:42:37 fedora kernel: i915 0000:00:02.0: [drm] Finished loading DMC firmware i915/tgl_dmc_ver2_12.bin (v2.12)
Mar 21 01:42:37 fedora kernel: usbcore: registered new interface driver btusb
Mar 21 01:42:37 fedora kernel: Bluetooth: hci0: Bootloader revision 0.4 build 0 week 30 2018
Mar 21 01:42:37 fedora kernel: Bluetooth: hci0: Device revision is 2
Mar 21 01:42:37 fedora kernel: Bluetooth: hci0: Secure boot is enabled
Mar 21 01:42:37 fedora kernel: Bluetooth: hci0: OTP lock is enabled
Mar 21 01:42:37 fedora kernel: Bluetooth: hci0: API lock is enabled
Mar 21 01:42:37 fedora kernel: Bluetooth: hci0: Debug lock is disabled
Mar 21 01:42:37 fedora kernel: Bluetooth: hci0: Minimum firmware build 1 week 10 2014
Mar 21 01:42:37 fedora systemd[1]: Reached target Bluetooth Support.
Mar 21 01:42:37 fedora systemd[1]: Listening on D-Bus System Message Bus Socket.
Mar 21 01:42:37 fedora systemd[1]: Starting Bluetooth service...
Mar 21 01:42:37 fedora systemd[540]: bluetooth.service: Failed to set up mount namespacing: /run/systemd/unit-root/var/lib/bluetooth: No such file or directory
Mar 21 01:42:37 fedora systemd[540]: bluetooth.service: Failed at step NAMESPACE spawning /usr/libexec/bluetooth/bluetoothd: No such file or directory
Mar 21 01:42:37 fedora systemd[1]: bluetooth.service: Main process exited, code=exited, status=226/NAMESPACE
Mar 21 01:42:37 fedora systemd[1]: bluetooth.service: Failed with result 'exit-code'.
Mar 21 01:42:37 fedora systemd[1]: Failed to start Bluetooth service.
Mar 21 01:42:37 fedora audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 subj=kernel msg='unit=bluetooth comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? re>
Mar 21 01:42:37 fedora kernel: usb 3-3.3: new full-speed USB device number 6 using xhci_hcd
Mar 21 01:42:37 fedora kernel: Bluetooth: hci0: Found device firmware: intel/ibt-19-0-4.sfi
Mar 21 01:42:37 fedora kernel: Bluetooth: hci0: Boot Address: 0x24800
Mar 21 01:42:37 fedora kernel: Bluetooth: hci0: Firmware Version: 126-5.22
...

When I searched for it, I saw that changing ReadWritePaths=/var/lib/bluetooth line to ReadWritePaths= may work inside bluetooth.service (systemd unit). I tried overriding it (systemctl edit --full bluetooth) and regenerate initramfs (while including that file as well) but it didn’t work. (error did not change) I suspect that systemd inside initramfs reads /usr/lib/systemd/system/bluetooth.service instead of /etc/systemd/system/bluetooth.service but I couldn’t find a way of replacing the original unit file while using dracut. (since my OS is immutable)

Am I doing this right? How can I make this work?

1 Like

My understanding there are 2 partitions involved /boot and /. For the initramfs file it placed in /boot and this partition usually (and should not) encrypted. The / where all system files (I guess for your case) are encrypted.

When the system booting, it run from /boot/efi/EFI/fedora/ directory then go to /boot/ directory where the initramfs placed. After that it will try to access and preparing the system using files from /.

The problem I guess all the bluetooth configuration are placed under / which are encrypted. May be the modules can load earlier but not the configuration or services.

It will different if the bluetooth connection are managed by BIOS, but as far as I know I never heard about BIOS managing bluetooth connection like BIOS managing for example USB connection.

1 Like

The service already has ReadWritePaths=/var/lib/bluetooth on my system so I suspect that the error is that it is missing from the initrd and thus from the dracut module.

Hi,

As far as I see, you put the necessary drivers, modules and files into initramfs and it should be sufficient to boot the system until LUKS decrypts the filesystem for further init. As @siosm wrote, existing paired device data is stored under /var/lib/bluetooth and I can see it inside initramfs. (I’ll paste the output at the bottom of this message)

I think the errors I got are not as descriptive as they can be. I’ve seen comments suggesting that the errors are due to permission related issues (/root folder) but I’m not sure.

Maybe this configuration works for Fedora Workstation but I couldn’t get it to work with Silverblue. :frowning:

# lsinitrd /boot/initramfs-5.16.15-201.fc35.x86_64.img | grep bluetooth
bluetooth
drwxr-xr-x   1 root     root            0 Jan  1  1970 etc/bluetooth
-rw-r--r--   1 root     root        10841 Jan  1  1970 etc/bluetooth/main.conf
-rw-r--r--   1 root     root         1182 Jan  1  1970 etc/dbus-1/system.d/bluetooth.conf
drwxr-xr-x   1 root     root            0 Jan  1  1970 etc/systemd/system/bluetooth.target.wants
lrwxrwxrwx   1 root     root           41 Jan  1  1970 etc/systemd/system/bluetooth.target.wants/bluetooth.service -> /usr/lib/systemd/system/bluetooth.service
lrwxrwxrwx   1 root     root           41 Jan  1  1970 etc/systemd/system/dbus-org.bluez.service -> /usr/lib/systemd/system/bluetooth.service
-rwxr-xr-x   1 root     root       288200 Jan  1  1970 usr/bin/bluetoothctl
drwxr-xr-x   1 root     root            0 Jan  1  1970 usr/libexec/bluetooth
-rwxr-xr-x   1 root     root      1241576 Jan  1  1970 usr/libexec/bluetooth/bluetoothd
drwxr-xr-x   1 root     root            0 Jan  1  1970 usr/lib/modules/5.16.15-201.fc35.x86_64/kernel/drivers/bluetooth
-rw-r--r--   1 root     root        26696 Jan  1  1970 usr/lib/modules/5.16.15-201.fc35.x86_64/kernel/drivers/bluetooth/btbcm.ko.xz
-rw-r--r--   1 root     root        36436 Jan  1  1970 usr/lib/modules/5.16.15-201.fc35.x86_64/kernel/drivers/bluetooth/btintel.ko.xz
-rw-r--r--   1 root     root        29028 Jan  1  1970 usr/lib/modules/5.16.15-201.fc35.x86_64/kernel/drivers/bluetooth/btrtl.ko.xz
-rw-r--r--   1 root     root        46804 Jan  1  1970 usr/lib/modules/5.16.15-201.fc35.x86_64/kernel/drivers/bluetooth/btusb.ko.xz
drwxr-xr-x   1 root     root            0 Jan  1  1970 usr/lib/modules/5.16.15-201.fc35.x86_64/kernel/net/bluetooth
-rw-r--r--   1 root     root       281016 Jan  1  1970 usr/lib/modules/5.16.15-201.fc35.x86_64/kernel/net/bluetooth/bluetooth.ko.xz
drwxr-xr-x   1 root     root            0 Jan  1  1970 usr/lib/modules/5.16.15-201.fc35.x86_64/kernel/net/bluetooth/bnep
-rw-r--r--   1 root     root        33288 Jan  1  1970 usr/lib/modules/5.16.15-201.fc35.x86_64/kernel/net/bluetooth/bnep/bnep.ko.xz
drwxr-xr-x   1 root     root            0 Jan  1  1970 usr/lib/modules/5.16.15-201.fc35.x86_64/kernel/net/bluetooth/hidp
-rw-r--r--   1 root     root        37284 Jan  1  1970 usr/lib/modules/5.16.15-201.fc35.x86_64/kernel/net/bluetooth/hidp/hidp.ko.xz
drwxr-xr-x   1 root     root            0 Jan  1  1970 usr/lib/modules/5.16.15-201.fc35.x86_64/kernel/net/bluetooth/rfcomm
-rw-r--r--   1 root     root        61388 Jan  1  1970 usr/lib/modules/5.16.15-201.fc35.x86_64/kernel/net/bluetooth/rfcomm/rfcomm.ko.xz
-rw-r--r--   1 root     root          822 Jan  1  1970 usr/lib/systemd/system/bluetooth.service
-rw-r--r--   1 root     root          435 Jan  1  1970 usr/lib/systemd/system/bluetooth.target
drwxr-xr-x   1 root     root            0 Jan  1  1970 var/lib/bluetooth
drwxr-xr-x   1 root     root            0 Jan  1  1970 var/lib/bluetooth/58:96:1D:2C:14:4B
drwxr-xr-x   1 root     root            0 Jan  1  1970 var/lib/bluetooth/58:96:1D:2C:14:4B/34:88:5D:A3:D1:A7
-rw-------   1 root     root            0 Jan  1  1970 var/lib/bluetooth/58:96:1D:2C:14:4B/34:88:5D:A3:D1:A7/attributes
-rw-------   1 root     root          367 Jan  1  1970 var/lib/bluetooth/58:96:1D:2C:14:4B/34:88:5D:A3:D1:A7/info
drwxr-xr-x   1 root     root            0 Jan  1  1970 var/lib/bluetooth/58:96:1D:2C:14:4B/68:13:24:E1:43:5B
-rw-------   1 root     root            0 Jan  1  1970 var/lib/bluetooth/58:96:1D:2C:14:4B/68:13:24:E1:43:5B/attributes
-rw-------   1 root     root          595 Jan  1  1970 var/lib/bluetooth/58:96:1D:2C:14:4B/68:13:24:E1:43:5B/info
drwxr-xr-x   1 root     root            0 Jan  1  1970 var/lib/bluetooth/58:96:1D:2C:14:4B/C5:EA:EB:FC:A7:BD
-rw-------   1 root     root          489 Jan  1  1970 var/lib/bluetooth/58:96:1D:2C:14:4B/C5:EA:EB:FC:A7:BD/attributes
-rw-------   1 root     root          761 Jan  1  1970 var/lib/bluetooth/58:96:1D:2C:14:4B/C5:EA:EB:FC:A7:BD/info
drwxr-xr-x   1 root     root            0 Jan  1  1970 var/lib/bluetooth/58:96:1D:2C:14:4B/cache
-rw-------   1 root     root           40 Jan  1  1970 var/lib/bluetooth/58:96:1D:2C:14:4B/cache/10:2B:41:67:D5:07
-rw-------   1 root     root           41 Jan  1  1970 var/lib/bluetooth/58:96:1D:2C:14:4B/cache/10:2B:41:6E:1A:FB
-rw-------   1 root     root           49 Jan  1  1970 var/lib/bluetooth/58:96:1D:2C:14:4B/cache/2C:FD:B3:1D:22:4D
-rw-------   1 root     root         1739 Jan  1  1970 var/lib/bluetooth/58:96:1D:2C:14:4B/cache/34:88:5D:A3:D1:A7
-rw-------   1 root     root           43 Jan  1  1970 var/lib/bluetooth/58:96:1D:2C:14:4B/cache/38:68:A4:0C:BF:63
-rw-------   1 root     root           41 Jan  1  1970 var/lib/bluetooth/58:96:1D:2C:14:4B/cache/54:3A:D6:51:A1:CB
-rw-------   1 root     root           40 Jan  1  1970 var/lib/bluetooth/58:96:1D:2C:14:4B/cache/54:3A:D6:E6:BD:87
-rw-------   1 root     root           41 Jan  1  1970 var/lib/bluetooth/58:96:1D:2C:14:4B/cache/64:07:F6:6E:81:FD
-rw-------   1 root     root           41 Jan  1  1970 var/lib/bluetooth/58:96:1D:2C:14:4B/cache/64:07:F6:94:50:9F
-rw-------   1 root     root           40 Jan  1  1970 var/lib/bluetooth/58:96:1D:2C:14:4B/cache/64:07:F6:94:51:DB
-rw-------   1 root     root           40 Jan  1  1970 var/lib/bluetooth/58:96:1D:2C:14:4B/cache/64:07:F6:95:71:DF
-rw-------   1 root     root         1637 Jan  1  1970 var/lib/bluetooth/58:96:1D:2C:14:4B/cache/68:13:24:E1:43:5B
-rw-------   1 root     root           44 Jan  1  1970 var/lib/bluetooth/58:96:1D:2C:14:4B/cache/68:72:C3:DB:C0:25
-rw-------   1 root     root           43 Jan  1  1970 var/lib/bluetooth/58:96:1D:2C:14:4B/cache/70:2A:D5:75:5F:85
-rw-------   1 root     root           26 Jan  1  1970 var/lib/bluetooth/58:96:1D:2C:14:4B/cache/70:54:B4:02:12:BF
-rw-------   1 root     root           44 Jan  1  1970 var/lib/bluetooth/58:96:1D:2C:14:4B/cache/70:B1:3D:9C:A4:87
-rw-------   1 root     root           44 Jan  1  1970 var/lib/bluetooth/58:96:1D:2C:14:4B/cache/70:B1:3D:AB:54:D3
-rw-------   1 root     root           40 Jan  1  1970 var/lib/bluetooth/58:96:1D:2C:14:4B/cache/7C:0A:3F:5A:A0:59
-rw-------   1 root     root           41 Jan  1  1970 var/lib/bluetooth/58:96:1D:2C:14:4B/cache/80:47:86:6E:97:33
-rw-------   1 root     root           41 Jan  1  1970 var/lib/bluetooth/58:96:1D:2C:14:4B/cache/80:47:86:72:E8:55
-rw-------   1 root     root           41 Jan  1  1970 var/lib/bluetooth/58:96:1D:2C:14:4B/cache/8C:EA:48:7C:53:29
-rw-------   1 root     root           44 Jan  1  1970 var/lib/bluetooth/58:96:1D:2C:14:4B/cache/BC:7E:8B:2C:8D:0B
-rw-------   1 root     root           40 Jan  1  1970 var/lib/bluetooth/58:96:1D:2C:14:4B/cache/C0:23:8D:53:EC:95
-rw-------   1 root     root           31 Jan  1  1970 var/lib/bluetooth/58:96:1D:2C:14:4B/cache/C1:07:0D:03:27:3B
-rw-------   1 root     root           25 Jan  1  1970 var/lib/bluetooth/58:96:1D:2C:14:4B/cache/C5:EA:EB:FC:A7:BC
-rw-------   1 root     root         2133 Jan  1  1970 var/lib/bluetooth/58:96:1D:2C:14:4B/cache/C5:EA:EB:FC:A7:BD
-rw-------   1 root     root           31 Jan  1  1970 var/lib/bluetooth/58:96:1D:2C:14:4B/cache/C9:2F:C6:5A:15:F5
-rw-------   1 root     root           40 Jan  1  1970 var/lib/bluetooth/58:96:1D:2C:14:4B/cache/CC:D3:C1:5B:67:7F
-rw-------   1 root     root           41 Jan  1  1970 var/lib/bluetooth/58:96:1D:2C:14:4B/cache/D8:A3:5C:8F:A7:83
-rw-------   1 root     root           41 Jan  1  1970 var/lib/bluetooth/58:96:1D:2C:14:4B/cache/D8:A3:5C:B5:15:53
-rw-------   1 root     root           31 Jan  1  1970 var/lib/bluetooth/58:96:1D:2C:14:4B/cache/EA:29:26:76:8D:8C
-rw-------   1 root     root           21 Jan  1  1970 var/lib/bluetooth/58:96:1D:2C:14:4B/cache/F4:60:E2:CE:55:75
-rw-------   1 root     root           29 Jan  1  1970 var/lib/bluetooth/58:96:1D:2C:14:4B/settings
drwxr-xr-x   1 root     root            0 Jan  1  1970 var/lib/bluetooth/mesh