[SOLVED] Regarding using a usb-stick in a LXC Container

theplayer02

New Member
Dec 25, 2022
10
6
3
Hi there,

i want to use a z-wave usb-stick in a LXC Container and configured the LXC config according to this thread:
LXC USB Passthrough (ZWave Stick)
I also created a udev rule, so that i don't have to manually set the correct rights after reboot of proxmox.

Now i have at least two questions:
If i understood everything correctly the container does not need priviliged rights for the passthrough?
And what did i overlooked in my config? There must be something i overlooked,
as i could not see the the usb device inside my lxc container.

I use proxmox 7.3.3
My lxc conf. file for the container looks like this:
Code:
arch: amd64
cores: 2
features: nesting=1,keyctl=1
hostname: openhab
memory: 2048
net0: name=eth0,bridge=vmbr0,hwaddr=62:95:1D:02:99:C6,ip=dhcp,type=veth
onboot: 1
ostype: debian
rootfs: local-lvm:vm-103-disk-0,size=8G
swap: 512
unprivileged: 1
lxc.cgroup2.devices.allow = c 166:* rwm
lxc.mount.entry: /dev/ttyACM0 /dev/ttyACM0 none,optional,create=file 0 0

And the access rights for the ttyACM0 should be okay:
Code:
root@pve:~# ls -l /dev/ttyACM0
crw-rw-rw- 1 root dialout 166, 0 Dec 25 12:20 /dev/ttyACM0
 
The syslog does not show anything related to the mounting of the usb-stick while startup of the container.

Code:
Dec 27 22:24:34 pve pvedaemon[3055001]: starting CT 103: UPID:pve:002E9D99:04CA55DD:63AB6292:vzstart:103:root@pam:
Dec 27 22:24:34 pve pvedaemon[2848270]: <root@pam> starting task UPID:pve:002E9D99:04CA55DD:63AB6292:vzstart:103:root@pam:
Dec 27 22:24:34 pve systemd[1]: Started PVE LXC Container: 103.
Dec 27 22:24:35 pve kernel: EXT4-fs (dm-9): mounted filesystem with ordered data mode. Opts: (null). Quota mode: none.
Dec 27 22:24:36 pve audit[3055024]: AVC apparmor="STATUS" operation="profile_load" profile="/usr/bin/lxc-start" name="lxc-103_</var/lib/lxc>" pid=3055024 comm="apparmor_parser"
Dec 27 22:24:36 pve kernel: audit: type=1400 audit(1672176276.674:68): apparmor="STATUS" operation="profile_load" profile="/usr/bin/lxc-start" name="lxc-103_</var/lib/lxc>" pid=3055024 comm="apparmor_parser"
Dec 27 22:24:36 pve systemd-udevd[3055036]: ethtool: autonegotiation is unset or enabled, the speed and duplex are not writable.
Dec 27 22:24:36 pve systemd-udevd[3055036]: Using default interface naming scheme 'v247'.
Dec 27 22:24:37 pve kernel: vmbr0: port 5(veth103i0) entered blocking state
Dec 27 22:24:37 pve kernel: vmbr0: port 5(veth103i0) entered disabled state
Dec 27 22:24:37 pve kernel: device veth103i0 entered promiscuous mode
Dec 27 22:24:37 pve kernel: eth0: renamed from vethFJuYdP
Dec 27 22:24:38 pve pvedaemon[2848270]: <root@pam> end task UPID:pve:002E9D99:04CA55DD:63AB6292:vzstart:103:root@pam: OK
Dec 27 22:24:39 pve kernel: IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
Dec 27 22:24:39 pve kernel: vmbr0: port 5(veth103i0) entered blocking state
Dec 27 22:24:39 pve kernel: vmbr0: port 5(veth103i0) entered forwarding state
Dec 27 22:24:43 pve pveproxy[2903103]: worker exit
Dec 27 22:24:43 pve pveproxy[668306]: worker 2903103 finished
Dec 27 22:24:43 pve pveproxy[668306]: starting 1 worker(s)
Dec 27 22:24:43 pve pveproxy[668306]: worker 3055574 started

The lsusb of the host looks the following:
Bus 001 Device 003: ID 0658:0200 Sigma Designs, Inc. Aeotec Z-Stick Gen5 (ZW090) - UZB

Code:
root@pve:~# ls -l /dev/bus/usb/001/003
crw-rw-rw- 1 root users 189, 2 Dec 25 22:58 /dev/bus/usb/001/003

EDIT: I forgot to mention that the usb stick is represented as a /dev/ttyACM0 with the info given in my first post.

To be honest: as i'm fairly new to proxmox, i don't have the slightest idea what could be done wrong from my side.
Any ideas could help :)

Greetings
 
Last edited:
I solved it myself. So for everybody else who wanted to use a Aoetec Zwave Stick in a LXC Container and struggles,
this is what i had to do:

First "lsusb" to get the vendor id and the product id for the udev rule (for later use) and the usb numbers
As above mentioned: 001/003

Then "ls -l /dev/usb/001/003", thats where i got the 189.

Then "ls /dev/serial/by-id/" which gives you a long ID of your device.
In my case it was usb-0658_0200-if00

To which device this is mapped?
Call "ls -l /dev/serial/by-id/" and this gave me ttyACM0

So i got everything i needed to write the following 4 lines, which i added to my lxc YOUR_NUMBER_HERE.conf,
which can be found here /etc/pve/lxc/YOUR_NUMBER.conf

Code:
lxc.cgroup2.devices.allow: c 189:* rwm
lxc.mount.entry: usb-0658_0200-if00 dev/serial/by-id/usb-0658_0200-if00 none bind,optional,create=file
lxc.cgroup2.devices.allow: c 166:* rwm
lxc.mount.entry: /dev/ttyACM0 dev/ttyACM0 none bind,optional,create=file

After that i checked a udev rule:
"nano /etc/udev/rules.d/50-myusb.rules"

And added the following:
Code:
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0658", ATTRS{idProduct}=="0200", GROUP="users", MODE="0666"

After a start of my container i saw the magic /dev/ttyACM0 in the lxc container.

The information how to find all this, especial with the serial/by-id i found in a german video:
lxc and sonnoff stick

I'm not the guy in the vid, but found it all well described.
Hope this helps some else too!
 
Thanks for the info. I do not have a /dev/serial* entry.

Also, how did you get the 166 for /dev/ttyACM0?
 
i will try to answer you in your other thread. Easier than to write infos to a allready closed thread.
 
I believe I have solved it. I found a mention in another thread. I had been passing my USB stick through to another VM using the Proxmox GUI 'Hardware' for that VM. When I removed that and rebooted, /dev/ttyACM0 now shows up.

Thanks!
 

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!