Plex - Arch30n/blog GitHub Wiki

Plex LXC Installation

Login to Proxmox and select your Proxmox server in the left pane. Click on Shell in the middle pane. Enter the following command to start the Plex LXC install via the tteck script. Press Enter on Yes.

bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/plex.sh)"
  1. Select Advanced.
  2. Select 22.04 Jammy.
  3. Change CONTAINER TYPE to Privileged.
  4. Enter a complex password.
  5. Accept the container ID.
  6. Set the Hostname.
  7. Change the Disk Size as needed. Note: I’d go for 16GB minimum.
  8. Change Core Count as needed. Note: I’d recommend starting with 2-4 cores.
  9. Change RAM as needed. Note: Plex is light on memory usage, so even 1024MB should be plenty.
  10. Leave the Bridge.
  11. Optionally set a static IP (e.g. 192.168.10.45/24). Note: Strongly recommended to use static IP.
  12. Set a Gateway IP.
  13. Don’t disable IPv6 (unless you need to).
  14. Leave MTU Size.
  15. Set DNS Search Domain (if needed).
  16. Set a DNS server IP.
  17. Leave the MAC address blank.
  18. Leave the VLAN.
  19. Enable Root SSH access.
  20. Don’t enable verbose mode.
  21. Press enter on Yes, Create Plex LXC.
  22. Select your storage by using the arrow keys, then press space to select, and tab to OK.
  23. Again, select the storage you want to use.
  24. Wait for the OS to download and update. Make take a few minutes. DO NOT do ANYTHING in the Proxmox console during the install. Wait for the Plex should be reachable message.

Note: tteck’s Plex LXC installer downloads and installs a number of libraries needed for hardware GPU acceleration. So you might see other guides on the internet that manually install several packages. Those steps can be skipped with his Plex LXC script.

Mounting media folders

We will in the next three sections explain the most common methods for how files can be accessed from inside the LXC Container. Please follow along with the option that applies to your specific network setup.

Option 1: Mounting an SMB/CIFS share

Option 2: Mounting an NFS Share

Option 3: Mounting a directory on the Proxmox host

Option 1: Mounting an SMB/CIFS share

The SMB/CIFS protocol provides support for cross-platform file sharing with Microsoft Windows, OS X, and other Unix systems.

Installing cifs-utils Let’s return to the container’s console and install the cifs-utils package.

apt install cifs-utils -y

Plex in Proxmox LXC Container - Image 33

Creating CIFS Credentials Once cifs-utils have been downloaded, create an empty text file and place it under /root/.cifs_credentials. We prefer nano, but use whichever text editor you are comfortable with.

nano /root/.cifs_credentials

Plex in Proxmox LXC Container - Image 34

Inside the file, add your SMB/CIFS username= on the first line and password= on the second line.

Tip: (Ctrl+o saves the file and Ctrl+x exits the editor.)

username=<username>
password=<password>

Plex in Proxmox LXC Container - Image 35

Optional: Increase security by adjusting the read/write permissions on the file to the current owner only.

chmod 600 /root/.cifs_credentials 

Plex in Proxmox LXC Container - Image 36

Creating the Mount Directory Create a directory in which we will mount our SMB/CIFS share. As we are using Plex, let’s give the directory the appropriate name;/mnt/plex.

mkdir Plex in Proxmox LXC Container - Image 37

Retrieving Plex uid and gid This step is necessary if you want to allow deletion of media files from within Plex Media Server.

When a directory is mounted it will belong to the user who first mounted it. In our example, the owner is root, while Plex Media Server runs as user plex. It will therefore not be able to modify any files belonging to root unless ownership is changed during the mount process.

In order to do so we need to first retrieve the User ID (uid) and Group ID (gid) of user plex. Execute the following command and write these numbers down because they will be used in the next section:

id -u plex && id -g plex Plex in Proxmox LXC Container - Image 38

Systemd We will mount our network share with systemd, rather than fstab, because the latter does not seem to remount on reboot as discussed in this Reddit post.

Under /etc/systemd/system/, create a new unit configuration file (.mount) that inherits its name from the full path to your mounted directory, with the quirk that all forward slashes / are replaced with a hyphen -.

Example 1: Your plex directory resides under /mnt/plex. Your unit configuration file should therefore be called /etc/systemd/system/mnt-plex.mount.

Example 2: A randomly shared folder under /home/geek/Public/important_files must be called /etc/systemd/system/home-geek-Public-important_files.mount and nothing else!

Armed with this information, let’s go ahead and create the file:

nano /etc/systemd/system/.mount Plex in Proxmox LXC Container - Image 39

Add the following information and replace <server_path>, , <mount_point>, and as necessary.

Save and close the file.

[Unit] Description=Plex Media Server files Requires=network-online.target After=network-online.service

