USB passthrough to LXC problem

enry86cami

New Member
May 25, 2023
19
2
3
Hi all,
I installed Virtual Environment 8.1.4 on a notebook. I create a LXC container with home assistant.
Now I'd like to install (network UPS tool) NUT in this container. So I need to pass the UPS USB from the host to the container.

HOST-SIDE:
root@proxmoxea:~# lsusb
Bus 001 Device 005: ID 051d:0002 American Power Conversion Uninterruptible Power Supply

root@proxmoxea:/dev/bus/usb/001# ls -l 005
crw-rw-r-- 1 root root 189, 4 Apr 13 19:06 005

I followed this guide:
https://www.schreiners-it.de/proxmox/usb-geraet-in-lxc-container-unter-proxmox-7-1/

so:

root@proxmoxea:/home# sudo nano /etc/pve/lxc/102.conf

arch: amd64
cores: 2
features: nesting=1
hostname: homeassistant
memory: 1024
net0: name=eth0,bridge=vmbr0,firewall=1,gw=192.168.0.1,hwaddr=AA:8D:52:E4:F1:D0,ip=192.168.0.28/24,type=veth
ostype: debian
rootfs: local-lvm:vm-102-disk-0,size=10G
swap: 512
unprivileged: 1
lxc.cgroup.devices.allow: c 189:* rwm
lxc.mount.entry: /dev/bus/usb/001/005 dev/bus/usb none bind,optional,create=file

but I don't have the ttyACM file (or ttyUSB0):

