Skip to content

Instantly share code, notes, and snippets.

@Steveveepee
Last active August 28, 2023 04:49
Show Gist options
  • Save Steveveepee/d5a3384b192514783f6d7353393235d4 to your computer and use it in GitHub Desktop.
Save Steveveepee/d5a3384b192514783f6d7353393235d4 to your computer and use it in GitHub Desktop.
Proxmox media setup notes

Set up media disks

optional set up a JBOD array and join them with mergerfs https://www.youtube.com/watch?v=n7piuhTXeG4&t=4s

set up drive on host with media files in folders as suggested by https://trash-guides.info/ mounted as directory on proxmox root eg: /mnt/storage/mediastorage

Add a group on the host that will have access to the media files

root@proxmox:~# addgroup --gid 1005 media
Adding group `media' (GID 1005) ...
Done.

Add a media user on the host (might not be needed)

root@proxmox:~# adduser --uid 1005 --ingroup media --no-create-home --disabled-login media
Adding user `media' ...
Adding new user `media' (1005) with group `media (1005)' ...
Not creating home directory `/home/media'.
Changing the user information for media
Enter the new value, or press ENTER for the default
        Full Name []:
        Room Number []:
        Work Phone []:
        Home Phone []:
        Other []:
Is the information correct? [Y/n]
Adding new user `media' to supplemental / extra groups `users' ...
Adding user `media' to group `users' ...

Change group ownership of the media store on the host to media group

chown -R root:media <media folder>

Plex server setup

make a ubuntu 22.04 container, sugegsted name: plexserver

(DHCP or static ip will work here, can be changed later)

(default settings are fine to start, you can adjust as required later - note, bootdisk size can be increased, but not shrunk so start with 8G and see)

install plex using official .deb from https://www.plex.tv/media-server-downloads/#plex-media-server

cd /tmp
wget <link copied from plex website>
dpkg -i  <file you just downloaded>

this will make a plex user and group.

root@PlexServer:~# grep plex /etc/passwd
plex:x:999:999::/var/lib/plexmediaserver:/usr/sbin/nologin

make a media group to map to the media group on the host

root@plexserver:~# addgroup --gid 1005 media
Adding group `media' (GID 1005) ...
Done.

change plex user main group to the media group

 usermod -g 1005 plex

add plex back to the plex group as well,

usermod -a -G plex plex

check

root@PlexServer:~# id plex
uid=999(plex) gid=1005(media) groups=1005(media),0(root),44(video),108(render),999(plex)

set up hardware transcoding for intel https://forum.proxmox.com/threads/intel-coffeelake-plex-hardware-transcoding-in-debian-unprivileged-lxc-container.132520/

when up to the editing /etc/pve/lxc/<container number>.conf on the host,

add a bindmount to the media storage on the root system

mp0: /mnt/storage/mediastorage/media,mp=/data,replicate=0

add the user/group mappings required by the hardware encoding adjust the mappings to include the group mapping of the media group on host/container

this example has hardware encoding mappings for user/group 104/108 and the group mapping of 1005/1005 for the media group. No media user mapping required. simple mappings can be generated for you at:

https://proxmox-idmap-helper.nieradko.com/

lxc.idmap: u 0 100000 65536
lxc.idmap: g 0 100000 104
lxc.idmap: g 104 108 1
lxc.idmap: g 105 100105 900
lxc.idmap: g 1005 1005 1
lxc.idmap: g 1006 101006 64530

on the host: edit /etc/subuid to add any user mappings required by the hardware transcode stuff

edit /etc/subgid to add the group mappings we added to the container.conf

# Generic lxc mapping
root:100000:65536
# group mapping for media group (1005 in both root and container)
root:1005:1
# group mapping for passthrough of intel graphics to plex container
root:108:1

restart the plexserver container and check the mounted media folders

root@PlexServer:~# ls -la /data
total 36
drwxrwsr-x  5 nobody media  4096 Aug 21 06:33 .
drwxr-xr-x 19 root   root   4096 Aug 23 23:52 ..
drwxrwsr-x 87 nobody media 12288 Aug 22 01:59 kids-movies
drwxrwsr-x 74 nobody media 12288 Aug 24 00:44 movies
drwxrwsr-x 32 nobody media  4096 Aug 21 07:31 tv

runuser <username> -s /bin/bashto test permissions

complete plex setup via web interface

plex done

*arr server setup

Make a container (I used ubuntu) install Docker and docker compose (note: new versions of docker incluse docker compose and its docker space compose not docker-compose.

make media group in container as per plex container above.

download example docker-compose.yml file: https://gist.github.com/Steveveepee/d4e49758dde24393fd0f9de4e159c191

edit docker-compose.yml to add your keys etc for the gluetun VPN container

docker compose up -d to start stack

check permissions of /root/config and chown -R root:media /root/config if media group does not have access

shutdown container and edit setup *arr apps as per https://trash-guides.info/Hardlinks/How-to-setup-for/Docker/ and https://trash-guides.info/Hardlinks/Examples/ for per app settings.

edit /etc/pve/lxc/<container number>.conf on the host

add the mount for the media

mp0: /mnt/storage/mediastorage,mp=/data

add the group mappings

lxc.idmap: u 0 100000 65536
lxc.idmap: g 0 100000 1005
lxc.idmap: g 1005 1005 1
lxc.idmap: g 1006 101006 64530

add the bindings for the vpn tunnel if not automatically added

lxc.cgroup2.devices.allow: c 10:200 rwm
lxc.mount.entry: /dev/net dev/net none bind,create=dir
lxc.mount.entry: /dev/net/tun dev/net/tun none bind,create=file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment