[SOLVED] RTL2838 DVB-T USB dongle as ADS-B receiver in lxc container

bgs

Member
Jan 19, 2022
19
1
8
Austria
Hi!

I'm trying to run an RTL2838 USB dongle within an lxc container. Sadly I'm always getting an error message within the container, which I think is a permission issue:
Code:
root@fr24:~# rtl_test
Found 1 device(s):
  0:  , , SN:

Using device 0: Generic RTL2832U OEM
usb_open error -4
Failed to open rtlsdr device #0.

On the host, this works as expected - therefore it's not a hardware-related issue:
Code:
root@pve:~# rtl_test
Found 1 device(s):
  0:  Realtek, RTL2838UHIDIR, SN: 00000001

Using device 0: Generic RTL2832U OEM
Found Rafael Micro R820T tuner
Supported gain values (29): 0.0 0.9 1.4 2.7 3.7 7.7 8.7 12.5 14.4 15.7 16.6 19.7 20.7 22.9 25.4 28.0 29.7 32.8 33.8 36.4 37.2 38.6 40.2 42.1 43.4 43.9 44.5 48.0 49.6
[R82XX] PLL not locked!
Sampling at 2048000 S/s.

Info: This tool will continuously read from the device, and report if
samples get lost. If you observe no further output, everything is fine.

Reading samples in async mode...
Allocating 15 zero-copy buffers
lost at least 96 bytes
^CSignal caught, exiting!

User cancel, exiting...
Samples per million lost (minimum): 4


I do not find any errors in my configuration o_O this is, what it looks like:
Code:
root@pve:~# pct config 110
arch: amd64
cores: 1
features: nesting=1
hostname: fr24
memory: 512
net0: name=eth0,bridge=vmbr0,firewall=1,gw=censored,hwaddr=censored,ip=censored/24,ip6=auto,type=veth
ostype: debian
parent: ssh
rootfs: local-lvm:vm-110-disk-0,size=8G
swap: 512
unprivileged: 1
lxc.cgroup.devices.allow: c 212:* rwm
lxc.mount.entry: /dev/dvb dev/dvb none bind,optional,create=dir
lxc.mount.entry: /dev/bus/usb/001 dev/bus/usb/001 none bind,optional,create=dir
Code:
root@pve:~# tail /etc/modprobe.d/blacklist-dvb_usb_rtl28xxu.conf
blacklist dvb_usb_rtl28xxu


Maybe the blacklist on the pve host isn't even the correct method, because the dongle disappeared as device (rtl_test still works anyways) :confused:
Code:
root@pve:~# ls -l /dev/* |grep dvb
root@pve:~#

Thanks in advance for any ideas,
bgs
 
Hi, thank you for your reply.
Yes, I am on PVE 7. How should the config entry look like for cgroup2? I don't get it from the docs.
Best regards,
bgs
 
Hi, thank you for your reply.
Yes, I am on PVE 7. How should the config entry look like for cgroup2? I don't get it from the docs.
Best regards,
bgs
you just change the part i quoted in the previous post, add a "2" after "cgroup" :)
 
Oh, that easy :) but still no difference. What confuses me, is that I cannot find the usb dongle anymore in the devices on the host:

Code:
root@pve:~# ls -l /dev/* |grep 212
root@pve:~#
 
Maybe the blacklist on the pve host isn't even the correct method, because the dongle disappeared as device (rtl_test still works anyways)

. What confuses me, is that I cannot find the usb dongle anymore in the devices on the host:

no need to blacklist it. that's why you don't see it anymore on the host :)

EDIT: for passing things to containers, blacklisting won't help since containers use the host kernel. it is relevant for VMs, with PCI passthrough (since kernel is virtualized in that case) the device shouldn't be used at the same time by the host kernel
 
Last edited:
I removed the blacklisting and restarted the host.

The "c" changed to "l"
Code:
root@pve:~# ls -l /dev/* |grep dvb
lrwxrwxrwx 1 root root 22 Jan 20 10:01 212:0 -> ../dvb/adapter0/demux0
lrwxrwxrwx 1 root root 20 Jan 20 10:01 212:1 -> ../dvb/adapter0/dvr0
lrwxrwxrwx 1 root root 20 Jan 20 10:01 212:2 -> ../dvb/adapter0/net0
lrwxrwxrwx 1 root root 25 Jan 20 10:01 212:3 -> ../dvb/adapter0/frontend0

Therefore the config looks like this now:
Code:
root@pve:~# pct config 110
arch: amd64
cores: 1
features: nesting=1
hostname: fr24
memory: 512
net0: name=eth0,bridge=vmbr0,firewall=1,gw=censored,hwaddr=censored,ip=censored/24,ip6=auto,type=veth
ostype: debian
parent: ssh
rootfs: local-lvm:vm-110-disk-0,size=8G
swap: 512
unprivileged: 1
lxc.mount.entry: /dev/dvb dev/dvb none bind,optional,create=dir
lxc.mount.entry: /dev/bus/usb/001 dev/bus/usb/001 none bind,optional,create=dir
lxc.cgroup2.devices.allow: l 212:* rwm

