[SOLVED] Pass USB Device to LXC

xadox

Active Member
Aug 21, 2019
31
3
28
Hello All.
I am on Proxmox V7.3-6. And I want to pass a USB Device on an unprivileged Ubuntu20.04.5 LTS LXC.
The USB device is a USB adapter to read my SmartMeter:

root@proxmox:~# lsusb Bus 003 Device 002: ID 10c4:ea60 Silicon Labs CP210x UART Bridge

I followed several instructions on the net. Unfortunately this does not work properly.
The most promising seems to be this tutorial:

https://www.schreiners-it.de/proxmox/usb-geraet-in-lxc-container-unter-proxmox-7-1/

But it starts directly with the fact that no ttyACM0 is created for me. I only have ttyUSB0.
ttyUSB0 is always present regardless of whether the following command is used in one of the LXC configs:

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

Then sometimes lxc.cgroup2.devices.allow is used and sometimes lxc.cgroup.devices.allow.

Any tips would be greatly appreciated.
 
Hmm, have you tried create=dir instead of create=file already? My gut tells me create=file should be correct, but it's worth a try nevertheless.

Another thing I have noticed: Why is there a trailing / in dev/bus/usb/? Skimming the LXC docs, I can't really find anything regarding the actual path specification, so I'm not sure a trailing slash actually makes a difference or not; but maybe try something like dev/bus/usb/003/006 instead. Just for good measure.

So, the full mount entries I'd suggest you try are:

1.
lxc.mount.entry: /dev/bus/usb/003/006 dev/bus/usb/003/006 none bind,optional,create=file

2.
lxc.mount.entry: /dev/bus/usb/003/006 dev/bus/usb/003/006 none bind,optional,create=dir

Also, make sure your device has the required permissions by doing a chmod a+rw /dev/bus/usd/003/006 beforehand.
 
I have tested a bit more. You are totaly right.
The command should be without the ending "/":

lxc.cgroup2.devices.allow: c 189:* rwm lxc.mount.entry: /dev/bus/usb/003/002 dev/bus/usb none bind,optional,create=file

The first "/dev/bus/usb/003/002" is the mount point on the host. The Second one "dev/bus/usb" is the mount target on the lxc.
This creates the file "dev/bus/usb" on the lxc.

root@iob:/dev/bus# ls -la crw-rw-rw- 1 nobody nogroup 189, 257 Mar 14 14:51 usb

Thats working. But if I read the tutorials correctly there should be now a ttyACM0 device created on the host.
And for me thats not working. Instead I am using dev/ttyUSB0:

lxc.cgroup2.devices.allow: c 188:* rwm lxc.mount.entry: /dev/ttyUSB0 dev/ttyUSB0 none bind,optional,create=file

And with that I am able to use the USB device in the lxc.
 
The Same worked with me.
Unfortunately when I Hotswap the USB Device. I loose the connection an the rights.
I receive: ls -al /dev/ttyUSB0
c--------- 0 nobody nogroup 188, 0 Aug 6 19:58 /dev/ttyUSB0

one I restart the LXC, everything is working again.

Anyone an Idea how to get the permissions Hotswap-compatible?

Rgds
Malte
 
The Same worked with me.
Unfortunately when I Hotswap the USB Device. I loose the connection an the rights.
I receive: ls -al /dev/ttyUSB0
c--------- 0 nobody nogroup 188, 0 Aug 6 19:58 /dev/ttyUSB0

one I restart the LXC, everything is working again.

Anyone an Idea how to get the permissions Hotswap-compatible?

Rgds
Malte
Hi all.
I have the same problem afrter re-plug device (in 8.1.10). Is there any progress? Some settings or workaround?
Thx
 

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!