root@proxmoxea:/home# ls -l /dev/tty*
crw-rw-rw- 1 root tty 5, 0 Apr 14 13:24 /dev/tty
crw--w---- 1 root tty 4, 0 Apr 13 19:06 /dev/tty0
crw--w---- 1 root tty 4, 1 Apr 13 19:06 /dev/tty1
crw--w---- 1 root tty 4, 10 Apr 13 19:06 /dev/tty10
crw--w---- 1 root tty 4, 11 Apr 13 19:06 /dev/tty11
crw--w---- 1 root tty 4, 12 Apr 13 19:06 /dev/tty12
crw--w---- 1 root tty 4, 13 Apr 13 19:06 /dev/tty13
crw--w---- 1 root tty 4, 14 Apr 13 19:06 /dev/tty14
crw--w---- 1 root tty 4, 15 Apr 13 19:06 /dev/tty15
crw--w---- 1 root tty 4, 16 Apr 13 19:06 /dev/tty16
crw--w---- 1 root tty 4, 17 Apr 13 19:06 /dev/tty17
crw--w---- 1 root tty 4, 18 Apr 13 19:06 /dev/tty18
crw--w---- 1 root tty 4, 19 Apr 13 19:06 /dev/tty19
crw--w---- 1 root tty 4, 2 Apr 13 19:06 /dev/tty2
crw--w---- 1 root tty 4, 20 Apr 13 19:06 /dev/tty20
crw--w---- 1 root tty 4, 21 Apr 13 19:06 /dev/tty21
crw--w---- 1 root tty 4, 22 Apr 13 19:06 /dev/tty22
crw--w---- 1 root tty 4, 23 Apr 13 19:06 /dev/tty23
crw--w---- 1 root tty 4, 24 Apr 13 19:06 /dev/tty24
crw--w---- 1 root tty 4, 25 Apr 13 19:06 /dev/tty25
crw--w---- 1 root tty 4, 26 Apr 13 19:06 /dev/tty26
crw--w---- 1 root tty 4, 27 Apr 13 19:06 /dev/tty27
crw--w---- 1 root tty 4, 28 Apr 13 19:06 /dev/tty28
crw--w---- 1 root tty 4, 29 Apr 13 19:06 /dev/tty29
crw--w---- 1 root tty 4, 3 Apr 13 19:06 /dev/tty3
crw--w---- 1 root tty 4, 30 Apr 13 19:06 /dev/tty30
crw--w---- 1 root tty 4, 31 Apr 13 19:06 /dev/tty31
crw--w---- 1 root tty 4, 32 Apr 13 19:06 /dev/tty32
crw--w---- 1 root tty 4, 33 Apr 13 19:06 /dev/tty33
crw--w---- 1 root tty 4, 34 Apr 13 19:06 /dev/tty34
crw--w---- 1 root tty 4, 35 Apr 13 19:06 /dev/tty35
crw--w---- 1 root tty 4, 36 Apr 13 19:06 /dev/tty36
crw--w---- 1 root tty 4, 37 Apr 13 19:06 /dev/tty37
crw--w---- 1 root tty 4, 38 Apr 13 19:06 /dev/tty38
crw--w---- 1 root tty 4, 39 Apr 13 19:06 /dev/tty39
crw--w---- 1 root tty 4, 4 Apr 13 19:06 /dev/tty4
crw--w---- 1 root tty 4, 40 Apr 13 19:06 /dev/tty40
crw--w---- 1 root tty 4, 41 Apr 13 19:06 /dev/tty41
crw--w---- 1 root tty 4, 42 Apr 13 19:06 /dev/tty42
crw--w---- 1 root tty 4, 43 Apr 13 19:06 /dev/tty43
crw--w---- 1 root tty 4, 44 Apr 13 19:06 /dev/tty44
crw--w---- 1 root tty 4, 45 Apr 13 19:06 /dev/tty45
crw--w---- 1 root tty 4, 46 Apr 13 19:06 /dev/tty46
crw--w---- 1 root tty 4, 47 Apr 13 19:06 /dev/tty47
crw--w---- 1 root tty 4, 48 Apr 13 19:06 /dev/tty48
crw--w---- 1 root tty 4, 49 Apr 13 19:06 /dev/tty49
crw--w---- 1 root tty 4, 5 Apr 13 19:06 /dev/tty5
crw--w---- 1 root tty 4, 50 Apr 13 19:06 /dev/tty50
crw--w---- 1 root tty 4, 51 Apr 13 19:06 /dev/tty51
crw--w---- 1 root tty 4, 52 Apr 13 19:06 /dev/tty52
crw--w---- 1 root tty 4, 53 Apr 13 19:06 /dev/tty53
crw--w---- 1 root tty 4, 54 Apr 13 19:06 /dev/tty54
crw--w---- 1 root tty 4, 55 Apr 13 19:06 /dev/tty55
crw--w---- 1 root tty 4, 56 Apr 13 19:06 /dev/tty56
crw--w---- 1 root tty 4, 57 Apr 13 19:06 /dev/tty57
crw--w---- 1 root tty 4, 58 Apr 13 19:06 /dev/tty58
crw--w---- 1 root tty 4, 59 Apr 13 19:06 /dev/tty59
crw--w---- 1 root tty 4, 6 Apr 13 19:06 /dev/tty6
crw--w---- 1 root tty 4, 60 Apr 13 19:06 /dev/tty60
crw--w---- 1 root tty 4, 61 Apr 13 19:06 /dev/tty61
crw--w---- 1 root tty 4, 62 Apr 13 19:06 /dev/tty62
crw--w---- 1 root tty 4, 63 Apr 13 19:06 /dev/tty63
crw--w---- 1 root tty 4, 7 Apr 13 19:06 /dev/tty7
crw--w---- 1 root tty 4, 8 Apr 13 19:06 /dev/tty8
crw--w---- 1 root tty 4, 9 Apr 13 19:06 /dev/tty9
crw------- 1 root root 5, 3 Apr 13 19:06 /dev/ttyprintk
crw-rw---- 1 root dialout 4, 64 Apr 13 19:06 /dev/ttyS0
crw-rw---- 1 root dialout 4, 65 Apr 13 19:06 /dev/ttyS1
crw-rw---- 1 root dialout 4, 74 Apr 13 19:06 /dev/ttyS10
crw-rw---- 1 root dialout 4, 75 Apr 13 19:06 /dev/ttyS11
crw-rw---- 1 root dialout 4, 76 Apr 13 19:06 /dev/ttyS12
crw-rw---- 1 root dialout 4, 77 Apr 13 19:06 /dev/ttyS13
crw-rw---- 1 root dialout 4, 78 Apr 13 19:06 /dev/ttyS14
crw-rw---- 1 root dialout 4, 79 Apr 13 19:06 /dev/ttyS15
crw-rw---- 1 root dialout 4, 80 Apr 13 19:06 /dev/ttyS16
crw-rw---- 1 root dialout 4, 81 Apr 13 19:06 /dev/ttyS17
crw-rw---- 1 root dialout 4, 82 Apr 13 19:06 /dev/ttyS18
crw-rw---- 1 root dialout 4, 83 Apr 13 19:06 /dev/ttyS19
crw-rw---- 1 root dialout 4, 66 Apr 13 19:06 /dev/ttyS2
crw-rw---- 1 root dialout 4, 84 Apr 13 19:06 /dev/ttyS20
crw-rw---- 1 root dialout 4, 85 Apr 13 19:06 /dev/ttyS21
crw-rw---- 1 root dialout 4, 86 Apr 13 19:06 /dev/ttyS22
crw-rw---- 1 root dialout 4, 87 Apr 13 19:06 /dev/ttyS23
crw-rw---- 1 root dialout 4, 88 Apr 13 19:06 /dev/ttyS24
crw-rw---- 1 root dialout 4, 89 Apr 13 19:06 /dev/ttyS25
crw-rw---- 1 root dialout 4, 90 Apr 13 19:06 /dev/ttyS26
crw-rw---- 1 root dialout 4, 91 Apr 13 19:06 /dev/ttyS27
crw-rw---- 1 root dialout 4, 92 Apr 13 19:06 /dev/ttyS28
crw-rw---- 1 root dialout 4, 93 Apr 13 19:06 /dev/ttyS29
crw-rw---- 1 root dialout 4, 67 Apr 13 19:06 /dev/ttyS3
crw-rw---- 1 root dialout 4, 94 Apr 13 19:06 /dev/ttyS30
crw-rw---- 1 root dialout 4, 95 Apr 13 19:06 /dev/ttyS31
crw-rw---- 1 root dialout 4, 68 Apr 13 19:06 /dev/ttyS4
crw-rw---- 1 root dialout 4, 69 Apr 13 19:06 /dev/ttyS5
crw-rw---- 1 root dialout 4, 70 Apr 13 19:06 /dev/ttyS6
crw-rw---- 1 root dialout 4, 71 Apr 13 19:06 /dev/ttyS7
crw-rw---- 1 root dialout 4, 72 Apr 13 19:06 /dev/ttyS8
crw-rw---- 1 root dialout 4, 73 Apr 13 19:06 /dev/ttyS9