Sadly still no affect to the container.
 
lxc.cgroup2.devices.allow: l 212:* rwm
why did you change that part to "l"? that just means its a link, but you need to keep it as "c" (signifies it's a char device) since you want to pass the char device and not the link...

please reboot the container afterwards too ;)
 
you probably want to pass the /dev/dvb/adapter0 directory instead.

try like:
Code:
lxc.mount.entry: /dev/dvb/adapter0 dev/dvb/adapter0 none bind,optional,create=dir
lxc.mount.entry: /dev/bus/usb/001 dev/bus/usb/001 none bind,optional,create=dir
lxc.cgroup2.devices.allow: c 212:* rwm
 
Tried but still no difference :(
The /dev/dvb/adapter0 directory was correctly available in the container before.
 
does it work if you remove the optional parts?

The /dev/dvb/adapter0 directory was correctly available in the container before.
then maybe try also with the previous directory /dev/dvb (without the "optional")

make sure you reboot the container after the changes
 
Code:
lxc.mount.entry: /dev/dvb dev/dvb none bind,create=dir
and reboot with directory correctly passed:
Code:
root@fr24:/dev/dvb# ls -l
total 0
drwxr-xr-x 2 nobody nogroup 120 Jan 20 09:01 adapter0

but still not working
 
and reboot with directory correctly passed:
okay

but still not working
probably you need to adjust the owner or the permissions of the device on the host.

when you use unprivileged containers (default in GUI) the container will take a different user id, e.g. 100000 if the /etc/subuid and /etc/subgid files are default/empty.

what you can do is something like:
Code:
chown -R 100000:100000 /dev/dvb

that'll set the owner of the device file to the same user id as the container process, and afterwards it should hopefully work
 
The owner is now root in the container
Code:
root@fr24:/dev/dvb# ls -l
total 0
drwxr-xr-x 2 root root 120 Jan 20 09:01 adapter0

but with no difference o_O
 
I use a USB 2.0 DVB-C tuner in a unprivileged container and /dev/dvb/adapter0 shows nobody:nogroup, which is fine because the files inside it:
ls -al /dev/dvb/adapter0/ total 0 drwxr-xr-x 2 nobody nogroup 120 Jan 20 08:12 . drwxr-xr-x 4 nobody nogroup 80 Jan 20 08:12 .. crw-rw---- 1 nobody video 212, 1 Jan 20 08:12 demux0 crw-rw---- 1 nobody video 212, 2 Jan 20 08:12 dvr0 crw-rw---- 1 nobody video 212, 0 Jan 20 08:12 frontend0 crw-rw---- 1 nobody video 212, 3 Jan 20 08:12 net0
show that they are part of the video group, which I have mapped from the host to the container using:
lxc.idmap: u 0 100000 65535 lxc.idmap: g 0 100000 44 lxc.idmap: g 44 44 1 lxc.idmap: g 45 100045 65490 lxc.cgroup2.devices.allow: c 212:* rwm lxc.mount.entry: /dev/dvb dev/dvb none bind,create=dir 0 0
On your host and or container, the video group might have a different number than 44.
Maybe my working example can help you get yours to work.
 
Hi and thank you for this idea. Tried it but still no access in the container:
Code:
root@fr24:~# ls -al /dev/dvb/adapter0/
total 0
drwxr-xr-x 2 root root     120 Jan 20 09:01 .
drwxr-xr-x 3 root root      60 Jan 20 09:01 ..
crw-rw---- 1 root video 212, 0 Jan 20 09:01 demux0
crw-rw---- 1 root video 212, 1 Jan 20 09:01 dvr0
crw-rw---- 1 root video 212, 3 Jan 20 09:01 frontend0
crw-rw---- 1 root video 212, 2 Jan 20 09:01 net0
root@fr24:~# rtl_test
Found 1 device(s):
  0:  , , SN:

Using device 0: Generic RTL2832U OEM
usb_open error -4
Failed to open rtlsdr device #0.
root@fr24:~#
 
root inside the unprivileged container is not a user that can do everything, like on the host. Is the root user inside the container a member of the video group?
 
Yes, it's been in the video group already
Code:
root@fr24:~# groups
root video

While testing I found out, that rtl_test executed on the host, sets the group to plugdev (46) :oops:
Code:
root@pve:~# ls -al /dev/dvb/adapter0/
total 0
drwxr-xr-x 2 root root       120 Jan 21 19:32 .
drwxr-xr-x 3 root root        60 Jan 21 19:32 ..
crw-rw---- 1 root plugdev 212, 0 Jan 21 19:32 demux0
crw-rw---- 1 root plugdev 212, 1 Jan 21 19:32 dvr0
crw-rw---- 1 root plugdev 212, 3 Jan 21 19:32 frontend0
crw-rw---- 1 root plugdev 212, 2 Jan 21 19:32 net0
 
Hey I've solved it by making the mountpoint writable by all on the proxmox host. In your case:

Code:
chmod 0666 /dev/bus/usb/001

Probably better to make a group for it on the host and map the right uid and gid like avw did though.
 

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!