[SOLVED] How to pass APC USB to LXC container?

Aug 30, 2023
51
6
8
Luxembourg
Hi,

Can anyone help me redirect the USB connection of my APC UPS to a new LXC container using the Debian 12 template? I've tried variations of lxc.mount.entry but none seem to work, when I check in the container I get:

Code:
root@EDDIE:~# lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 051d:0003 American Power Conversion UPS
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub


root@EDDIE:~# apt list apcu*
Listing... Done
apcupsd-cgi/stable,now 3.14.14-3.1+b1 amd64 [installed]
apcupsd-doc/stable,now 3.14.14-3.1 all [installed]
apcupsd/stable,now 3.14.14-3.1+b1 amd64 [installed]


root@EDDIE:~# systemctl status apcupsd
* apcupsd.service - UPS power management daemon
     Loaded: loaded (/lib/systemd/system/apcupsd.service; disabled; preset: enabled)
     Active: inactive (dead)
       Docs: man:apcupsd(8)


root@EDDIE:~# apctest


2023-12-14 10:03:03 apctest 3.14.14 (31 May 2016) debian
Checking configuration ...
sharenet.type = Network & ShareUPS Disabled
cable.type = USB Cable
mode.type = USB UPS Driver
Setting up the port ...
apctest FATAL ERROR in apctest.c at line 319
Unable to open UPS device.
  If apcupsd or apctest is already running,
  please stop it and run this program again.
apctest error termination completed


UPSTYPE usb
DEVICE /dev/usb/hiddev0


# POLLTIME <int>
#   Interval (in seconds) at which apcupsd polls the UPS for status. This
#   setting applies both to directly-attached UPSes (UPSTYPE apcsmart, usb,
#   dumb) and networked UPSes (UPSTYPE net, snmp). Lowering this setting


root@EDDIE:~# ls /dev
console  core  fd  full  initctl  log  mqueue  null  ptmx  pts  random  shm  stderr  stdin  stdout  tty  tty1  tty2  urandom  usb  zero
root@EDDIE:~# ls /dev/usb
hiddev0
root@EDDIE:~# ls /dev/usb/hiddev0
/dev/usb/hiddev0
root@EDDIE:~#

Checks on the host show:

Code:
root@ned:~# pveversion
pve-manager/8.1.3/b46aac3b42da5d15 (running kernel: 6.5.11-7-pve)


root@ned:~# dmesg | grep 'UPS'
[292295.458409] usb 1-5: Product: Smart-UPS 750 FW:COM 02.1 / UPS.05.I
[292295.461339] hid-generic 0003:051D:0003.0002: hiddev0,hidraw0: USB HID v1.00 Device [American Power Conversion Smart-UPS 750 FW:COM 02.1 / UPS.05.I] on usb-0000:00:14.0-5/input0


root@ned:~# lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 051d:0003 American Power Conversion UPS
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

The current config for the container is:

Code:
root@ned:~# cat /etc/pve/nodes/ned/lxc/101.conf
arch: amd64
cores: 1
features: nesting=1
hostname: EDDIE
memory: 512
net0: name=eth0,bridge=vmbr0,firewall=1,hwaddr=BC:24:11:1F:83:CB,ip=dhcp,type=veth
ostype: debian
rootfs: local-zfs:subvol-101-disk-0,size=8G
startup: order=1
swap: 512
unprivileged: 1
lxc.cgroup2.devices.allow: c 189:* rwm
lxc.mount.entry: /dev/usb/hiddev0 dev/usb/hiddev0 none bind,optional,create=file

FYI, I want to use a container as I don't want mess about installing apache2 to get the cgi working, and keep PvE itself clean.

I've also checked other threads on the forum that try to do something similar, but none of them have helped - and are old so I did not want to reply on them.
 
PVE version 8.1 introduced container device passthrough. Use that instead of manually bind mounting the device into the container.
Code:
pct set <container id> -dev0 /dev/usb/hiddev0
 
  • Like
Reactions: Taomyn
FYI I got it working, although I need to work out how to get the "not found info" if possible for my UPS, but I will try to write it all up here because as always there's never one place to find all the info

1702567100596.png
 

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!