Bluetooth dongle not working with LXC

Possible

New Member
Mar 25, 2020
12
0
1
37
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 ?
 

oguz

Proxmox Staff Member
Staff member
Nov 19, 2018
4,041
489
88

Possible

New Member
Mar 25, 2020
12
0
1
37
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:

oguz

Proxmox Staff Member
Staff member
Nov 19, 2018
4,041
489
88
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.
 

Possible

New Member
Mar 25, 2020
12
0
1
37
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
 

oguz

Proxmox Staff Member
Staff member
Nov 19, 2018
4,041
489
88
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
 

Possible

New Member
Mar 25, 2020
12
0
1
37
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:

oguz

Proxmox Staff Member
Staff member
Nov 19, 2018
4,041
489
88
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.
 

Possible

New Member
Mar 25, 2020
12
0
1
37
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
 

Possible

New Member
Mar 25, 2020
12
0
1
37
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
 

Possible

New Member
Mar 25, 2020
12
0
1
37
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 ?
 

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 your own in 60 seconds.

Buy now!