Plex Media Server
Plex media is going to host all media files I own. This is going to run in its own virtual machine on proxmox.
To connect
user@192.168.1.252
Inside of Proxmox I have created a virtual drive to store media files on.
pve>plex>hardware>add>hard disk
This gave me a 2TB drive to store media files onto but it needs to be mounted to the ubuntu server and given a path. To do this automatically I added an entry to fstab. The steps to do this are as follows
First list the block devices that the system can detect
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 100G 0 disk
├─sda1 8:1 0 512M 0 part /boot
└─sda2 8:2 0 99.5G 0 part /
sdb 8:16 0 1.8T 0 disk
└─sdb1 8:17 0 1.8T 0 part /mnt/plex
Here we can see that sdb is the 2TB drive that was created. Now format this drive and give it a ext4 file system. This will wipe all data, do not accidentally do this to the wrong device.
$ sudo mkfs.ext4 /dev/sdb
Now we need to get the UUID of the drive to make this drive mount automatically on startup
$ sudo blkid /dev/sdb
/dev/sdb: UUID="8986dc87-308b-44ab-a1e3-b78fc98c871e" TYPE="ext4"
Linux needs to know where on the file system the data from this drive should be mounted to. Making a new directory inside the /mnt folder for this is the best way.
sudo mkdir /mnt/plex-media
Now we are ready to edit fstab and have this drive mounted to the /mnt/plex-media folder
$ sudo nano /etc/fstab
APPEND TO BOTTOM
UUID=8986dc87-308b-44ab-a1e3-b78fc98c871e /mnt/plex ext4 defaults 0 2
Fstab has been changed and now it needs to be reloaded to take effect
$ sudo systemctl daemon-reexec
$ sudo systemctl --user daemon-reload
$ sudo mount -a
Plex requires that the plex user is the owner of the drive. However I want to be sure that my regular user account and plex both have read write permission to this drive. To do this I made a group and added both users to it.
$ sudo groupadd media
$ sudo usermod -aG media plex
$ sudo usermod -aG media ben
Set group ownership of the drive
$ sudo chown -R root:media /mnt/media
Give permissions to owners, groups, and other users
sudo chmod -R 775 /mnt/media
Save and test
$ sudo mount -a
I want to be able to directly connect my laptop to this drive so that I can write data to it as if it were a drive mounted directly to my laptop. To achieve that I used sshfs which uses a secure ssh connection to mount the drive to my laptop using the ben account that now has read write permission to the drive.
Install SSHFS
$ sudo pacman -Sy sshfs
Create a local mount point
mkdir -p ~/plex-media
Mount the remote drive
sshfs ben@192.168.1.252:/mnt/media ~/plex-media
Accessing Plex
Plex web client is hosted from within my home network on
http://192.168.1.252:32400
To mount the drive to my laptop I created a shell script that will run the sshfs command so I don’t have to keep it memorised
$ touch plexlogin.sh
$ nano plexlogin.sh
#! /bin/bash
sshfs ben@192.168.1.252:/mnt/media ~/plex-media
$ chmod +x plexlogin.sh
Then created an alias so that it could be run from any location in the terminal with mountplex command
$ sudo nano /.bashrc
APPEND
# connect to the plex server files
alias mountplex='/path/to/file/plexlogin.sh'