[SOLVED] LXC USB Passthrough (ZWave Stick)

tschanness

Member
Oct 30, 2016
291
22
18
33
Hi,
sadly there is no wiki entry for LXC USB Passthrough, so if someone has the same problem as me he will at least find it in the forum. Nice work with VE 4.3 btw.

1st.
Plug in you USB ZWave stick and find the Major:Minor Numbers:
Code:
root@proxmox01:~# lsusb
[...]
Bus 004 Device 005: ID 0658:0200 Sigma Designs, Inc.
[...]
Major Number is 4, Minor is 5 for me (Bus and Device). Yours will vary.

2nd.
Take a look at the /dev Filetree:
Code:
root@proxmox01:~# ls -l /dev/bus/usb/004/005
crw-rw-r-- 1 root root 189, 388 Oct 25 16:19 /dev/bus/usb/004/005
Take note of the 189,388. Yours may differ. I'm not even sure what those numbers mean :/

3rd.
Edit the LXC Config file:
Code:
root@proxmox01:~# nano /etc/pve/nodes/proxmox01/lxc/101.conf
lxc.cgroup.devices.allow: c 189:388 rwm
lxc.mount.entry: /dev/bus/usb/004/005 dev/bus/usb/004/005 none bind,optional,create=file
You File will be in another Location.

4th.
Wonder why it does not work

5th.
The ZWave Stick creates a ttyACM device:
Code:
root@proxmox01:~# ls -l /dev/ttyACM0
crwxrwxrwx 1 root dialout 166, 0 Oct 30 13:38 /dev/ttyACM0
Note the 166 here. Add it to your Container:
Code:
lxc.cgroup.devices.allow: c 166:* rwm
lxc.mount.entry: /dev/ttyACM0 dev/ttyACM0 none bind,optional,create=file

This was it for me. I hope it helps someone.
 
Thanks for posting, this helped me get openhab running in a container.

One note. If the container is unprivileged, you will need to give permissions to /dev/ttyACM0 from the host. chmod o+rw /dev/ttyACM0 did the trick. If you don't want to give permissions to everyone, I suspect (but not sure) that you can fiddle with adding the required uid's inside the container to the /dev/ttyACM0 device's group (dialout) outside the container, Restart the container to take effect.
 
Here you have another step by step guide, https ://gist.github.com/Yub0/518097e1a9d179dba19a787b462f7dd2#gistcomment-2625690.

Note that it is important to use Proxmox's pct to stop and start containers instead of lxc's tools.
 
  • Like
Reactions: tschanness
Sorry to open up an old post.
I followed the mods directions and my z wave stick works great unless I restart or shutdown the host. Then I need to give permissions to /dev/ttyACM0 using chmod o+rw /dev/ttyACM0 for it to work again.

Is there a way to get around this?
 
The web page is no longer available

Wayback machine is your friend:
https://web.archive.org/web/2019081...o.com/change-usb-device-permission-linux.html

...

As a permanent solution, you can create a udev-based USB permission rule which assigns any custom permission mode of your choice. Here is how to do it.

First, you need to identify the vendorID and productID of your USB device. For that, use lsusb command.

$ lsusb -vvv

From the lsusb output, find your USB device's entry, and look for "idVendor" and "idProduct" fields. In this example, we have idVendor (0x067b) and idProduct (0x2303).

Next, create a new udev rule as follows.

$ sudo vi /etc/udev/rules.d/50-myusb.rules SUBSYSTEMS=="usb", ATTRS{idVendor}=="067b", ATTRS{idProduct}=="2303", GROUP="users", MODE="0666"

Replace "idVendor" and "idProduct" values with your own. MODE="0666" indicates the preferred permission of the USB device.

Now reboot your machine or reload udev rules:

$ sudo udevadm control --reload
Then verify the permission of the USB device.
 
Wayback machine is your friend:
https://web.archive.org/web/2019081...o.com/change-usb-device-permission-linux.html

...

As a permanent solution, you can create a udev-based USB permission rule which assigns any custom permission mode of your choice. Here is how to do it.

First, you need to identify the vendorID and productID of your USB device. For that, use lsusb command.

$ lsusb -vvv

From the lsusb output, find your USB device's entry, and look for "idVendor" and "idProduct" fields. In this example, we have idVendor (0x067b) and idProduct (0x2303).

Next, create a new udev rule as follows.

$ sudo vi /etc/udev/rules.d/50-myusb.rules SUBSYSTEMS=="usb", ATTRS{idVendor}=="067b", ATTRS{idProduct}=="2303", GROUP="users", MODE="0666"

Replace "idVendor" and "idProduct" values with your own. MODE="0666" indicates the preferred permission of the USB device.

Now reboot your machine or reload udev rules:

$ sudo udevadm control --reload
Then verify the permission of the USB device.
Thanks! Downloaded the pdf in the thread as well for future reference
 
One note. If the container is unprivileged, you will need to give permissions to /dev/ttyACM0 from the host. chmod o+rw /dev/ttyACM0 did the trick. If you don't want to give permissions to everyone, I suspect (but not sure) that you can fiddle with adding the required uid's inside the container to the /dev/ttyACM0 device's group (dialout) outside the container
Apologies for quoting this so many years later but I don't really understand this
 

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!