If you have not already, we suggest setting your Plex username to something else rather than email which is displayed on your posts in forum. You can change the username at https://app.plex.tv/desktop#!/account
Welcome to our forums! Please take a few moments to read through our Community Guidelines (also conveniently linked in the header at the top of each page). There, you'll find guidelines on conduct, tips on getting the help you may be searching for, and more!

[Guide] Plex Media Server with Intel NUC and Ubuntu 16.04 LTS

grogstergrogster Posts: 26Members, Plex Pass Plex Pass
edited January 16 in Linux

HARDWARE

  • Intel NUC (BOXNUC7I5BNK, i5-7260U 2,20 GHz, Link)
  • 2 x 8GB DDR4 RAM (CT2K8G4SFD8213, Link)
  • 250GB M.2 PCIe NVMe SSD (Samsung 960 EVO MZ-V6E250BW, Link)

This hardware setup is meant to be an allrounder. Fast enough to transcode multiple movies at the same time, almost completely silent in order to run it in the living room and power efficient in order to run it 24/7. It is able to hardware transcode three H.264 1080p movies at the same time with ~30-35% CPU load. Transcoding a single H.265 4K HDR movie has ~35-40% CPU load.
If you are looking for a single user setup this NUC might be overkill, the NUC i3 with 2 x 4GB RAM should be fine then.


Step 1: Install Ubuntu

  • Update BIOS with latest from Intel's website
  • Install Ubuntu 16.04 LTS 64bit server version
  • Use the following partition scheme (ESP size was suggested by Ubuntu, swap size is much bigger than usual because of RAM transcoding):

    #1: 536MB, ESP, bootable
    #2: 64GB, swap
    #3: 185,5GB, ext4

  • Setup user named plex


Step 2: Install Plex Media Server

  • Add plex repository as source

    • 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 -
  • Install Plex Media Server + dependencies

    • sudo apt-get update && sudo apt-get install avahi-daemon avahi-utils plexmediaserver
    • During installation you will be asked if you want to override the plex repository source with the one from the package. Select yes.
  • Re-enable plex repository source

    • By default the plex repository source from the package is disabled (commented out), enable it in /etc/apt/sources.list.d/plexmediaserver.list


Step 3: Setup NFS and Autofs

  • Install dependencies

    • sudo apt-get install autofs nfs-common
  • Create mount directory and configure Autofs

    • sudo mkdir /data
    • sudo nano /etc/auto.master
    • Append the following line at the end of the file:
/data      /etc/auto.data
  • Create Autofs configuration file for data directory
    • sudo cp /etc/auto.misc /etc/auto.data
    • Append all your mount points at the end of the file, for example:
movies    -fstype=nfs4    <ip-of-your-nas>:/volume1/Movies
music     -fstype=nfs4    <ip-of-your-nas>:/volume1/Music
  • Restart Autofs

    • sudo systemctl restart autofs
  • All your mount points are now available at /data/...

  • Autofs will automatically unmount all mount points if there is no access within 5 minutes and remount if you try to access the mount point. You can keep ghost references to the mount points by adding --ghost in auto.master at the end of the appended line


Step 4: Configure Plex Media Server

  • Open http://<ip-of-your-server>:32400/web in your browser and configure your server


Step 5: Setup RAM transcoding

  • Create transcoding directory

    • sudo mkdir /tmp/transcoding
  • Setup the system to mount the RAM disk on every boot

    • sudo nano /etc/fstab
    • Append the following line:
tmpfs    /tmp    tmpfs    defaults,noatime,nosuid,nodev,noexec,size=64G,mode=1777    0    0
  • Grant writing permissions for the transcoding directory

    • sudo chown -R plex:plex /tmp/transcoding
  • Use /tmp/transcoding in Plex Media Server > Settings > Server > Transcoder > Temporary directory


Additional notes / tips

  • In order to update plex media server it is enough to run the system update: sudo apt-get update && sudo apt-get upgrade
  • If you setup a DDNS service for your server consider to configure the Ubuntu firewall. In that case please check out the Plex reference for which ports you need to allow
«1

