usb-passthrough
Make the host's USB serial devices available in a privileged LXC container through an autodev hook.
usb-passthrough.sh adds an lxc.hook.autodev entry to one container's configuration. At every start of the container the hook copies the device nodes of the host's USB character devices into the container's /dev. It is meant for privileged containers and is not listed on the website.
Source: tools/pve/usb-passthrough.sh.
Run
In the Proxmox VE host shell, as root. The container ID is a required argument; replace 106 with yours:
bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/tools/pve/usb-passthrough.sh)" -s 106There is no container menu. The ID is read from the first argument ($1).
Prompt
| Prompt | Input | Effect |
|---|---|---|
Did you replace 106 with your LXC ID? Proceed(y/n)? | y | Continues. |
n | Exits without changes. |
What it changes
In /etc/pve/lxc/<id>.conf the script removes every line that contains autodev and appends:
lxc.autodev: 1
lxc.hook.autodev: bash -c '<hook>'The hook searches /sys/dev/char for character devices with the major numbers 166, 188 and 189, and copies each device node and its /dev symlinks (from udevadm info) into the container's root filesystem. 188 covers ttyUSB* and 189 covers bus/usb/*.
Reboot the container to apply the change.
Undo
Remove the two lines from /etc/pve/lxc/<id>.conf and restart the container.
Limits
- Without an ID the script works on
/etc/pve/lxc/.confand fails. It does not check that the container exists or that it is privileged. - Devices are copied when the container starts. A USB device plugged in later appears only after the next container start.
- An existing
lxc.autodevorlxc.hook.autodevline is replaced, including one written by frigate-support. - All matching USB devices of the host are passed in, not a selected one.
- The script works in a temporary directory that it does not remove.
- It reads no environment variables and sends no telemetry.