I looked also this thread but doesn't work for me:
https://forum.proxmox.com/threads/pass-usb-device-to-lxc.124205/

Can anyone help me?
 
Hi,

you made a little mistake in your config file:

Instead of your code:
lxc.mount.entry: /dev/bus/usb/001/005 dev/bus/usb none bind,optional,create=file

Try this line:
lxc.mount.entry: /dev/bus/usb/001/005 dev/bus/usb/001/005 none bind,optional,create=file

The ttyACM is not relevant in your case.

After you saved the config file. Turn of your container and turn it on again. Try the nut-scanner -U command and you should see your UPS (USV).

The downside for this solution: After a shutdown or restart of the proxmox server, the usb port may be changed, so you need to adjust the config file again.
 
thanks for your reply. I'll try... About the USB port changing after a reboot, I'd like to assign a fixed port, so is there another solution?
 
Now I'd like to install (network UPS tool) NUT in this container. So I need to pass the UPS USB from the host to the container.

HOST-SIDE:
root@proxmoxea:~# lsusb
Bus 001 Device 005: ID 051d:0002 American Power Conversion Uninterruptible Power Supply

There's software similar to NUT for American Power Conversion UPSs called apcupsd

It talks to the UPS via /dev/usb/hiddev0 - you might have more luck passing that through instead of the raw USB bus.

