Skip to content

Instantly share code, notes, and snippets.

@gerard33
Created January 19, 2022 19:43
Show Gist options
  • Save gerard33/8bef158b338fdb0cb1c67f680077f3a7 to your computer and use it in GitHub Desktop.
Save gerard33/8bef158b338fdb0cb1c67f680077f3a7 to your computer and use it in GitHub Desktop.
LXC USB Passthrough (Proxmox)
1. Plug USB device
root@proxmox01:~# lsusb
[...]
Bus 004 Device 005: ID 0658:0200 Sigma Designs, Inc.
[...]
2. Take a look of device
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 ID (example: 189, 388)
3. Edit lxc configuration
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
@gerard33
Copy link
Author

gerard33 commented Jan 19, 2022

https://gist.github.com/Yub0/518097e1a9d179dba19a787b462f7dd2#gistcomment-2625690
A little bit more detailed version of the same:

Stop the LXC CT.
# pct stop 102

Then inspect log for this CT.
# cat /var/log/lxc/102.log

Now, disconnect USB device from host and then:
# lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 002: ID 80ee:0021 VirtualBox USB Tablet
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Now connect device and list devices again, here my device is Bus 002 Device 005: ID 0c4b:0600 Reiner SCT Kartensysteme GmbH.
# lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 005: ID 0c4b:0600 Reiner SCT Kartensysteme GmbH
Bus 002 Device 002: ID 80ee:0021 VirtualBox USB Tablet
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
5. Now, by taking the Bus and Device from the previous output.

# ls -l /dev/bus/usb/002/005
crw-rw-rw- 1 root root 189, 132 Jun 20 22:39 /dev/bus/usb/002/005
Edit the following file, appending the following at the end. Here 002, 005 and 189 were taken from the previous outputs.
# cat /etc/pve/lxc/102.conf
...
lxc.cgroup.devices.allow: c 189:* rwm
lxc.mount.entry: /dev/bus/usb/002/005 dev/bus/usb/002/005 none bind,optional,create=file
Start the CT with the following command:
# pct start 102

Then inspect the log again. If there are no new errors there the passthrough worked.
# cat /var/log/lxc/102.log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment