Hey
@gfngfn256,
Problem
I've been reading this thread and running some tests, and it seems I'm stuck with this problem.
I successfully run NUT server (in its docker container) inside an LxC.
I do not want to switch to running the docker directly on the host as you do.
My only issue is that everytime I reboot, a new device id is assigned to the USB, so I have to manually fix the NUT LxC passthrough.
This does not happen with my other USBs (at least not so often) such as Google Coral or a Zigbee antenna, which seem to be much more stable (in terms of device ID), but with the NUT USB its basically everytime I reboot.
Testing suggested fixes
Test 1
I've tried to setup a UDEV symlink and directly passthrough the symlink. It does not work. The container does not recognize the device.
Also I know this is not an issue of running it within docker, since doing the same with my Zigbee LxC container also makes the antenna unrecognizable (and my zigbee2mqtt server is not within docker but directly on the LxC container).
Test 2
I've also tried several approaches with readlinks as you suggested. In order to get full path I even tried something a bit more complex:
Bash:
pct set <vmid> --dev0 path=/dev/$(readlink /dev/coral -n | sed 's|\.\.|/dev|g')
The command works, but it basically assigns the
/dev/usb/bus/XXX/XXX
device, so upon reboot it fails again.
I've also tried to put the command directly within the
/etc/pve/lxc/XXX.conf
file, so that it "reads the link" upon starting the LxC, but it fails since you can't pass bash within that YAML config.
Test 3
I even tried to map the device "the old fashion way" (before Proxmox supported USB passthrough) with this in the LxC config :
YAML:
lxc.cgroup.devices.allow: c 189:* rwm
lxc.mount.entry: /dev/ups dev/bus/usb/001/001 none bind,optional,create=file
This basically maps my
/dev/ups
alias into a
/dev/bus/usb/001/001
device inside the LxC container. But the problem persists, since
/dev/bus/usb/001/001
is still unrecognized by the LxC as a device (since its a symlink).
Test 4
I also saw
this thread and tested to bind the whole bus with this.
Although it seems that with this "old fashioned way"
you can map the entire bus to the LxC container regardless of it being unprivileged, it seems that frigate fails to detect the USB.
Also tried with NUT, and it does not recognize the device when there are more devices mapped to the container.
Alternative Solutions
I think that with a privileged container we could be able to share the udev symlinks between host and LxC, and make it work. Bu
t I want to avoid making my LxC's privileged.
Also, if making it privileged was an option, no udev would be necessary at all since we could pass the whole bus instead of only the device, avoiding any issues with device id changes.
Therefore the only solution I can think of at this point, is a
init.d
script that runs every reboot and updates the new
/dev/bus/usb/XXX/XXX
path with something like:
Bash:
pct set <vmid> -del dev0 && pct set <vmid> --dev0 path=/dev/bus/usb/$(lsusb| grep 051d:0002 | cut -d ':' -f1 | cut -d " " -f2,4 | sed 's| |/|g')
But not even sure if that script would successfully ran after initializing proxmox (so that pct works properly) but before containers are started.
Any other ideas?