Note: I run apcupsd directly on the proxmox host rather than in an LXC, so it can shut the VMs and host down cleanly in case of an extended power outage, so I haven't verified if passing the hiddev0 device through is enough.

Bash:
MachineOfLovingGrace ~ # dmesg | grep 'American Power'
[    1.829442] usb 3-4: Manufacturer: American Power Conversion
[    1.837834] hid-generic 0003:051D:0002.0001: hiddev0,hidraw0: USB HID v1.00 Device [American Power Conversion Back-UPS RS 1500G FW:878.L4 .I USB FW:L4 ] on usb-0000:00:14.0-4/input0  
MachineOfLovingGrace ~ # ls -l /proc/`pidof apcupsd`/fd
total 0
lr-x------ 1 root root 64 May  1 08:28 0 -> /dev/null
lr-x------ 1 root root 64 May  1 08:28 1 -> /dev/null
lr-x------ 1 root root 64 May  1 08:28 2 -> /dev/null
lrwx------ 1 root root 64 May  1 08:28 3 -> /var/log/apcupsd.events
lrwx------ 1 root root 64 May  1 08:28 4 -> socket:[7544]
lrwx------ 1 root root 64 May  1 08:28 5 -> socket:[2715]
lrwx------ 1 root root 64 May  1 08:28 7 -> /dev/usb/hiddev0
l-wx------ 1 root root 64 May  1 08:28 8 -> /var/log/apcupsd.status
 
lxc.cgroup.devices.allow: c 189:* rwm
As per docs that should be:
Code:
lxc.cgroup2.devices.allow: c 189:* rwm

root@proxmoxea:/home# ls -l /dev/tty*
It looks like you are searching in your Proxmox host, I believe you should be searching in the LXC "Homeassistant" CT 102

About the USB port changing after a reboot
You have 2 options for this:

1. Create a udev rule, example here.
2. Pass the whole USB bus/ instead of just bus/port, example here.
 
Hi,

you made a little mistake in your config file:

Instead of your code:
lxc.mount.entry: /dev/bus/usb/001/005 dev/bus/usb none bind,optional,create=file

Try this line:
lxc.mount.entry: /dev/bus/usb/001/005 dev/bus/usb/001/005 none bind,optional,create=file

The ttyACM is not relevant in your case.

After you saved the config file. Turn of your container and turn it on again. Try the nut-scanner -U command and you should see your UPS (USV).

The downside for this solution: After a shutdown or restart of the proxmox server, the usb port may be changed, so you need to adjust the config file again.
with you suggested line (host side):
Code:
lxc.cgroup2.devices.allow: c 189:* rwm
lxc.mount.entry: /dev/bus/usb/001/005 dev/bus/usb/001/005 none bind,optional,create=file

I have this (client side):
Code:
root@utilities:/# ls -l /dev/bus/usb/001/005
crw-rw-r-- 1 nobody nogroup 189, 4 May  3 18:46 /dev/bus/usb/001/005

this is the log of nut container:
Code:
root@utilities:/home/nut# docker compose logs
WARN[0000] /home/nut/docker-compose.yml: `version` is obsolete
nut-upsd  | + '[' -z mypasswd ]
nut-upsd  | + '[' -z  ]
nut-upsd  | + base64
nut-upsd  | + dd 'if=/dev/urandom' 'bs=18' 'count=1'
nut-upsd  | + ADMIN_PASSWORD=gerterHW0+3
nut-upsd  | + cat
nut-upsd  | + cat
nut-upsd  | + cat
nut-upsd  | + cat
nut-upsd  | + chgrp -R nut /etc/nut /dev/bus/usb
nut-upsd  | chgrp: /dev/bus/usb/001/005: Operation not permitted

Is this a permission problem?
 
