I've been playing with Plex Media Server for the last few weeks on my Linux laptop, and much to my surprise it seems to play back any video format I throw at it including DivX and XviD which is the format of a great many of my collection of movies. So buoyed by this I have decided to move the entire Plex configuration to a dedicated Ubuntu virtual machine which will reside on my Intel NUC I reviewed earlier.
My Intel NUC is headless, and whilst it is possible to create a VM image on the command line, it is much more convenient to create it on a GUI elsewhere and move it over to the NUC. To that end, I created the VM on my Mac knowing the network configuration would ultimately have to change when the VM is in situ on the NUC.






The steps are quite straightforward so there isn't much need for narrative. I had previously downloaded the Ubuntu 16.04 LTS server iso image (more of that in a minute).
I decided to go for 4GB RAM and 10GB fixed disk size which should be more than adequate.

The initial network connection is set as above. We need a bridged network so I can use my pre-existing 192.168 network in my property. Obviously when the VM is moved to the Intel NIC the AirPort won't be a valid setting at that point - so we'll have to change it then.



As mentioned previously, I had already downloaded the Ubuntu 16.04 LTS iso image which is selected for the installation above. Most of the installation screens haven't been captured for brevity because they are straightforward, but note I have selected openSSH server in the software packages to install - this is important since we will need to ssh into our headless Plex server.
We now need to edit the /etc/network/interfaces file to change the default DHCP IP assignment to static. Your configuration will obviously be different from mine here. I've elected to go for the address of 192.168.0.203 for my server.
nigel@plex-media-server:~$ cat /etc/network/interfaces # This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). source /etc/network/interfaces.d/* # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto enp0s3 # iface enp0s3 inet dhcp iface enp0s3 inet static address 192.168.0.203 netmask 255.255.255.0 network 192.168.0.1 broadcast 192.168.1.255 gateway 192.168.0.1 dns-nameservers 90.207.238.97
I have already covered how to export a VM image in a previous blog here, so I don't need to go into too much detail in this blog. My VM has been exported and now needs to be copied to the NUC host machine using scp.
Nigels-MacBook-Pro:Documents nigel$ scp Plex\ Media\ Server.ova nigel@192.168.0.202:/home/nigel/VM/. nigel@192.168.0.202's password: Plex Media Server.ova 100% 604MB 4.1MB/s 02:27 Nigels-MacBook-Pro:Documents nigel$
nigel@devbox:~/VM$ VBoxManage import Plex\ Media\ Server.ova 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100% Interpreting /home/nigel/VM/Plex Media Server.ova... OK. Disks: vmdisk1 10737418240 -1 http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized Plex Media Server-disk001.vmdk -1 -1 Virtual system 0: 0: Suggested OS type: "Ubuntu_64" (change with "--vsys 0 --ostype <type>"; use "list ostypes" to list all possible values) 1: Suggested VM name "Plex Media Server" (change with "--vsys 0 --vmname <name>") 2: Number of CPUs: 1 (change with "--vsys 0 --cpus <n>") 3: Guest memory: 4096 MB (change with "--vsys 0 --memory <MB>") 4: Sound card (appliance expects "", can change on import) (disable with "--vsys 0 --unit 4 --ignore") 5: USB controller (disable with "--vsys 0 --unit 5 --ignore") 6: Network adapter: orig Bridged, config 3, extra slot=0;type=Bridged 7: CD-ROM (disable with "--vsys 0 --unit 7 --ignore") 8: IDE controller, type PIIX4 (disable with "--vsys 0 --unit 8 --ignore") 9: IDE controller, type PIIX4 (disable with "--vsys 0 --unit 9 --ignore") 10: SATA controller, type AHCI (disable with "--vsys 0 --unit 10 --ignore") 11: Hard disk image: source image=Plex Media Server-disk001.vmdk, target path=/home/nigel/VirtualBox VMs/Plex Media Server/Plex Media Server-disk001.vmdk, controller=10;channel=0 (change target path with "--vsys 0 --unit 11 --disk path"; disable with "--vsys 0 --unit 11 --ignore") 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100% Successfully imported the appliance.
$ VBoxManage modifyvm "Plex Media Server" --nic1 bridged --bridgeadapter1 enp3s0 $ VBoxManage modifyvm "Plex Media Server" --audio none
$ pwd /home/nigel/VirtualBox VMs $ VBoxHeadless --startvm "Plex Media Server" &
nigel@nigel-Aspire-VN7-793G:/etc$ ssh nigel@192.168.0.203 The authenticity of host '192.168.0.203 (192.168.0.203)' can't be established. ECDSA key fingerprint is SHA256:BLRRmyijEFgtS+KnkXQUudkdsMskpLrzR19zBugQ2ww. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '192.168.0.203' (ECDSA) to the list of known hosts. nigel@192.168.0.203's password: Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-87-generic x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage 127 packages can be updated. 64 updates are security updates. Last login: Sun Feb 18 19:58:43 2018 from 192.168.0.12 nigel@plex-media-server:~$
$ sudo apt-get install cifs.utils
$ sudo mkdir /mnt/freenas
# cat .cifs username=xxxxxx password=xxxxxx # ls -las .cifs 4 -r-------- 1 root root 39 Feb 18 21:37 .cifs
$ sudo mount.cifs //192.168.0.200/personal /mnt/freenas -o vers=3.0,credentials=/root/.cifs,uid=1000 $ ls -las /mnt/freenas | grep Documents 0 drwxr-xr-x 2 nigel root 0 Aug 14 2017 Documents
$ sudo umount /mnt/freenas $ cat /etc/fstab # /etc/fstab: static file system information. # # Use 'blkid' to print the universally unique identifier for a # device; this may be used with UUID= as a more robust way to name devices # that works even if disks are added and removed. See fstab(5). # # <file system> <mount point> <type> <options> <dump> <pass> # / was on /dev/sda1 during installation UUID=600eb961-4caa-4a24-b8cf-c35efdd71ca4 / ext4 errors=remount-ro 0 1 # swap was on /dev/sda5 during installation UUID=523ed080-41af-4dab-839f-070f40c26ada none swap sw 0 0 # CIFS FreeNas mount //192.168.0.200/personal /mnt/freenas cifs credentials=/root/.cifs,uid=1000,vers=3.0 0 0 $ sudo mount -a $ ls -las /mnt/freenas | grep Documents 0 drwxr-xr-x 2 nigel root 0 Aug 14 2017 Documents

