Forwarding USB devices to the openvz guest


Proxmox 3.3

Forwarding of USB devices to openvz

IMPORTANT: If you connect to a guest more than one device, it is better to directly edit the OpenVZ container config without using vzctl. The reason is that when using the vzctl DEVICES option in the config file is overwritten and all the devices you need to add a single command, or in the config file is only recently added the device.

Forwarding devices in general:

# vzctl set [VEID] --devices b|c:major:minor|all:[r|w|rw|none]

[VEID] – id openvz container, b — block device, c — character device. major:minor – this value can be seen in the output:

# ls -l /dev/bus/usb/[Bus]/[Device]

for example:

# ls -l /dev/bus/usb/002/014     
crw-rw-r-T 1 root adb 189, 141 Apr  9 13:00 /dev/bus/usb/002/014

[Bus] and [Device] in the output of:

# lsusb
Bus 002 Device 014: ID 04e8:6860 Samsung Electronics Co., Ltd GT-I9100 Phone [Galaxy S II], GT-P7500 [Galaxy Tab 10.1]
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 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0b39:1001 Omnidirectional Control Technology, Inc. 
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

Forwarding example for named device (in / dev /):

# vzctl set [VEID] --devnodes ttyACM0:rw --save

device name can be found in the output of dmesg after you connect the device, for example:

usb 2-1.3: new high speed USB device number 14 using ehci_hcd
usb 2-1.3: New USB device found, idVendor=04e8, idProduct=6860
usb 2-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 2-1.3: Product: SAMSUNG_Android
usb 2-1.3: Manufacturer: SAMSUNG
usb 2-1.3: SerialNumber: 7f4197c6
usb 2-1.3: configuration #1 chosen from 1 choice
cdc_acm 2-1.3:1.1: This device cannot do calls on its own. It is not a modem.
cdc_acm 2-1.3:1.1: ttyACM0: USB ACM device

major: minor code example:

# vzctl set [VEID] --devices c:189:141:rw --save

forwarding example for directly editing the config:

# vipw /etc/pve/openvz/[VEID].conf
DEVNODES="ttyACM0:rw "
DEVNODES="c:189:all:rw "

To carryover USB device into a working container must mount from the host to the guest system:

# mount -o bind /dev/ [VE_ROOT]/dev/

, [VE_ROOT] – root of openvz container.In proxmox usually located here:

/var/lib/vz/root/[VEID] .

[VEID] – id of the container
# man vzctl

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.