Last edited:
lxc.cgroup2.devices.allow: c 189:* rwm lxc.mount.entry: /dev/bus/usb/001/005 dev/bus/usb/001/005 none bind,optional,create=file
Instead of mounting the device node into the container,

use the device passthrough feature instead:
Code:
pct set <vmid> --dev0 path=/dev/bus/usb/001/005
This creates a new device node within the container,

nut-upsd | chgrp: /dev/bus/usb/001/005: Operation not permitted
which should fix this error.
 
Instead of mounting the device node into the container,

use the device passthrough feature instead:
Code:
pct set <vmid> --dev0 path=/dev/bus/usb/001/005
This creates a new device node within the container,


which should fix this error.
Not sure i follow .. in prox8.1 setting the: pct set ... do a passthrought like any pci-e in vm.. So we do not have to deal anymore with the id 189* rwm ..
as i quickly check on prox 8.2 and the gui show line to set gid uid. Is the line / lxc.cgroup2.devices.allow: c 189:* rwm / is still needed to a proper pass in 8.1 when using the pct set lxcid ... or it required a change of 3 file to somehow get the guid-cid to set. ? (for unpriviledge container)
 
When using the container device passthrough feature, there is no need to manually specify allow device rules with lxc.cgroup2.devices.allow. This also works with unprivileged containers.

The options uid and gid specify the ids of the device node within the container. If not set, it defaults to uid=0 and gid=0.
Code:
pct set <vmid> --dev0 path=/dev/bus/usb/001/005,uid=0,gid=0
 
When using the container device passthrough feature, there is no need to manually specify allow device rules with lxc.cgroup2.devices.allow. This also works with unprivileged containers.
This is news for me. I personally don't use USB device passthrough to LXC, but would be eager to hear from other users who have managed this with the above pct set <vmid> --dev0 .... command alone (working).
 
This is news for me. I personally don't use USB device passthrough to LXC, but would be eager to hear from other users who have managed this with the above pct set <vmid> --dev0 .... command alone (working).
i got a usb tv tuner working in an unpriv plex lxc and a pci coral tpu in an unpriv frigate lxc with this method (but through the web gui through the resource > add > device passthrough menu). also got the igpu in both with the same method
 
  • Like
Reactions: gfngfn256
Instead of mounting the device node into the container,

use the device passthrough feature instead:
Code:
pct set <vmid> --dev0 path=/dev/bus/usb/001/005
This creates a new device node within the container,


which should fix this error.
many thanks, now it works and it is very simple.... I don't why on the net I found many guide but all "complicated "

but now after a reboot the usb continues changing. could you suggest how avoid this?
 
but now after a reboot the usb continues changing. could you suggest how avoid this?
To avoid this you need to make a udev rule to assign a unique name for the specific USB device using the device's (unique) attributes. This will then survive a reboot/bus port change.
Read here on this subject.
 