[Mount] What=//<server_path>/ Where=/<mount_point> Options=credentials=/root/.cifs_credentials,uid=,gid= Type=cifs

[Install] WantedBy=multi-user.target Plex in Proxmox LXC Container - Image 40

Enable the unit configuration file:

systemctl enable .mount Plex in Proxmox LXC Container - Image 41

Start the directory service to automatically mount the folder:

systemctl start .mount Plex in Proxmox LXC Container - Image 42

Verify that the files are now seen in the mounted directory.

ls -l Plex in Proxmox LXC Container - Image 43

Great, the files are there, and we can now go ahead and add this folder to Plex Media Server in Completing the Setup.

If you are using NFS shares instead, read on for Option 2: Mounting an NFS Share.

Caution: If you are continuing from Option 1: Mounting an SMB/CIFS share, please reset the container first and restart the tutorial from the Configuration section. Your mounted directory will otherwise be mapped twice with different protocols!

Option 2: Mounting an NFS Share

Network File System (NFS) is a distributed file system, which in comparison to SMB/CIFS, has better performance when medium-sized or small files are accessed.

If your LXC Container is still running, please turn it off with the Shutdown button.

Plex in Proxmox LXC Container - Image 44

Enabling NFS Container Support Assuming that you are using a Privileged container, click on 100 (plex) [1], then Options [2] and double-click on Features [3].

Plex in Proxmox LXC Container - Image 45

Enable NFS [1] and press OK [2].

Plex in Proxmox LXC Container - Image 46

Features should now display mount=nfs.

Plex in Proxmox LXC Container - Image 47

Go back to 100 (plex) [1], Console [2] and Start [3] the container.

Plex in Proxmox LXC Container - Image 48

Log back in with your credentials.

root Plex in Proxmox LXC Container - Image 15

Installing nfs-common Once logged in, install the nfs-common package.

apt install nfs-common -y Plex in Proxmox LXC Container - Image 49

Creating the Mount Directory Create a directory in which we will mount our NFS share. As we are using Plex, let’s give the directory the appropriate name;/mnt/plex.

mkdir Plex in Proxmox LXC Container - Image 37

Adding fstab Entries NFS shares in LXC Containers can be mounted via /etc/fstab, so we will go ahead and edit this file:

nano /etc/fstab Plex in Proxmox LXC Container - Image 50

Add the following information by replacing <server_path>, and with your own network share settings and then save and close the file.

<server_path>:/ / nfs defaults 0 0 Plex in Proxmox LXC Container - Image 51

Mounting the Volume We can now mount the directory in /etc/fstab with the mount -a command.

mount -a Plex in Proxmox LXC Container - Image 52

Verify that the files are now seen in the mounted directory.

ls -l Plex in Proxmox LXC Container - Image 43

Yep, the files can be seen and the directory will remain mounted even after a reboot.

You can now jump to Completing the Setup or read on for Option 3: Mounting a Directory on the Proxmox host.

Caution: If you are continuing from Option 2: Mounting an NFS Share, please reset the container first and restart the tutorial from the Configuration section. Your mounted directory will otherwise be mapped twice with different protocols!

Option 3: Mounting a Directory on the Proxmox host

The final option that we will discuss is how to mount an LXC container directory directly from within the Proxmox host.

If your LXC Container is still running, please turn it off with the Shutdown button.

Plex in Proxmox LXC Container - Image 44

We will now open a terminal directly on the Proxmox host. (Note: not on the container).

Select pve [1] and open up a new Shell [2].

Plex in Proxmox LXC Container - Image 53

The pct Command Let’s assume that our media files are stored in the following directory on the Proxmox host, /mnt/plex.

We can now tell Proxmox to mirror this local directory onto the LXC Container with this simple Proxmox Container Toolkit (pct) command:

Replace , and with your own specific parameters.

pct set -mp0 ,mp= Plex in Proxmox LXC Container - Image 54

Changing File Ownership If you want the option to be able to delete external files from within Plex Media Server, change the ownership of the mount directory to plex.

Note: We are currently uncertain whether this is the correct way to change ownership for directories inside LXC Containers. If you aware of a “better” method, please let us know in the comments below and we will update this section. For now, it seems to work for what we are trying to do.

chown -R plex:plex /mnt/plex/ Plex in Proxmox LXC Container - Image 55

Launching the Container Let’s exit our Proxmox shell and return to the web interface and select 100 (plex) [1], Resources [2] to verify that the Mount Point (mp0) [3] has been set to /mnt/plex,mp=/mnt/plex.

Good, it is there.

Plex in Proxmox LXC Container - Image 56

Go back to 100 (plex) [1], Console [2] and Start [3] the container.

Plex in Proxmox LXC Container - Image 48

Verify that the files are now seen in the mounted directory.

ls -l Plex in Proxmox LXC Container - Image 43

⚠️ **GitHub.com Fallback** ⚠️