USB passthrough to LXC problem

Assuming you restarted (reconfigured?) the NUT container correctly it appears that the NUT container cannot access the original file only the symlink, as your output would indicate:


I googled a bit on the subject & it would appear others have had similar issues with containers (though in docker) only being able to access the symlink & not the original file.

Lets try & see if a workaround helps.

What does the following show (on the PVE host):

readlink /dev/ups0
this is the docker-compose.yml:
Code:
version: '2.2'
services:
  nut-upsd:
    container_name: nut-upsd
    image: upshift/nut-upsd
    devices:
    - /dev/ups0
    environment:
    - UPS_NAME=APC
    - UPS_DRIVER=usbhid-ups
    - API_USER=master
    - API_PASSWORD=mypasswd
    network_mode: host
    restart: unless-stopped

when the usb path changes I modify only the line: - /dev/ups0
 
Replying to my own query - I found the command in the docs! Its with the --delete <string> parameter. So in your case that would be:
pct set VMID --delete dev0 (if you used dev0 originally, I'm not sure) & then reapply the new pct set .... command. Although I believe all this is not necessary - since as long as you used the same device (dev0 ?) both times, & then restarted the LXC, it will simply have been replaced.

In any case please provide, as already requested, the output for (from host):
readlink /dev/ups0

readlink -f /dev/ups0

Good luck.
the command: readlink /dev/ups0 doesn't show anything, readlink -f /dev/ups0 shows "/dev/ups0"
 
Replying to my own query - I found the command in the docs! Its with the --delete <string> parameter. So in your case that would be:
pct set VMID --delete dev0 (if you used dev0 originally, I'm not sure) & then reapply the new pct set .... command. Although I believe all this is not necessary - since as long as you used the same device (dev0 ?) both times, & then restarted the LXC, it will simply have been replaced.

In any case please provide, as already requested, the output for (from host):
readlink /dev/ups0

readlink -f /dev/ups0

Good luck.
Originally I used:
pct set 105 --dev0 path=/dev/bus/usb/001/012
and after:
pct set 105 --dev0 path=/dev/ups0
 
OK you have a rather complicated setup. You are running a docker inside an LXC.

(I must be honest, I also run a NUT server, but I have it inside the Proxmox host. Yes I know its not ideal to tamper too much with the host, but I find that with something that is totally dependent on a specific USB device, I'm not going to go down the rabbit hole of USB passthrough etc.)

But back to your problem, let's try changing the Udev rule & see if it helps. So lets try this:

Code:
nano /etc/udev/rules.d/50-apcups.rules

SUBSYSTEM=="usb", ATTRS{idVendor}=="051d", ATTRS{idProduct}=="0002", SYMLINK+="ups0", GROUP="100000", MODE="0666"

#save & exit

udevadm control --reload

udevadm trigger

Then start up LXC & see what happens.
 
now, when the USB path changes, the LXC container doesn't start, this is the error:
"TASK ERROR: Device /dev/bus/usb/001/012 does not exist"
The LXC container starts again if I type: pct set 105 --delete dev0

Maybe I have to find an easier solution, if I install NUT on proxmox host only UDEV rule is needed?
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!