[PVE-User] Share an usb device with a forced dev entry between proxmox and lxc

Guillaume proxmox at shadowprojects.org
Thu Jan 12 13:01:43 CET 2017


Hello,
I'm trying to share an usb 4g key between a proxmox 4.server and a lxc 
container.

Device is as follow on the server :
Bus 001 Device 037: ID 12d1:1003 Huawei Technologies Co., Ltd. E220 
HSDPA Modem / E230/E270/E870 HSDPA/HSUPA Modem

I created this udev rule on the server to have a fixed endpoint in /dev :
/etc/udev/rules.d/10-usbsms.rules
ACTION=="add", KERNEL=="ttyUSB[0-9]*", ATTRS{idVendor}=="12d1", 
ATTRS{idProduct}=="1003", GROUP="dialout", MODE="0666", SYMLINK+="usbsms%n"

Result in /dev :
crw-rw-rw-  1 root dialout 188,   0 Jan 12 12:40 ttyUSB0
crw-rw-rw-  1 root dialout 188,   1 Jan 12 12:40 ttyUSB1
crw-rw-rw-  1 root dialout 188,   2 Jan 12 11:17 ttyUSB2
...
drwxr-xr-x  2 root root          60 Dec 20 10:47 usb
lrwxrwxrwx  1 root dialout        7 Jan 12 12:40 usbsms0 -> ttyUSB0
lrwxrwxrwx  1 root dialout        7 Jan 12 12:40 usbsms1 -> ttyUSB1

On my container configuration file, i mount the device :
lxc.aa_profile: unconfined
lxc.cgroup.devices.allow: c 188:* rwm
lxc.cgroup.devices.allow: c 189:* rwm
lxc.mount.entry: /dev/bus/usb/001 dev/bus/usb/001 none 
bind,optional,create=dir
lxc.mount.entry: /dev/ttyUSB0 dev/ttyUSB0 none bind,optional,create=file
lxc.mount.entry: /dev/ttyUSB1 dev/ttyUSB1 none bind,optional,create=file
lxc.mount.entry: /dev/ttyUSB2 dev/ttyUSB2 none bind,optional,create=file
lxc.mount.entry: /dev/usbsms0 /dev/usbsms0 none bind,optional,create=file
lxc.mount.entry: /dev/usbsms1 /dev/usbsms1 none bind,optional,create=file

Here's the result on my container :
~# lsusb
Bus 006 Device 002: ID 03f0:1027 Hewlett-Packard Virtual keyboard and mouse
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 037: ID 12d1:1003 Huawei Technologies Co., Ltd. E220 
HSDPA Modem / E230/E270/E870 HSDPA/HSUPA Modem
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 005 Device 006: ID 0c45:7401 Microdia TEMPer Temperature Sensor
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

~# ll /dev
total 4
drwxr-xr-x  8 root root       560 Jan 12 12:54 ./
drwxr-xr-x 22 root root      4096 Jan 12 12:54 ../
...
crw-rw-rw-  1 root dialout 188, 0 Jan 12 12:40 ttyUSB0
crw-rw-rw-  1 root dialout 188, 1 Jan 12 12:40 ttyUSB1
crw-rw-rw-  1 root dialout 188, 2 Jan 12 11:17 ttyUSB2
...

No /dev/usbsms* entries.

And if i try to create a udev rules on the container side instead :
SUBSYSTEM=="tty", ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="1003", 
GROUP="dialout", MODE="0666", SYMLINK+="usbsms%n"

I got nothing either in /dev

Any hint ?
Thanks,

-- 
   Guillaume Hilt




More information about the pve-user mailing list