Introduction
Following the file-server setup described in the previous article, I’m now moving on to setting up a media server. The initial clone preparation is almost identical to the previous file-server setup, so I’ll be going through that portion quickly. As a recap, the file server provides SMB (Server Message Block) shares that can be mounted and used much like local storage.
Since I have a lifetime Plex Pass subscription, Plex is a convenient choice for streaming my media remotely. For playback at home, however, I prefer Kodi. This is because my media library is stored locally on the file server, and Kodi can access SMB shares directly. Kodi also provides a more customizable interface with fewer distractions (no ads).
Kodi, however, does not provide built-in remote streaming functionality. Although alternative methods like Tailscale or a Cloudflare Tunnel can be used to allow remote access. Plex already supports remote access, making it the simpler choice for streaming outside the home.
This will be a two-part setup:
- Install Plex Media Server for remote streaming.
- Install Kodi for local streaming
Media Server VM Clone and Setup
What follows is a recap of what was presented in my previous article. Because the process is almost identical, I’ll be running through the commands quickly with minimal explanation. I have linked the previous article in various spots if you want a more detailed walk through.
In Proxmox:
- Clone the base template, and confirm that the cloned VM has a unique MAC address.
- Start the cloned VM.
- Log in as
rootthrough the Proxmox console.
From the Cloned VM:
Adjust Font size (optional)
setfont Lat15-Terminus28x14
Generate New Machine ID
systemctl stop systemd-machine-id-commit
rm -f /etc/machine-id /var/lib/dbus/machine-id
systemd-machine-id-setup
systemctl start systemd-machine-id-commit
Generate New SSH Host Keys
systemctl stop ssh
rm -f /etc/ssh/ssh_host*
ssh-keygen -Asystemctl start ssh
Configure Networking for this VM
systemctl stop networking.service
nano /etc/network/interfaces
nano /etc/hosts
nano /etc/hostname
systemctl restart networking.service
Update the IP address, hostname, gateway, and any other settings as required for this VM.
Finally, reboot the VM. After the reboot, verify the settings:
hostnamectl
ip a
systemctl status ssh
From this point forward, I will be using ssh instead of the Proxmox Console, as the terminal is far more flexible.
Plex Repository and Signing-Key Changes
There have been some changes to the way Plex Media Server is installed and updated on Linux since my previous installation, so I want to cover those differences before moving on.
Starting with Plex Media Server version 1.43.0, Plex moved its Linux package repository to a new location and introduced the PlexSign.v2 signing key. Older tutorials may use the previous outdated information. Specifically; downloads.plex.tv/repo/deb, plexmediaserver.gpg, or PlexSign.key files.
The current repository and key to use are https://repo.plex.tv/deb/ and PlexSign.v2.
If you use the Plex installation script, it places the key file at /usr/share/keyrings. Other instructions may use /etc/apt/keyrings. Either location can work. The important thing is that the path in the repository configuration matches the key’s actual location. Additionally it uses the older Debian repository file format.
Since this is a fresh clone there are no old Plex repositories to remove. But if you are using a custom setup, you will want to remove the old Plex repository. You should validate the correct file before removing.
ls -la /etc/apt/sources.list.d/
sudo rm -f /etc/apt/sources.list.d/<plex apt file>
sudo apt update
Using the Plex Install Script
While visiting the Plex website I saw that Plex now provides an installation script, and I’ll be using that script here. Before running it, I downloaded the script without executing it, for inspection.
wget https://repo.plex.tv/scripts/setupRepo.sh
less setupRepo.sh
It was while reviewing the script, I noticed that it used a different signing key and key-storage location from those shown in the manual installation instructions. That prompted me to investigate the change further, and create the above dialog.
It is good practice to review installation scripts before running them, especially when they require root privileges. You should;
- confirm that the script came from the official source
- examine the commands it will execute
- understand what it is doing before running it.
Having satisfied my paranoid curiosity, I deleted the script, mainly because I wanted to test the Plex one line command as given. But, I still needed to download an application, curl, to use the one line command. While I was at it I also installed cifs-utils, which I’ll need later to mount SMB shares.
sudo apt update
sudo apt upgrade
sudo apt install curl cifs-utils
curl -LsSf https://repo.plex.tv/scripts/setupRepo.sh | sudo bash
The script walked through the install, asking the appropriate questions, and setting everything up correctly. However the one thing I wish it had done was configure the new repository according to DEB822 format instead of the older one line format. So I converted it myself, and updated apt.
sudo nano /etc/apt/sources.list.d/plex.sources
Types: deb
URIs: https://repo.plex.tv/deb/
Suites: public
Components: main
Architectures: amd64
Signed-By: /usr/share/keyrings/plexmediaserver.v2.gpg
sudo rm /etc/apt/sources.list.d/plex.list
sudo apt update
Finally I confirmed the media server was installed and running.
sudo systemctl status plexmediaserver
And that was it. Using the script it is surprisingly simple to install the plexmediaserver.
Set Up Plex Library Folders on the File Server
Before accessing the media, I need to log in to the file server and set up the media directory. Once this is complete, both Plex and Kodi will be able to access the media files.
- Create samba media group, and add myself to it
- Create a media folder and adjust the permissions
- Update the smb.conf file
- Restart the samba server
I start off by logging into the file server via SSH. This means we will be using sudo a lot. First let’s create the new group. I use the -r option to create a system group
sudo groupadd -r sambamedia
Only members of the sambamedia group should be able to access the share, so I add myself to the group.
sudo usermod -aG sambamedia rt
Create a folder to hold the media files next.
sudo mkdir /srv/media
Change the ownership of the folder to root and sambamedia. The leading 2 in chmod sets the setgid bit, which causes new files and directories to inherit the sambamedia group. I also use a 0 at the end to block everybody else form this direcotry.
sudo chown root:sambamedia /srv/media
sudo chmod 2770 /srv/media
If you are following along from the previous article, you know the smbpasswd was already created for our current user. If this is a custom installation, you may need to create a samba user and password.
sudo smbpasswd -a <user>
Use your favorite text editor to modify the /etc/samba/smb.conf file by adding a new section for media. Other than the name, path, and group this is basically the same as the public share previously created.
[media]
comment = Shared directory
path = /srv/media
browseable = yes
read only = no
guest ok = no
valid users = @sambamedia
force group = sambamedia
create mask = 0660
force create mode = 0660
directory mask = 0770
force directory mode = 2770
We can now test the smb.conf file, restart Samba, and log out of the file server.
sudo testparm
sudo systemctl restart smbd
logout
There is one metadata issue worth mentioning. Plex normally stores its metadata in its own application-data directory, while Kodi stores its library database locally on the playback device. They should not overwrite each other’s metadata unless Kodi is configured to export .nfo files or artwork into the media folders. For that reason, I’ll avoid enabling Kodi’s export options unless I specifically want it to write metadata beside the media files.
Finally we need to copy some media files over to our media folder. We can do this via the file manager, since we should now have permission to access the media folder.
smb://172.20.30.63/media
Plex Media Server Setup
We need to SSH back into our media server. Because this was originally a clone created from a template, I am using the same non-privileged user. This simplifies things when setting up samba shares. The basic process is as follows.
- Create a media folder
- Test mount the file server media folder
- Create a new fstab entry so the folder will mount on restart.
First I create a media folder. There is no reason to not put it in the same place as on the file server.
sudo mkdir /srv/media
Now we can test mount the folder. The below command should prompt you for a password.
sudo mount -t cifs //172.20.30.63/media /srv/media -o username=rt,vers=3.0
Assuming everything worked, we can create a credentials file somewhere on our server. It can go anywhere. While some may prefer a different location for the credentials file, I have placed it in /etc/ for simplicity..
sudo nano /etc/.credentials
username=rt
password=XXXXXXXXXX
sudo chmod 600 /etc/.credentials
sudo chown root:root /etc/.credentials
Once we confirm everything works, we can modify the fstab file on the media server. There can be a lot, or a few things we put here, and some will depend on your situation. I am going with something beyond the minimum without going completely crazy.
//172.20.30.63/media /srv/media cifs credentials=/etc/.credentials,_netdev,nofail,uid=plex,gid=plex,ro,file_mode=0640,dir_mode=0750 0 0
- start with the IP address and media folder
- Next comes the mount point folder we created
- Then the mount type, cifs, got to love Windows, SMB/CIFS is a real thing.
- Next is a number of comma separated options
- Our credentials file
- _netdev tells the system that networking is required
- nofail keeps the system from stalling if the mount fails
- uid=plex,gid=plex are the user and group plex created when it was installed
- ro is read only (don’t want Plex messing with our metadata)
- file_mode=0640,dir_mode=0750 controls basic file permissions
- Finally we end with 0 0 which stops legacy dumps and prevents fsck disk scans
Some would also want to add vers= to the options. But the server is setup for only smb 3. 0 or above, so it is not really necessary here. If you don’t know the server you are connecting to, then it would be a valid option.
At this point go ahead and reboot the media server, then validate that the directory mounted and everything is working correctly.
To complete this, we need to log into the local Plex server and follow instructions provided.
http://172.20.30.64:32400/web
How Plex setup proceeds will depend on if you have a active Plex subscription or not.
Local Kodi Setup
Setting up Kodi on a local machine is much simpler. The first step is to install the application via your package manager. For Windows or MAC,OS try their application stores.
For example, on my laptop I go to the KDE Discover store. Type kodi in the search bar, and install it.
Once it is installed it should show up in the program menu. You can click on it to run it.
From the Kodi interface go to settings then file manager. From the left side select Add Source.
From the popup Window select browse. Then select Add network Location.
In the new Window select SMB for the protocol. In the Server Name block type the IP address and base folder. In my example it would be 172.20.30.63/media. Then enter your user name and password. Then click OK. Your SMB share should now show up as a source.
Next go back to settings and select Media, then Library. Next select the type of media (videos, music, pictures). From the popup select browse, and you should see your SMB server is a browseable choices. Select it, then browse to the appropriate folder and it will be added as a library. Choose to scan the library and wait for Kodi to finish.
Conclusion
This concludes part 4 of this series. We have setup a media server, storing our media on the file server SMB share. This provides a benefit of allowing ohter application’s to access our media as well.
This leaves two more servers to build, library and wiki. Which I will be handled in upcoming articles.
Mini PC (I)Virtualization and Storage



Leave a Reply