Comments

  • checktravischecktravis Posts: 45Members, Plex Pass Plex Pass
    edited January 9

    @grogster said:
    * #2: 64GB, swap (much bigger than usual because of RAM transcoding)

    I ended up going with 8 gigs of ram, (pair of 4G). I may upgrade it later, want to see how it goes with 8. Does that change the size of this swap partition here? should I make it 32 since I am using half the ram you are?

  • grogstergrogster Posts: 26Members, Plex Pass Plex Pass

    @checktravis said:
    I ended up going with 8 gigs of ram, (pair of 4G). I may upgrade it later, want to see how it goes with 8. Does that change the size of this swap partition here? should I make it 32 since I am using half the ram you are?

    No I would not, as swap is kind of "disk memory", if the system runs out of memory, it writes parts of the RAM into the swap partition in order to free RAM.

  • checktravischecktravis Posts: 45Members, Plex Pass Plex Pass

    Great guide,. I have tried ubuntu and centos, can't decide which to keep.

    I have the M.2 installed, as well as a few usb 3.0 drives (not ssd) I can use. I'd like to run a seedbox along with Plex (with my Plex video library) What would be the best use of the external drives verses the m.2?

  • grogstergrogster Posts: 26Members, Plex Pass Plex Pass

    Thanks, very much appreciated!

    As both Ubuntu and CentOS are officially supported this is a decision about your preference. As I'm more familiar with Ubuntu I've chosen that one.

    For storing your video library I would go with the external drives as you'll need a lot of space and SSD drives are pretty much expensive.

  • checktravischecktravis Posts: 45Members, Plex Pass Plex Pass

    i use my own user to sudo and set everything up. Should the auto log in user script be mine or should it be'plex'? or, does it matter as long as it is the owner of the directory?

  • CooadCooad Posts: 28Members ✭✭

    Hi
    I’m using a similar device as a server (MSI Cubi 2), and I believe these are ideal devices to use for PMS.
    I also set up ram transcoding, and I might have a suggestion - I set the ramdisc size to only 2 GB, and everything is working. I know the plex support page says you need to have enough space to hold the entire file, but in my experiance, when the ramdisc is about 90% full, the „old” chunks are deleted. That means you don’t need that much ram (I have only 4 GB), and such a big swap partition.
    The biggest file I tried is 6,5 GB 10 Mbps 1080p movie - I have no guarantee that it would work with what you mention. But I’m definately curious :)

  • grogstergrogster Posts: 26Members, Plex Pass Plex Pass

    @checktravis I'm not exactly sure about this, from what I've read it should not matter as far as any user is logged in. There were users that reported issues with the server if no user was logged in.

    @Cooad good to know! I experienced kind of the same when I played a 60GB 4K movie. Even if this article says "The directory used needs sufficient free space, roughly equal to the size of the source file of the transcode plus 100MB" the transcoding for that movie used almost two times my complete RAM + swap, that's 100GB more that the source file size. It looked like the old data got cleaned up. Maybe this are optimizations from the linux system.

  • checktravischecktravis Posts: 45Members, Plex Pass Plex Pass

    I'm transitioning off my Nighthawk x10 router. The official firmware offers no shell access so I am constantly running into issues with file permissions, lack of rsync on the server, etc. So, I thought go with a small NUC instead. This setup is working great (thanks again for going through the effort of documenting it).

    Question: Running PMS and serving the media files too much for this NUC? I might plug the drives back in to the x10, but transfer rates are so much slower because NTFS seems to be the only format that just works. Netgear says others are supported but good luck getting a stable connection to anything else.

    Will start a new thread if this is too off topic.

  • grogstergrogster Posts: 26Members, Plex Pass Plex Pass

    It shouldn't be a problem to handle both, there's no difference in CPU load if you read the data from network storage or USB drives. Just an idea: besides the M.2 connector the NUC has a SATA port on the mainboard. Use this one to get better read/write rates.

  • checktravischecktravis Posts: 45Members, Plex Pass Plex Pass

    Odd they would offer that with no room to use it without leaving it open. I did find these third party cases: http://www.gorite.com/

    Thanks for the tip.

  • checktravischecktravis Posts: 45Members, Plex Pass Plex Pass
    edited January 13

    i can't get glances to work. it may be a user/permission issue

    gtop

    /home/[me]/bin/gtop: line 1: glances: command not found

    pip show glances

    Name: Glances
        Version: 2.11.1
        Summary: A cross-platform curses-based monitoring tool
        Home-page: https://github.com/nicolargo/glances
        Author: Nicolas Hennion
        Author-email: nicolas@nicolargo.com
        License: LGPLv3
        Location: /usr/local/lib/python2.7/dist-packages
        Requires: psutil
    

    tried adding /usr/local/lib/python2.7/dist-packages to path

    UPDATE:
    following 'specific user location' info here https://github.com/nicolargo/glances/blob/master/README.rst

    i kept getting

    You are using pip version 8.1.1, however version 9.0.1 is available.
    You should consider upgrading via the 'pip install --upgrade pip' command.

    and that suggestion didn't work, but

    pip install --user --upgrade pip

    did work, then I was able to

    export PYTHONUSERBASE=/home/[me]/
    pip install --user glances
    export PATH=$PATH:/home/[me]/bin
    

    then gtop works (as does 'glances')

  • millercentralmillercentral Posts: 73Members, Plex Pass Plex Pass

    Thanks for the guide, really helpful. A couple of questions:

    • did you consider a docker container instead of native install of Plex? If so, any pros in your opinion to this setup vs docker?
    • how do you manage updates to the server? Manually through client prompts, or something else?

    Thanks again!

  • checktravischecktravis Posts: 45Members, Plex Pass Plex Pass

    can you explain a little about STEP 10: Setup RAM transcoding?
    I am transcoding, df -h shows
    tmpfs 64G 51M 64G 1% /tmp
    (the only line that matches the size)

    sudo ls -la /tmp/transcoding/ - 
    ls: cannot access '/tmp/transcoding/': No such file or directory
    

    but i see it if i
    sudo ls -la /tmp/

  • grogstergrogster Posts: 26Members, Plex Pass Plex Pass

    @millercentral I bought this machine as dedicated plex server, so I decided to install it natively. I would say pro for docker is that you have it running in its own sandbox, in performance it shouldn't matter if you got with native or docker. If you check the Dockerfile it uses the same setup with Ubuntu 16.04. I'm not (yet) that experienced with docker, I played a little bit with it by creating a plex webhook for light control and using influxdb + grafana in combination with glances to have a monitoring history. Maybe I'll decide to switch to docker at some later point. Do you see any pros to the docker setup?
    In step 5 I add the plex repository as source, I can now simply do sudo apt-get upgrade and it will update plex server as well.

    @checktravis this looks like a permission issue. If you do sudo ls -lsa /tmp/ is owner and group set as the plex user?
    You could try to switch to root shell with sudo -i can you access this directory then?

  • checktravischecktravis Posts: 45Members, Plex Pass Plex Pass

    still can't enter it even with sudo -i

    but here is the directory item:

    0 drwxr-xr-x 3 plex plex 60 Jan 13 05:20 transcoding

  • ChuckPAChuckPA Posts: 19,551Members, Plex Pass, Plex Ninja, Plex Team Member Plex Team Member

    I've been following the developments here.

    When everything is settled and you have this process boiled down to a procedure / How-To, I will be happy to help with the final formatting and post it up for you in the Linux Tips if you wish.

    Please DISABLE Verbose logging until requested

    Please search before posting

    Primary support forums: Linux, Synology, and QNAP

    Please remember to report back. This benefits others.

    Useful links

     Installation and Basic Setup |  Media Preparation (How to name your media files)  |  Linux Permissions 

     Handling TV Specials | Handling Movie extras  |  Nas Compatibility List

     Reporting Plex Server issues | Plex Media Server FAQ | Linux Tips

     

    Other useful guides: Local Subtitles | The Plex "dance" | Synology FAQ | PMS Release Announcements

    Hosts: Fedora, QNAP, Synology, most Linux distros in VM

    No technical support via PM unless offered

    Please remember to mark the appropriate answer(s) which solved your issue.

     
  • grogstergrogster Posts: 26Members, Plex Pass Plex Pass

    @checktravis is your question about the df -h command or do you have any issues while transcoding? When I configure a directory as transcoding directory where I setup wrong permissions (root only access for example) and try to play a movie in the browser (this is important, there are no issues in this case when you use the plex media player app) I get an error immediately ("An error occurred tying to play this item. shaka1001 (network)").

    @ChuckPA yes, that would be great! :) What would be necessary to have a procedure / How-To?

  • CooadCooad Posts: 28Members ✭✭

    Another suggestion from me - i believe the autologin is unnecessary. My current machine has no autologin, and the previous one hadn't either. And the shorter guide, the better :-)

  • grogstergrogster Posts: 26Members, Plex Pass Plex Pass

    @Cooad I'll try that the next couple of days, thanks!

    @millercentral I will also test a docker installation of pms, if I runs without issues I re-write that part of the guide

  • ChuckPAChuckPA Posts: 19,551Members, Plex Pass, Plex Ninja, Plex Team Member Plex Team Member

    @grogster

    To create a guide

    1. Think of the 'Step by step' sequence for someone who should have the enough basic skill to do this. (you can't teach them Linux)
    2. Consider the target user(s). I strongly recommend you do not integrate Docker with it. It should be free standing. Not everyone will want to use Docker on a a dedicated NUC. (Unnecessary layer of complication and abstraction)
    3. I suggest taking a look at the sequences I've created in Linux Tips https://forums.plex.tv/categories/linux-tips as a template to follow

    Of note: The Proxmox guide is user-generated. I only performed the final formatting

    Please DISABLE Verbose logging until requested

    Please search before posting

    Primary support forums: Linux, Synology, and QNAP

    Please remember to report back. This benefits others.

    Useful links

     Installation and Basic Setup |  Media Preparation (How to name your media files)  |  Linux Permissions 

     Handling TV Specials | Handling Movie extras  |  Nas Compatibility List

     Reporting Plex Server issues | Plex Media Server FAQ | Linux Tips

     

    Other useful guides: Local Subtitles | The Plex "dance" | Synology FAQ | PMS Release Announcements

    Hosts: Fedora, QNAP, Synology, most Linux distros in VM

    No technical support via PM unless offered

    Please remember to mark the appropriate answer(s) which solved your issue.

     
«1
Sign In or Register to comment.