Firstly navigate to Settings->Server->library and disable the setting Empty trash automatically after every scan as shown above. Save this setting change.
$ sudo service plexmediaserver stop [sudo] password for nigel: $ ps -ef | grep plex nigel 6274 1647 0 09:51 pts/1 00:00:00 grep --color=auto plex $
nigel@devbox:~$ VBoxManage list vms "badzilla-d8" {86af2c61-3b68-47c5-a71e-8f45ac196cbe} "Plex Media Server" {5efa7e7b-ae92-45a9-8244-bae451b53c0a} nigel@devbox:~$ VBoxManage list runningvms nigel@devbox:~$
nigel@devbox:~$ VBoxHeadless --startvm "Plex Media Server" &
nigel@devbox:~$ ssh nigel@192.168.0.203 The authenticity of host '192.168.0.203 (192.168.0.203)' can't be established. ECDSA key fingerprint is SHA256:BLRRmyijEFgtS+KnkXQUudkdsMskpLrzR19zBugQ2ww. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '192.168.0.203' (ECDSA) to the list of known hosts. nigel@192.168.0.203's password: Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-87-generic x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage 19 packages can be updated. 10 updates are security updates. Last login: Sun Feb 18 22:11:59 2018 from 192.168.0.14 nigel@plex-media-server:~$
nigel@nigel-Aspire-VN7-793G:~/Downloads$ scp plexmediaserver_1.11.3.4803-c40bba82e_amd64.deb nigel@192.168.0.203:/tmp nigel@192.168.0.203's password: plexmediaserver_1.11.3.4803-c40bba82e_amd64.deb 100% 104MB 817.5KB/s 02:10 nigel@nigel-Aspire-VN7-793G:~/Downloads$
nigel@plex-media-server:~$ sudo dpkg -i /tmp/plexmediaserver*.deb [sudo] password for nigel: Selecting previously unselected package plexmediaserver. (Reading database ... 93857 files and directories currently installed.) Preparing to unpack .../plexmediaserver_1.11.3.4803-c40bba82e_amd64.deb ... Unpacking plexmediaserver (1.11.3.4803-c40bba82e) ... Setting up plexmediaserver (1.11.3.4803-c40bba82e) ... Created symlink from /etc/systemd/system/multi-user.target.wants/plexmediaserver.service to /lib/systemd/system/plexmediaserver.service. Processing triggers for ureadahead (0.100.0-19) ... Processing triggers for systemd (229-4ubuntu21.1) ... Processing triggers for mime-support (3.59ubuntu1) ... nigel@plex-media-server:~
nigel@plex-media-server:~$ sudo service plexmediaserver stop
nigel@nigel-Aspire-VN7-793G:/$ ls -las /var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server/ total 44 4 drwxr-xr-x 10 plex plex 4096 Feb 24 09:51 . 4 drwxr-xr-x 3 plex plex 4096 Jan 28 20:11 .. 4 drwxr-xr-x 5 plex plex 4096 Feb 24 09:45 Cache 4 drwxr-xr-x 3 plex plex 4096 Jan 28 20:11 Codecs 4 drwxr-xr-x 3 plex plex 4096 Jan 28 20:11 Crash Reports 4 drwxr-xr-x 3 plex plex 4096 Feb 24 09:14 Logs 4 drwxr-xr-x 3 plex plex 4096 Jan 28 20:18 Media 4 drwxr-xr-x 6 plex plex 4096 Jan 30 21:44 Metadata 4 drwxr-xr-x 3 plex plex 4096 Feb 22 20:25 Plug-ins 4 drwxr-xr-x 7 plex plex 4096 Jan 28 20:11 Plug-in Support 4 -rw------- 1 plex plex 1002 Feb 24 09:45 Preferences.xml nigel@nigel-Aspire-VN7-793G:/$
root@plex-media-server:/home/nigel# passwd plex Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully root@plex-media-server:/home/nigel#
nigel@nigel-Aspire-VN7-793G:/$ sudo -H -u plex scp -rp /var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server/* plex@192.168.0.203:"/var/lib/plexmediaserver/Library/Application\\ Support/Plex\\ Media\\ Server/."
Next we should start the Plex service on the destination machine and check it came up ok.
nigel@plex-media-server:~$ sudo service plexmediaserver start nigel@plex-media-server:~$ ps -ef | grep plex plex 17501 1 0 13:19 ? 00:00:00 /bin/sh -c LD_LIBRARY_PATH=/usr/lib/plexmediaserver "/usr/lib/plexmediaserver/Plex Media Server" plex 17502 17501 22 13:19 ? 00:00:02 /usr/lib/plexmediaserver/Plex Media Server plex 17517 17502 89 13:19 ? 00:00:07 Plex Plug-in [com.plexapp.system] /usr/lib/plexmediaserver/Resources/Plug-ins-c40bba82e/Framework.bundle/Contents/Resources/Versions/2/Python/bootstrap.py --server-version 1.11.3.4803-c40bba82e /usr/lib/plexmediaserver/Resources/Plug-ins-c40bba82e/System.bundle nigel 17541 1453 0 13:19 pts/0 00:00:00 grep --color=auto plex nigel@plex-media-server:~$


You should now be able to point your browser to Plex's new home. You need to change the URL to include your IP address, which in my case is 192.168.0.203 with a port of 32400. Yours should be similar but probably not identical. Check out the first image above for the entire URL although you won't need to include the index.html.
You may have to log in again but mine went straight to the 'Recently Added' view as you can see in the second image above. So my media and my libraries have been found ok. This shouldn't be a surprise - don't forget earlier in the tutorial I connected the VM to my FreeNAS where the media is held - and the canonical path is exactly the same to the media on the VM (destination) as it is on my source machine (my laptop).

Now we know everything is working ok, we should re-enable the emptying of trash - see the screenshot above.
$ sudo dpkg --remove plexmediaserver [sudo] password for nigel: (Reading database ... 334962 files and directories currently installed.) Removing plexmediaserver (1.10.1.4602-f54242b6b) ... Removed symlink /etc/systemd/system/multi-user.target.wants/plexmediaserver.service. Processing triggers for systemd (229-4ubuntu21.1) ... Processing triggers for ureadahead (0.100.0-19) ... Processing triggers for desktop-file-utils (0.22-1ubuntu5.1) ... Processing triggers for mime-support (3.59ubuntu1) ... Processing triggers for libc-bin (2.23-0ubuntu10) ...