To avoid this you need to make a udev rule to assign a unique name for the specific USB device using the device's (unique) attributes. This will then survive a reboot/bus port change.
Read here on this subject.
many thanks for your support. I have a doubt:
-I extrated the info by: udevadm info --name=/dev/bus/usb/001/009 --attribute-walk
but this give me a lot of info....
Code:
Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/devices/pci0000:00/0000:00:14.0/usb1/1-4/1-4.2':
    KERNEL=="1-4.2"
    SUBSYSTEM=="usb"
    DRIVER=="usb"
    ATTR{authorized}=="1"
    ATTR{avoid_reset_quirk}=="0"
    ATTR{bConfigurationValue}=="1"
    ATTR{bDeviceClass}=="00"
    ATTR{bDeviceProtocol}=="00"
    ATTR{bDeviceSubClass}=="00"
    ATTR{bMaxPacketSize0}=="64"
    ATTR{bMaxPower}=="2mA"
    ATTR{bNumConfigurations}=="1"
    ATTR{bNumInterfaces}==" 1"
    ATTR{bcdDevice}=="0090"
    ATTR{bmAttributes}=="e0"
    ATTR{busnum}=="1"
    ATTR{configuration}==""
    ATTR{devnum}=="12"
    ATTR{devpath}=="4.2"
    ATTR{idProduct}=="0002"
    ATTR{idVendor}=="051d"
    ATTR{ltm_capable}=="no"
    ATTR{manufacturer}=="American Power Conversion"
    ATTR{maxchild}=="0"
    ATTR{product}=="Back-UPS RS 550GI FW:857.L3 .I USB FW:L3  "
    ATTR{quirks}=="0x0"
    ATTR{removable}=="unknown"
    ATTR{remove}=="(not readable)"
    ATTR{rx_lanes}=="1"
    ATTR{serial}=="3B1209X31427  "
    ATTR{speed}=="12"
    ATTR{tx_lanes}=="1"
    ATTR{urbnum}=="242"
    ATTR{version}==" 2.00"

  looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1/1-4':
    KERNELS=="1-4"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{authorized}=="1"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bDeviceClass}=="09"
    ATTRS{bDeviceProtocol}=="02"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{bMaxPower}=="0mA"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bcdDevice}=="5000"
    ATTRS{bmAttributes}=="e0"
    ATTRS{busnum}=="1"
    ATTRS{configuration}==""
    ATTRS{devnum}=="3"
    ATTRS{devpath}=="4"
    ATTRS{idProduct}=="2134"
    ATTRS{idVendor}=="0424"
    ATTRS{ltm_capable}=="no"
    ATTRS{manufacturer}=="SMSC"
    ATTRS{maxchild}=="4"
    ATTRS{physical_location/dock}=="no"
    ATTRS{physical_location/horizontal_position}=="left"
    ATTRS{physical_location/lid}=="no"
    ATTRS{physical_location/panel}=="right"
    ATTRS{physical_location/vertical_position}=="upper"
    
    ATTRS{product}=="USB2134B"
    ATTRS{quirks}=="0x0"
    ATTRS{removable}=="fixed"
    ATTRS{remove}=="(not readable)"
    ATTRS{rx_lanes}=="1"
    ATTRS{speed}=="480"
    ATTRS{tx_lanes}=="1"
    ATTRS{urbnum}=="135"
    ATTRS{version}==" 2.10"

  looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1':
    KERNELS=="usb1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{authorized}=="1"
    ATTRS{authorized_default}=="1"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bDeviceClass}=="09"
    ATTRS{bDeviceProtocol}=="01"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{bMaxPower}=="0mA"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bcdDevice}=="0605"
    ATTRS{bmAttributes}=="e0"
    ATTRS{busnum}=="1"
    ATTRS{configuration}==""
    ATTRS{devnum}=="1"
    ATTRS{devpath}=="0"
    ATTRS{idProduct}=="0002"
    ATTRS{idVendor}=="1d6b"
    ATTRS{interface_authorized_default}=="1"
    ATTRS{ltm_capable}=="no"
    ATTRS{manufacturer}=="Linux 6.5.13-1-pve xhci-hcd"
    ATTRS{maxchild}=="12"
    ATTRS{product}=="xHCI Host Controller"
    ATTRS{quirks}=="0x0"
    ATTRS{removable}=="unknown"
    ATTRS{remove}=="(not readable)"
    ATTRS{rx_lanes}=="1"
    ATTRS{serial}=="0000:00:14.0"
    ATTRS{speed}=="480"
    ATTRS{tx_lanes}=="1"
    ATTRS{urbnum}=="147"
    ATTRS{version}==" 2.00"

  looking at parent device '/devices/pci0000:00/0000:00:14.0':
    KERNELS=="0000:00:14.0"
    SUBSYSTEMS=="pci"
    DRIVERS=="xhci_hcd"
    ATTRS{ari_enabled}=="0"
    ATTRS{broken_parity_status}=="0"
    ATTRS{class}=="0x0c0330"
    ATTRS{consistent_dma_mask_bits}=="64"
    ATTRS{d3cold_allowed}=="1"
    ATTRS{power/wakeup_total_time_ms}=="0"
    ATTRS{power_state}=="D0"
    ATTRS{remove}=="(not readable)"
    ATTRS{rescan}=="(not readable)"
    ATTRS{revision}=="0x21"
    ATTRS{subsystem_device}=="0x80fa"
    ATTRS{subsystem_vendor}=="0x103c"
    ATTRS{vendor}=="0x8086"

  looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""
    ATTRS{waiting_for_supplier}=="0"

