passthrough usb from host to lxc?

Initially i tried with the bind option but no luck.
I just found that when i run: lxc-device add -n 112 /dev/ttyUSB0 /dev/ttyUSB0 on the host the passthrough works.
Only it will not survive a reboot of the container. Any idea how to do that?
 
You will need a line saying something like below in the container config file (/etc/pve/lxc/CTID.conf)

Code:
lxc.cgroup.devices.allow = c 212:* rwm


You need to replace 212 and * with major:minor of your USB device.

from here:
http://askubuntu.com/questions/545359/lxc-usb-device-passthrough
 
You will need a line saying something like below in the container config file (/etc/pve/lxc/CTID.conf)

Code:
lxc.cgroup.devices.allow = c 212:* rwm



I did try that already but does not work. Maybe because it is not a storage usb device but a ftdi (433mhz transciever).
 
Adding these lines to the .conf of the container makes me see the usb device on the container when checking with lsusb:

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

root@domoticz:~# lsusb
Bus 002 Device 005: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Also the software i use to control the 433mhz transceiver sees the device at serial port /dev/ttyUSB0 but it cannot use it until i give the: lxc-device add -n 112 /dev/ttyUSB0 /dev/ttyUSB0 ​on the host.
 
I don't know if it has anything to do with this but when i login over SSH as root in the container all seems ok.
But when i login as a user i get:

root@domoticz:~# login sierink
Password:
Last login: Sat Oct 10 16:13:30 CEST 2015 on pts/2
Welcome to Ubuntu 14.04.3 LTS (GNU/Linux 4.2.2-1-pve x86_64)
* Documentation: https://help.ubuntu.com/
-bash: /dev/null: Permission denied
-bash: /dev/null: Permission denied
-bash: /dev/null: Permission denied
-bash: /dev/null: Permission denied
-bash: /dev/null: Permission denied
-bash: /dev/null: Permission denied
-bash: /dev/null: Permission denied
-bash: /dev/null: Permission denied
-bash: /dev/null: Permission denied
-bash: /dev/null: Permission denied
-bash: /dev/null: Permission denied
-bash: /dev/null: Permission denied
-bash: /dev/null: Permission denied
-bash: /dev/null: Permission denied
 
the -bash: /dev/null: Permission denied issue was solved by: chmod 666 /dev/null

Remains the USB passthrough which is not working correctly. Even after the 'lxc-device add' command there is no 2 way traffic to the usb transceiver. It only sends signals but is not capable of receiving them.
 
Just wanted to share my experiences with this.

I have successfully passed through my USB TV Tuner in LXC on proxmox and everything seems to work.

I just needed to add these lines to my lxc config.

Code:
lxc.cgroup.devices.allow = c 212:* rwm
lxc.mount.entry = /dev/dvb dev/dvb  none bind,optional,create=dir
lxc.mount.entry = /dev/bus/usb/001 dev/bus/usb/001 none bind,optional,create=dir
 
Last edited:
  • Like
Reactions: James Crook
Is it possible to set the parameters

lxc.cgroup.devices.allow
lxc.mount.entry

in /etc/pve/lxc/node.conf instead of /var/lib/lxc/node/config?
 
yes, all options starting with "lxc." are passed on to the generated lxc configuration file. some of them can break your setup though, so make sure you know what you are doing.
 
Take a look at the following procedure for an step by step guide, https ://gist.github.com/Yub0/518097e1a9d179dba19a787b462f7dd2#gistcomment-2625690
 

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!