Passthrough usb video grabber to LXC

puncake

New Member
Feb 13, 2023
1
0
1
Hi all, I'm struggling with this at the moment, I have Hyperion running in an LXC and I'm trying to passthrough a usb video grabber. I've followed a couple of tutorials meant mainly for Zigbee sticks but to no avail. (like this: https://www.schreiners-it.de/proxmox/usb-geraet-in-lxc-container-unter-proxmox-7-1/)

After changing the container.conf no file gets created and I cannot see the video grabber in the Hyperion webUI. lsusb on the host sees the device. lsusb in the lxc console doesn't work even after the new file is meant to be created.

Appreciate a nudge to the right direction. thanks.
 
I have the same issue, I don't know if we can install hyperion as a VM on Proxmox
 
I have very same problem as well with usb video grabber passthrough to LXC. Tried same methods, but no luck. Any luck with VM (not LXC), when you can add USB devices in settings?
 
Does the new way of dev0: /dev/...,gid=...,uid=... not work for your video grabber? I don't know which device path(s) or which user/group works for your particular device. Do you load the video grabber drivers on the host, and which group and user are assign to which device path(s)?
 
  • Like
Reactions: Kamazas
Does the new way of dev0: /dev/...,gid=...,uid=... not work for your video grabber? I don't know which device path(s) or which user/group works for your particular device. Do you load the video grabber drivers on the host, and which group and user are assign to which device path(s)?
Maybe I describe my steps, because I'm not sure now. My LXC Debian 11 with Hyperion.

This is my host pve info:
root@pve:~# lsusb
Bus 002 Device 002: ID 345f:2130 MACROSILICON USB3.0 UHD
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 8087:0a2b Intel Corp. Bluetooth wireless interface
Bus 001 Device 002: ID 10c4:ea60 Silicon Labs CP210x UART Bridge
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
root@pve:~# ls -l /dev/bus/usb/002/002
crw-rw-r-- 1 root root 189, 129 Mar 17 22:46 /dev/bus/usb/002/002


/dev/bus/usb/002/002 is my video grabber and as far as I saw there shouldn't be any installed drivers for that to use it for Hyperion.

This I added to root@pve:~# nano /etc/pve/lxc/101.conf:
....
lxc.cgroup2.devices.allow: c 189:* rwm
lxc.mount.entry: /dev/bus/usb/002/002 dev/bus/usb/ none bind,optional,create=file

How I should I try that new way in my case?
 
/dev/bus/usb/002/002 is my video grabber and as far as I saw there shouldn't be any installed drivers for that to use it for Hyperion.
That path is not usable and not stable. USB (un)plug does not work inside containers as it does on the host or inside VMs.
Find out which device file or folder is created upon insertion of the USB device, like /dev/dvb/adapter/dvr0 in case of a TV tuner.
All necessary drivers (they might be built-in) need to be loaded on the Proxmox host (since the container shares the kernel) and the driver usually creates a file or folder under /dev/.
This I added to root@pve:~# nano /etc/pve/lxc/101.conf:
....
lxc.cgroup2.devices.allow: c 189:* rwm
lxc.mount.entry: /dev/bus/usb/002/002 dev/bus/usb/ none bind,optional,create=file

How I should I try that new way in my case?
it would be something like dev0: /dev/videograbber,gid=44,uid=0 but it depends on the device path and the group (on the host and inside the container) and user, which you need to figure out first.
 
  • Like
Reactions: Kamazas
That path is not usable and not stable. USB (un)plug does not work inside containers as it does on the host or inside VMs.
Find out which device file or folder is created upon insertion of the USB device, like /dev/dvb/adapter/dvr0 in case of a TV tuner.
All necessary drivers (they might be built-in) need to be loaded on the Proxmox host (since the container shares the kernel) and the driver usually creates a file or folder under /dev/.

it would be something like dev0: /dev/videograbber,gid=44,uid=0 but it depends on the device path and the group (on the host and inside the container) and user, which you need to figure out first.
I'm sorry if my questions are stupid, just not experienced in this field.
Is that ok, if I use root user and group, so my:
root@pve:~# id -u
0
root@pve:~# id -g
0

Next thing:
1710759449868.png
how can I know which folder is created by:
Bus 002 Device 002: ID 345f:2130 MACROSILICON USB3.0 UHD
It's this of the device itself: Link
 
