USB Passthrough to LXC Plex

hval007

Member
Aug 22, 2021
7
0
6
35
So I started recently with VE 7.0, created LXC and installed ubuntu + Plex. Idea is to use a USB drive connected to the machine to read media files through to Plex

For USB passthrough I followed this guide here

Then followed this guide to change cgroup

What I cannot figure out, is when I go into Plex --> Add Library I just cant figure out where my usb files would be stored? I must be missing a crucial step here

I did a bit more research and followed this guide to mount my usb on the host which worked perfectly and I can read the media file on the Proxmox host via ssh :

Code:
root@pve:/media/usb-drive# mount | grep sdd1
/dev/sdd1 on /media/usb-drive type fuseblk (rw,relatime,user_id=0,group_id=0,allow_other,blksize=4096) 
root@pve:/media/usb-drive# cd /media/usb-drive 
root@pve:/media/usb-drive# dir Android Cruella.2021.1080p.DSNP.WEBRip.DDP5.1.Atmos.x264-TOMMY\ (1) Scam\ 1992\ -\ The\ Harshad\ Mehta\ Story\ (2020)\ S01\ Hindi\ (1080p\ WEBRip\ x265\ 10bit)\ -\ [Musafirboy]


This is what I receive on the Plex LXC via console: It cant see the usb mount or read contents of the usb-drive?
Code:
Ubuntu 20.04.2 LTS Plex tty1
Plex login: root Password: Welcome to Ubuntu 20.04.2 LTS (GNU/Linux 5.11.22-1-pve x86_64)
Documentation:  https://help.ubuntu.com
Management:     https://landscape.canonical.com
Support:        https://ubuntu.com/advantage Last login: Fri Aug 20 23:32:01 UTC 2021 on tty1
root@Plex:~# fdisk -l root@Plex:~# mkdir /media/usb-drive mkdir: cannot create directory '/media/usb-drive': File exists
root@Plex:~# mount /dev/sdd1 /media/usb-drive/ mount: /media/usb-drive: special device /dev/sdd1 does not exist.
root@Plex:~# cd /media/usb-drive
root@Plex:/media/usb-drive# dir root@Plex:/media/usb-drive#


Also rechecked my passthrough of USB to LXC correctly:
Code:
lxc.cgroup2.devices.allow: c 189:* rwm
lxc.mount.entry: /dev/bus/usb/004 dev/bus/usb/004 none bind,optional,create=dir
 
There's a difference between accessing a USB device or accessing its storage. The way you're passing the device through is the former, but it sounds like you want the latter. You should mount it on the host (via the file system's uuid to not also depend on the specific USB slot it's plugged in) and then pass the mounted directory through as a bind mount. However, this will not support hotplugging while the container is running.
 
There's a difference between accessing a USB device or accessing its storage. The way you're passing the device through is the former, but it sounds like you want the latter. You should mount it on the host (via the file system's uuid to not also depend on the specific USB slot it's plugged in) and then pass the mounted directory through as a bind mount. However, this will not support hotplugging while the container is running.
Thanks do you happen to have any guides or steps that can be followed? I'm new to Promox and Linux and appreciate any guidance here
 
If you're new to these things I recommend using a VM for the time being, as with those you could use actual USB pass through via the GUI.

Otherwise, it's roughly these steps:
1) setup /etc/fstab entry for the device with the `x-systemd.automount` option
Eg. add something like:
UUID="2587-CC93" /mnt/the-usb-stick exfat-fuse defaults,x-systemd.automount 0 0
You can figure out the UUID via # blkid /dev/sdd1 (assuming `sdd1` is currently the USB stick)

2) add an `mpX` entry to /etc/pve/lxc/$VMID.conf
Eg.
mp0: /mnt/the-usb-stick,mp=/path/inside/container
 
If you're new to these things I recommend using a VM for the time being, as with those you could use actual USB pass through via the GUI.

Otherwise, it's roughly these steps:
1) setup /etc/fstab entry for the device with the `x-systemd.automount` option
Eg. add something like:
UUID="2587-CC93" /mnt/the-usb-stick exfat-fuse defaults,x-systemd.automount 0 0
You can figure out the UUID via # blkid /dev/sdd1 (assuming `sdd1` is currently the USB stick)

2) add an `mpX` entry to /etc/pve/lxc/$VMID.conf
Eg.
mp0: /mnt/the-usb-stick,mp=/path/inside/container
I will give this a try:

running blkid: (this is my usb)
/dev/sdc2: LABEL="New Volume" BLOCK_SIZE="512" UUID="4C8ACD3D8ACD2474" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="b916cd1f-2b9d-4871-80f4-ea6d925f4

1. <file system> <mount point> <type> <options> <dump> <pass> /dev/pve/root / xfs defaults 0 1 /dev/pve/swap none swap sw 0 0 proc /proc proc defaults 0 0 UUID=3620834D208312D3 /media/data ntfs defaults,x-systemd.automount 0 0


2) I am confused with this bit : mp=/path/inside/container
 
this is where, from the container's point of view, the data should show up
So I created the path as follows, restarted the container and navigating to within Plex to that path I see nothing.

mp0: /media/data,mp=/dev/bus/usb/plex
 

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!