there are:
-looking at device '/devices/pci0000:00/0000:00:14.0/usb1/1-4/1-4.2':
-looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1/1-4'
-looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1':
-looking at parent device '/devices/pci0000:00/0000:00:14.0':
-looking at parent device '/devices/pci0000:00':


do I to find an equal attribute among these 5 devices? for example SUBSYSTEM, the first-second-third are "usb", the fouth is "pci" and the last is empty....
 
The device on '/devices/pci0000:00/0000:00:14.0/usb1/1-4/1-4.2' appears to be your UPS as identified by ATTR{manufacturer}=="American Power Conversion"

So enter the following:
Code:
nano /etc/udev/rules.d/50-apcups.rules

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

#save & exit

udevadm control --reload
udevadm trigger

You should then find the device with:
ls /dev/ups0 -al

Then you should be able to pass the device to the LXC with:
pct set <vmid> --dev0 path=/dev/ups0

Good luck & report back if it works. (I've never tried it myself in Proxmox).
 
  • Like
Reactions: leesteken
One other thing I think worth mentioning - I believe you need to "undo" the original pct set --dev.... command you invoked, otherwise you may encounter some strange situation of the "2" (but really the same) devices being passed to the LXC.

To be honest - I'm not exactly sure how to revoke the pct set --dev... command at all, I've looked in the docs here & don't find any mention of how to revoke it. I imagine though you should be able to do it within the LXC's vmid.conf file. If you post it here - maybe we can have a look at it.

Good luck.
 
The device on '/devices/pci0000:00/0000:00:14.0/usb1/1-4/1-4.2' appears to be your UPS as identified by ATTR{manufacturer}=="American Power Conversion"

So enter the following:
Code:
nano /etc/udev/rules.d/50-apcups.rules

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

#save & exit

udevadm control --reload
udevadm trigger

You should then find the device with:
ls /dev/ups0 -al

Then you should be able to pass the device to the LXC with:
pct set <vmid> --dev0 path=/dev/ups0

Good luck & report back if it works. (I've never tried it myself in Proxmox).
in the host with:
Code:
ls /dev/ups0 -al
I have:
Code:
lrwxrwxrwx 1 root root 15 Jun 23 22:39 /dev/ups0 -> bus/usb/001/012
and I think is ok
In the client:
Code:
crw-rw---- 1 root root 189, 11 Jun 23 20:41 /dev/ups0

From the nut container (the software that needs the ups usb connection) i have this error:
Code:
chgrp: /dev/bus/usb: No such file or directory

Maybe a problem with the old:
Code:
pct set <vmid> --dev0 path=/dev/bus/usb/001/012
 
From the nut container (the software that needs the ups usb connection) i have this error:
Code:
chgrp: /dev/bus/usb: No such file or directory
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:
Code:
lrwxrwxrwx 1 root root 15 Jun 23 22:39 /dev/ups0 -> bus/usb/001/012

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
 
To be honest - I'm not exactly sure how to revoke the pct set --dev...command at all, I've looked in the docs here & don't find any mention of how to revoke it.
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.
 
Last edited:
I may as well anyway document the approach that I believe/hope will work for you @enry86cami, so assuming the above symlink points correctly to the USB device file path, you will enter the following:

pct set <vmid> --dev0 path=/$(readlink /dev/usb0)

What this will do; read the full USB device path & pass that to the LXC.
With this approach - if the USB port gets "hot changed" - all you have to do is restart the LXC & it should get correctly passed again.

Good luck & report back.
 
Last edited:

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!