Newsletter
Newsletter

Host Your Own Media Server – Plex Media Server With NVIDIA PCIe Passthrough

Scroll down
Mahdi AlMulla
Mahdi AlMulla
I`m
  • Residence:
    Bahrain
  • Age:
    25

May 9, 2023

14:32

Mahdi AlMulla

In recent years, the rise of online streaming services has made it easier than ever to access a vast array of media content from the comfort of your own home. However, for many people, there is still something to be said for hosting your own media server. This allows you to store your media collection locally, access it from any device on your network, and customize your setup to your exact specifications.

This article illustrate how a Plex Media Server can be installed on a VM inside a ProxMox hypervisor. To truly take advantage of Plex’s capabilities, however, you may want to consider using PCIe passthrough with an NVIDIA graphics card. This technology allows you to assign a dedicated GPU to a virtual machine, boosting performance and enabling hardware transcoding for even smoother playback.

Step 1: Setting up a new VM (Ubuntu 20.4.6 Live Server)

To host Plex Media server, I will be using the Ubuntu 20.4.6 Live Server as an operating system.

System Specifications:

  • CPU: 4 Cores
  • RAM: 4GB
  • Hard Disk: 20GB (As my media library will be mounted on the server using CIFS)

Note: Install OpenSSH Server as we are going to remotely access the server via ssh.

Step 2: Install Plex Media Server

With the Ubuntu 20.4.6 Live Server VM up and running, the next step is to install the Plex Media Server software. This can be done by adding the Plex repository to Ubuntu and then installing the server software via the command line. Once installed, you can access the Plex Media Server interface from your web browser and start adding your media collection.

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 -
sudo apt update
sudo apt install plexmediaserver

Step 3: Configure Network Share for Plex Media Server


To enable your Plex media server to access your media library, you will need to configure a network share. In my case, since I have a NAS server that contains (legally obtained) media library, I can configure a network share to grant Plex media server access to the media files. This will be done by mounting the NAS drive to the fstab file, which will be used by the system at boot time to mount network share automatically.

sudo nano /etc/fstab

Add to bottom of file

//PATH-TO-FILE-SERVER /PlexMedia cifs username=$$$$$$$$,password=######## 0 0

And then reboot

After rebooting the machine, Plex Media Server is now accessible through https://<SERVER_IP>:32400/web. Where we can now import our media, and plex will automatically discover it, and generate data from the metadata.

To this point, plex is now up and running, the only one thing left now is to passthrough a gpu to the VM and utilize the NVENC to transcode large media.

Step 4: PCIe Passthrough

PCIe Passthrough is a technology that allows you to dedicate a physical device, such as an NVIDIA graphics card, to a virtual machine. This enables the virtual machine to access the full capabilities of the device, including hardware transcoding, which can significantly improve the performance of a Plex media server.

Let’s begin this by verifying the model of GPU installed on the ProxMox hypervisor.

Run the command:

lspci -v

As given there is only one GPU installed named: GeForce GTX 1660 SU

ProxMox Setup for PCIe Passthrough:

  • Add IOMMU Support:
nano /etc/default/grub

For Intel users

GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on"

For AMD users

GRUB_CMDLINE_LINUX_DEFAULT="quiet amd_iommu=on"

Save the file and close

update-grub
  • Load VFIO Modules at Boot
nano /etc/modules
vfio
vfio_iommu_type1
vfio_pci
vfio_virqfd

Save the file and close

echo "options vfio_iommu_type1 allow_unsafe_interrupts=1" > /etc/modprobe.d/iommu_unsafe_interrupts.conf
echo "options kvm ignore_msrs=1" > /etc/modprobe.d/kvm.conf
  • Add Nvidia & nouveau Drivers to the kernal’s blacklisted modules
echo "blacklist nouveau" >> /etc/modprobe.d/blacklist.conf
echo "blacklist nvidia" >> /etc/modprobe.d/blacklist.conf
  • Find Your GPU
lspci -v
  • Copy the HEX values from your GPU here > /etc/modprobe.d/vfio.conf
echo "options vfio-pci ids=####.####,####.#### disable_vga=1"> /etc/modprobe.d/vfio.conf
update-initramfs -u
  • Hide VM identifiers from NVIDIA

nano ###.conf (# is the VM identifier of your Plex server) > and modify CPU Line (Make sure that the VM is stopped)

cpu: host,hidden=1

Lastly reboot your ProxMox hypervisor

Step 5: Install Nvidia Drivers on the Ubuntu Server

sudo apt install build-essential libglvnd-dev pkg-config
wget https://www.nvidia.com/content/DriverDownloads/confirmation.php?url=/XFree86/Linux-x86_64/525.116.03/NVIDIA-Linux-x86_64-525.116.03.run&lang=us&type=TITAN

Make sure that the link is specific to your GPU

./NVIDIA-Linux-x86_64-###.##.##.run

Confirm GPU is using downloaded drivers

nvidia-smi

Now after enabling HW transcoding, we can see that the videos are being transcoded using HW NVENC engine.

Setting up a Plex media server with PCIe passthrough on Proxmox can greatly enhance your media streaming experience, providing you with powerful hardware transcoding capabilities and smoother playback on multiple devices. By following the steps outlined in this guide, including creating a new virtual machine, installing and configuring Ubuntu, setting up a network share for your media files, and configuring PCIe passthrough for hardware transcoding, you can build a high-performance media server that meets your specific needs. With your own media server, you can easily organize and stream your media collection on any device, without relying on third-party services or limited streaming options. So, if you’re looking to create your own media server, give this guide a try and see how it can help you elevate your media streaming experience.

Posted in Technology, Tutorials, Virtualization
Write a comment
© 2025 All Rights Reserved.
Made with ❤️ by Mahdi
Write me a message