Bluetooth dongle not working with LXC

Possible

Member
Mar 25, 2020
12
0
6
40
Hello,

I have installed a LXC Ubuntu 20.x.x installation. I would like to use the Bluetooth dongle which i have plugged into my server. I can see that the dongle is listed:

lsusb:

Code:
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 006: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)

However, the dongle is not able to communicate with my SMA Sunnyboy (Converter for solar panels)

It keeps connecting:

Code:
root@SMA:/var/log/sbfspot.3# /usr/local/bin/sbfspot.3/SBFspot -v -cfgSBFspotZUID.cfg -finq -nocsv
SBFspot V3.7.0
Yet another tool to read power production of SMA solar inverters
(c) 2012-2020, SBF (https://github.com/SBFspot/SBFspot)
Compiled for Linux (LE) 64 bit with SQLite support
Commandline Args: -v -cfgSBFspotZUID.cfg -finq -nocsv
Reading config '/usr/local/bin/sbfspot.3/SBFspotZUID.cfg'
Mon Dec 28 08:37:17 2020: INFO: Starting...
sunrise: 07:45
sunset : 15:42
Connecting to 00:80:25:25:3b:47 (1/10)
Connecting to 00:80:25:25:3b:47 (2/10)
Connecting to 00:80:25:25:3b:47 (3/10)
Connecting to 00:80:25:25:3b:47 (4/10)
Connecting to 00:80:25:25:3b:47 (5/10)
Connecting to 00:80:25:25:3b:47 (6/10)
Connecting to 00:80:25:25:3b:47 (7/10)

When i create an VM and passtrought the USB port to the VM, it is working fine.. Is LXC not able to handle USB ports directory ? OR is there another way ?
 
So what i have to do is find the right device id from the USB

and type:

pct set 100 -mp0 /mnt/bindmounts/shared,mp=/shared

With this, i can use any USB device which is listed with lsusb command?

?
 
Last edited:
and type:

pct set 100 -mp0 /mnt/bindmounts/shared,mp=/shared
that's just an example to bindmount a directory. you need to type the path to the usb bus device like /dev/bus/usb/001/002 or similar.

With this, i can use any USB device which is listed with lsusb command?
yes, you also need to allow the mount entry according to major:minor of the device.

for example to pass device on /dev/bus/usb/001/002 first run ls -l /dev/bus/usb/001/002 and you should see something like this:
Code:
crw-rw-r-- 1 root root 189, 1 Dec 30 08:48 /dev/bus/usb/001/002
189, 1 are the major and minor.

you need to then add:
Code:
lxc.cgroup.devices.allow: c 189:1 rwm

and if using an unprivileged container make sure to set permissions for the unprivileged user on that path.
 
Sorry but i am new to proxmox. What do you mean with:

that's just an example to bindmount a directory. you need to type the path to the usb bus device like /dev/bus/usb/001/002 or similar.

When i have found de device bus, it simular like this?

pct set 100 -mp0 /mnt/dev/bus/usb/001/002/shared,mp=/shared
 
in your container configuration at /etc/pve/lxc/CTID.conf add these (adapt the major:minor part and /dev/my-device parts):

Code:
lxc.cgroup.devices.allow: c major:minor rwm
lxc.mount.entry: /dev/my-device /dev/my-device none bind,optional,create=file
 
Oke i think i have found it. THe config looks now like this:

Code:
unprivileged: 1
lxc.cgroup.devices.allow: c 189:4 rwm
lxc.mount.entry: /dev/bus/usb/001/005 /dev/bus/usb/001/005 none bind,optional,create=file

Is this oke because no data is still received. Do i have to set unprivileged: 1 to 0 to make sure all permissions are correct?
 
Last edited:
Do i have to set unprivileged: 1 to 0 to make sure all permissions are correct?
no, modifying that manually will break the container.


check the permissions of /dev/bus/001/005 in the container and on the host.

Code:
pve# ls -l /dev/bus/usb/001/005
crw-rw-r-- 1 root root 189, 4 Dec 30 08:37 /dev/bus/usb/001/005
container# ls -l /dev/bus/usb/001/005

if you see nobody nogroup from the container, then you can run:
Code:
pve# chown 100000:100000 /dev/bus/usb/001/005

and then it should show up with the right permission in the container.
 
The command runs in de host but not on the container:

Host:
Code:
arch: amd64
cores: 2
hostname: dsmr
memory: 4096
net0: name=eth0,bridge=vmbr0,firewall=1,hwaddr=36:9C:7D:68:9A:C0,ip=dhcp,type=veth
ostype: ubuntu
rootfs: local-lvm:vm-102-disk-0,size=40G
swap: 512
unprivileged: 1
lxc.cgroup.devices.allow: c 189:4 rwm
lxc.mount.entry: /dev/bus/usb/001/005 /dev/bus/usb/001/005 none bind,optional,create=file

Code:
root@dsmr:~# ls -l /dev/bus/usb/001/005
ls: cannot access '/dev/bus/usb/001/005': No such file or directory
root@dsmr:~#

I rebooted the container but didnt work
 
It worked,... the mount entry was wrong

lxc.mount.entry: /dev/bus/usb/001/005 /dev/bus/usb/001/005 none bind,optional,create=file

needs to be:;

lxc.mount.entry: /dev/bus/usb/001/005 /dev/bus/usb/001/005 none bind,optional,create=file
 
For the bluetooth device it worked. Now i hava en FTDI USB cable which reads out my Smart Meter for Electrictiy and gas.

lsusb:
Code:
Bus 001 Device 004: ID 0403:6001 Future Technology Devices International, Ltd FT232 Serial (UART) IC

Container:
Code:
root@dsmr:~# ls -l /dev/bus/usb/001/004
crw-rw-r-- 1 root root 189, 3 Dec 30 18:49 /dev/bus/usb/001/004


Host file:
Code:
arch: amd64
cores: 2
hostname: dsmr
memory: 4096
net0: name=eth0,bridge=vmbr0,firewall=1,hwaddr=36:9C:7D:68:9A:C0,ip=dhcp,type=veth
ostype: ubuntu
rootfs: local-lvm:vm-102-disk-0,size=40G
swap: 512
unprivileged: 1
lxc.cgroup.devices.allow: c 189:3 rwm
lxc.mount.entry: /dev/bus/usb/001/004 dev/bus/usb/001/004 none bind,optional,create=file

The software (DSMR Reader) is not receiving data from the USB cable.

Any ideas ?
 
here it is neither working i get the following message
Code:
root@homeassistant:~# service bluetooth status
* bluetooth.service - Bluetooth service
     Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Sun 2023-02-19 01:55:36 UTC; 46s ago
       Docs: man:bluetoothd(8)
    Process: 887 ExecStart=/usr/libexec/bluetooth/bluetoothd (code=exited, status=1/FAILURE)
   Main PID: 887 (code=exited, status=1/FAILURE)
     Status: "Starting up"
        CPU: 13ms

Feb 19 01:55:36 homeassistant systemd[1]: Starting Bluetooth service...
Feb 19 01:55:36 homeassistant bluetoothd[887]: Bluetooth daemon 5.55
Feb 19 01:55:36 homeassistant systemd[1]: Started Bluetooth service.
Feb 19 01:55:36 homeassistant bluetoothd[887]: src/adapter.c:adapter_init() Failed to access management interface
Feb 19 01:55:36 homeassistant bluetoothd[887]: src/main.c:main() Adapter handling initialization failed
Feb 19 01:55:36 homeassistant systemd[1]: bluetooth.service: Main process exited, code=exited, status=1/FAILURE
Feb 19 01:55:36 homeassistant systemd[1]: bluetooth.service: Failed with result 'exit-code'.

actually my usb controller is passed trough
Code:
root@homeassistant:~# ls -l /dev/bus/usb/001/003
crw-rw-rw- 1 root root 189, 2 Feb 18 23:11 /dev/bus/usb/001/003

then i did this
Code:
root@homeassistant:~# lsmod | grep bluetooth

bluetooth             679936  6 btrtl,btintel,btbcm,bnep,btusb
ecdh_generic           16384  1 bluetooth

followed by this
Code:
hciconfig
Can't open HCI socket.: Address family not supported by protocol

it seems to me the system does not know that the adapter is the bluetooth adapter
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!