Is that ok, if I use root user and group, so my:
root@pve:~# id -u
0
root@pve:~# id -g
0
We need to know which user/group is expected by the container, which can also be found by looking at the user/group on the Proxmox host of the device path (which we don't know yet).
Next thing:
View attachment 64831
how can I know which folder is created by:
Bus 002 Device 002: ID 345f:2130 MACROSILICON USB3.0 UHD
It's this of the device itself: Link
Make sure the device is working (the driver loads, firmware is found) and see the difference somewhere below /dev with the device unplugged and plugged in.
I don't know your device, so I don't know which (built-in or not) driver it uses or which device folders/files it creates or if it needs some non-open firmware.. Is the device supported on Linux? Is there a guide to get it working on Linux? Maybe the manufacturer support knows there details? Did you manage to get it working in a VM with USB passthrough (or bare-metal Linux)?
 
  • Like
Reactions: Kamazas
We need to know which user/group is expected by the container, which can also be found by looking at the user/group on the Proxmox host of the device path (which we don't know yet).

Make sure the device is working (the driver loads, firmware is found) and see the difference somewhere below /dev with the device unplugged and plugged in.
I don't know your device, so I don't know which (built-in or not) driver it uses or which device folders/files it creates or if it needs some non-open firmware.. Is the device supported on Linux? Is there a guide to get it working on Linux? Maybe the manufacturer support knows there details? Did you manage to get it working in a VM with USB passthrough (or bare-metal Linux)?
Well first of all then I try to see if it's working on VM with USB passthrough. Thx for help.
 
Well first of all then I try to see if it's working on VM with USB passthrough. Thx for help.
Performance of the video grabber might disappoint but at least you'll have a base line to observe and experiment with. Maybe use Debian 12 in the VM to make it very similar to Proxmox (or just install Proxmox in the VM). Or maybe install a Linux distribution that you know is supported by the device manufacturer to make sure it will work. I don't know which is the best approach, sorry.
 
  • Like
Reactions: Kamazas
Performance of the video grabber might disappoint but at least you'll have a base line to observe and experiment with. Maybe use Debian 12 in the VM to make it very similar to Proxmox (or just install Proxmox in the VM). Or maybe install a Linux distribution that you know is supported by the device manufacturer to make sure it will work. I don't know which is the best approach, sorry.

Just quickly checked what I have when connected and disconnected USB video grabber. Strange that when connected, then 5 more entries.
1710764968198.png

when connected: video0, video1, highdraw1, media0, v41
 
Strange that when connected, then 5 more entries.
That normal and to be expected. That's how Linux drivers work.

when connected: video0, video1, highdraw1, media0, v41
Then those are the files/folders that you want to pass to the container. Look at the output of ls -l /dev/video0 /dev/video1 /dev/highdraw1 /dev/media0 /dev/v4l. You'll have to pass all those files separately with the same user and group (equivalent of those inside the container).
 
  • Like
Reactions: Kamazas
That normal and to be expected. That's how Linux drivers work.


Then those are the files/folders that you want to pass to the container. Look at the output of ls -l /dev/video0 /dev/video1 /dev/highdraw1 /dev/media0 /dev/v4l. You'll have to pass all those files separately with the same user and group (equivalent of those inside the container).
First I tried Debian 12 VM with USB passthrough and actually it works quite well, just to save my NUC resources would be better to have hyperion on the LXC instead of VM.

I tried now on pve:
root@pve:/dev# ls -l /dev/video0 /dev/video1 /dev/highdraw1 /dev/media0 /dev/v4l
ls: cannot access '/dev/highdraw1': No such file or directory
crw-rw---- 1 root video 234, 0 Mar 18 17:10 /dev/media0
crw-rw---- 1 root video 81, 0 Mar 18 17:10 /dev/video0
crw-rw---- 1 root video 81, 1 Mar 18 17:10 /dev/video1

/dev/v4l:
total 0
drwxr-xr-x 2 root root 80 Mar 18 17:10 by-id
drwxr-xr-x 2 root root 80 Mar 18 17:10 by-path
root@pve:/dev#
on host and hyperion container I have the same and only root user, which means:
root@pve:~# id -u
0
root@pve:~# id -g
0

Is that ok?
 
on host and hyperion container I have the same and only root user, which means:
root@pve:~# id -u
0
root@pve:~# id -g
0

Is that ok?
Please stop about the root IDs, they are always 0 and not relevant here.
First I tried Debian 12 VM with USB passthrough and actually it works quite well, just to save my NUC resources would be better to have hyperion on the LXC instead of VM.
Nice to know that it works.
I tried now on pve:
root@pve:/dev# ls -l /dev/video0 /dev/video1 /dev/highdraw1 /dev/media0 /dev/v4l
ls: cannot access '/dev/highdraw1': No such file or directory
crw-rw---- 1 root video 234, 0 Mar 18 17:10 /dev/media0
crw-rw---- 1 root video 81, 0 Mar 18 17:10 /dev/video0
crw-rw---- 1 root video 81, 1 Mar 18 17:10 /dev/video1

/dev/v4l:
total 0
drwxr-xr-x 2 root root 80 Mar 18 17:10 by-id
drwxr-xr-x 2 root root 80 Mar 18 17:10 by-path
root@pve:/dev#
Find out what the ID is of the video group is inside the container. Then add this to the container configuration file (replace THE_VIDEO_GROUP_IN_THE_CONTAINER with the ID of the video group inside the container):
Code:
dev0: /dev/media0,gid=THE_VIDEO_GROUP_IN_THE_CONTAINER,uid=0
dev1: /dev/video0,gid=THE_VIDEO_GROUP_IN_THE_CONTAINER,uid=0
dev2: /dev/video1,gid=THE_VIDEO_GROUP_IN_THE_CONTAINER,uid=0
You might have to add all the files under /dev/v4l/ as well. Or maybe lxc.mount.entry: /dev/v4l dev/v4l none bind,create=folder is enough. I'm not sure, I have only passed through /dev/dvb/... to containers.
 
  • Like
Reactions: Kamazas
Find out what the ID is of the video group is inside the container. Then add this to the container configuration file (replace THE_VIDEO_GROUP_IN_THE_CONTAINER with the ID of the video group inside the container):
Code:
dev0: /dev/media0,gid=THE_VIDEO_GROUP_IN_THE_CONTAINER,uid=0
dev1: /dev/video0,gid=THE_VIDEO_GROUP_IN_THE_CONTAINER,uid=0
dev2: /dev/video1,gid=THE_VIDEO_GROUP_IN_THE_CONTAINER,uid=0
You might have to add all the files under /dev/v4l/ as well. Or maybe lxc.mount.entry: /dev/v4l dev/v4l none bind,create=folder is enough. I'm not sure, I have only passed through /dev/dvb/... to containers.
Sorry I really don't get this part. "Find out what the ID is of the video group is inside the container."
Inside my PXC container my /dev:
1710778191676.png

sorry but I don't get that part, how to see "ID is of the video group is inside the container"
 
Sorry I really don't get this part. "Find out what the ID is of the video group is inside the container."
As you can see the user is root and the group, of the files you want to pass, is video on the Proxmox host:
crw-rw---- 1 root video 234, 0 Mar 18 17:10 /dev/media0
crw-rw---- 1 root video 81, 0 Mar 18 17:10 /dev/video0
crw-rw---- 1 root video 81, 1 Mar 18 17:10 /dev/video1
We want to give the files inside the container the same user and group (but inside the container, which can have different IDs).
What is the output of grep video /etc/group from inside the VM?
 
  • Like
Reactions: Kamazas
As you can see the user is root and the group, of the files you want to pass, is video on the Proxmox host:

We want to give the files inside the container the same user and group (but inside the container, which can have different IDs).
What is the output of grep video /etc/group from inside the VM?
Ok, big thx for help leesteken!

It worked!

Just sum up my steps if anyone else will struggle:
1. My LXC hyperion from: Link
2. Proxmox on my NUC and connected video grabber: Link
3. Check /dev what appears new when grabber is connected:
1710764968198.png

when connected: video0, video1, highdraw1, media0, v41

4. Find out what the ID is of the video group:
cd /dev
root@pve:/dev# ls -l /dev/video0 /dev/video1 /dev/highdraw1 /dev/media0 /dev/v4l
ls: cannot access '/dev/highdraw1': No such file or directory
crw-rw---- 1 root video 234, 0 Mar 18 17:10 /dev/media0
crw-rw---- 1 root video 81, 0 Mar 18 17:10 /dev/video0
crw-rw---- 1 root video 81, 1 Mar 18 17:10 /dev/video1

/dev/v4l:
total 0
drwxr-xr-x 2 root root 80 Mar 18 17:10 by-id
drwxr-xr-x 2 root root 80 Mar 18 17:10 by-path
5. Then in host:
nano /etc/pve/lxc/101.conf

Added just these lines:

dev0: /dev/media0,gid=234,uid=0
dev1: /dev/video0,gid=81,uid=0
dev2: /dev/video1,gid=81,uid=0
 
That's strange then why it works :D
Maybe the software inside the container runs as "root" (or the root user inside the container) and therefore does not need to be in the video group?

Anyway, for future readers, it should be:
Code:
dev0: /dev/media0,gid=44,uid=0
dev1: /dev/video0,gid=44,uid=0
dev2: /dev/video1,gid=44,uid=0
 
  • Like
Reactions: Kamazas

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!