Home Install Plex Server on Proxmox (LXC)
Post
Cancel
Preview Image

Install Plex Server on Proxmox (LXC)

Having had several challenges getting Plex to work in a Docker container, or rather external access to the Plex Server in a Docker container, decided to try installing it in a lightweight Linux Container (LXC) instead.

Used a mix of these guides: geekbitzone and kreaweb.

Download LXC Template

  • In local (hostname) drive, select CT Templates, and click Templates button
    • Select Ubuntu-22.04-standard template, and Download
    • At the TASK OK message, close the popup [X] at upper right

Create LXC Container

  • In Proxmox, click the Create CT button, upper right
    • General tab:
      • Set Hostname = plexserver
      • Set Unprivileged container = ticked
      • Enter and confirm password for container [STRONGBOX]
      • Click Next
    • Template tab:
      • Select Template = template downloaded earlier
      • Click Next
    • Disks tab:
      • Set Disk size = 32GB
      • Click Next
    • CPU tab:
      • Set Cores = 2
      • Click Next
    • Memory tab:
      • Set Memory = 2048 (4GB)
      • Set Swap = 512
      • Click Next
    • Network tab:
      • Set IPv4 = DHCP
      • Set MAC = 02:FF:60:14:FA:0A
        • This maps to 192.168.0.137 in router DHCP Reservations
      • Click Next
    • DNS tab:
      • Leave defaults
      • Click Next
    • Confirm tab:
      • Check settings OK
      • Set Start after created = ticked
      • Click Finish
    • Close the Task viewer once the container has been created

No Root On SSH

By default login as root over SSH is disabled. In the Container’s Console, login and then edit this file to enable it:

1
sudo nano /etc/ssh/sshd_config
  • Change the line “# PermitRootLogin password-prohibit” -> “PermitRootLogin yes

Restart SSH:

1
systemctl restart ssh

Install Plex Media Server

  • In the CT go to Console, or SSH into the server remotely
  • Login with Username = root, and container password as set above
  • Update the system:
1
2
apt update
apt upgrade -y
  • Install curl for fetching URLs and gnupg for secure authentication
1
apt install curl gnupg -y
  • Install the server:
1
2
3
4
5
echo deb https://downloads.plex.tv/repo/deb public main | sudo tee /etc/apt/sources.list.d/plexmediaserver.list
curl https://downloads.plex.tv/plex-keys/PlexSign.key | sudo apt-key add -
apt update
apt install plexmediaserver -y
apt upgrade -y
  • Verify that Plex is active (running), type command
1
systemctl status plexmediaserver
  • This should show the server is running, ignore the libusb_init failed. Press “q” to quit
  • Get the IP address of the server with command ip a, and check the 192.168.0.XXX value
  • Should then be able to open Plex Web GUI in a browser by going to:

    http://192.168.0.xxx:32400/web

Mount SMB/CIFS Share from TrueNAS

Mounting network/CIFS shares within an unprivileged (or privileged) Linux Container (LXC) can be quite tricky and an annoying experience within Proxmox due to the current way containers work. There is a way around it by mounting it on the Proxmox Host and creating a mount-point within the Linux Container (refer to this guide (has typos in some of the commands)).

  • Configure the Proxmox Host
    • Ensure the CIFS share is visible by going to Proxmox shell, and type:

      pvesm scan cifs 192.168.0.10

      • This should list the various datasets on TITAN TrueNAS
    • Add the share to the Proxmox VE as storage:

      pvesm add cifs plexmedia –server 192.168.0.10 –share Media [–username <plex> –password [STRONGBOX]

      • NOTE: excluded username/password using Guest access [TODO: LOCKDOWN]
      • This should mount //192.168.0.10/Media to Proxmox /mnt/pve/plexmedia
      • Test it by command ls /mnt/pve/plexmedia, should list media files
  • Configure the Proxmox Container, still in the Proxmox shell
    • Ensure that the container is shutdown, note its ID number (e.g. 103)
    • Map the Proxmox storage into the Container:

      pct set 103 -mp0 /mnt/pve/plexmedia,mp=/media

    • In the Plex Server VM, try ls -l /media, to see if it shows the media files

Migrate Data From Another Server

If migrating Plex data from another server, these instructions summarised in the notes below provide a general guide to the process.

  • On source server
    • Stop the server: service plexmediaserver stop
    • On for example TrueNAS FreeBSD in Plex Jail shell, ZIP up file databases/metadata:
    1
    2
    
    cd /usr/local/plexdata
    tar -czvf plexbackup.tar.gz “Plex Media Server”
    
    • In main TrueNAS shell, copy file to TITAN/Media folder:
    1
    
    mv /mnt/JailsPool/iocage/jails/plex/root/usr/local/plexdata/plexbackup.tar.gz /mnt/MasterPool/Media/
    
  • On destination server
    • Disable scans and Empty trash automatically in Settings / Library to avoid updates whilst migrating data, click Save Changes
    • Sign out of the Plex account
    • Stop the server in the VM Console: service plexmediaserver stop
    • In the server’s new /var/lib/plexmediaserver/Library/Application Support/Plex Media Server folder delete the following folders: Media / Metadata / Plug-in Support / Plug-ins, as they will be replaced below
    • Use FileZilla SSH into the server and copy the backup file to new server Plex data folder. In case of Ubuntu in LXC, folder = /var/lib/plexmediaserver
    • Unzip the file in that folder: tar -xzvf plexbackup.tar.gz

    • In the resulting ‘Plex Media Server’ folder, delete folders other than Media / Metadata / Plug-in Support / Plug-ins
    • Move the remaining folders/files to their proper location

      mv ‘Plex Media Server’ ‘Library/Application Support/’

    • Restart Plex Server: service plexmediaserver start
  • Remap folders, do one library at a time:
    • For each library, click on 3-dots, Manage Library -> Edit, and under Add folders browse to and add the new media folder path
    • Scan should start, check all okay
    • Remove old folder path
    • Repeat for next library
  • Final maintenance
    • Re-enable Scans / Delete trash in Settings -> Library
    • Empty trash for the server
    • Clean bundles for the server, wait a few minutes after the dialog box goes away
    • Optimise database for the server

Update Plex Server (as required)

If the Plex Server GUI indicates an update is available – check What’s New and decide whether it really needs updating. If so, then (YouTube guide):

  • In a browser go to plex.tv -> Downloads
  • Select Public Downloads -> Server
  • Select Linux tab. On Ubuntu 64-bit version, right-click and copy URL link
  • SSH into the Plex Server (Ubuntu), type command wget and paste URL from above
  • Once downloaded type ls to confirm .deb file has been downloaded ok, then command:

    sudo dpkg -I plexmediaserver_XXXXXX.deb (as URL above)

  • Plex service is stopped, new files are installed, then Plex service is restarted
  • Confirm in browser that Plex Server version is updated. Done!

References

This post is licensed under CC BY 4.0 by the author.
Recently Updated
Trending Tags
Contents
Trending Tags