Jump to content

Building Emby in Ubuntu Server


Recommended Posts


I’ve built out an Emby server using Linux.  The Emby install was very easy but getting the Linux part ready took a goodly amount of work.  I figured I’d document things (mostly) step by step and help out any other poor soul that wants to trek this path.


Why build it in Linux when a Windows build is much easier?  *shrug*  I dunno….  the experience is worth the effort sometimes.  One thing I will point out is that this build does not give you the ability to encode using the video card without a lot of extra work.  This is because I'm using an older card which has poor Linux support.  If you'd like to take advantage of GPU encoding then I highly recommend going with a more recent AMD/ATI video card or an Nvidia from about GTX 650 onwards.  At some point I'm going to replace the AMD HD 5550 I currently have with a GTX 650 TI Boost to get the transcoding ability.  My Windows system has a GTX 960 and the ability to offload the transcoding to GPU really helps keep the CPU usage/temps down.


My hardware list:

  • Case:  The cheapest micro-ATX case I could find in Micro Center
  • CPU:  AMD Phenom II x4 955 Black Edition (It’s old but it’ll do.)
  • Memory:  2 x 8 GB Ballistix Sport sticks
  • Power Supply:  The cheapest 500 watt PSU I could find in Micro Center
  • DVD Reader:  Huh?  Who needs that?
  • Video Card:  AMD HD 5550 Low Profile (you can ditch this if your computer has onboard video adapter)
  • Motherboard:  ASUS M5A78L-M/Plus USB3 (new purchase)
  • Hard Drives:  1 x Western Digital 1 TB Caviar Green (probably bought refurbished), 2 x Hitachi HGST Ultrastar 2 TB (new purchase, refurbished)
  • Monitor, Keyboard & Mouse:  Don’t need these after the initial setup so go ahead and use your primaries or spares for the moment.


Software list:  Ubuntu 16.04 Server as my base OS.  To install the OS I burned the Ubuntu ISO to an 8 GB flash drive using Rufus.


Step by step of what to do:


1.  Put your computer together.

Get a friend to help you if necessary.  Make certain that it works without letting the smoke out of the wires before you move on to the next steps.  For the moment you’ll need to connect a monitor and keyboard.  There’s no GUI (yet) so a mouse would be useless.


2.  Download Ubuntu 16.04 Server.

You can find it here.  (Pro tip:  it’s the third link from the top.)  The server version will give us a low-drag, high speed platform that won’t need a monitor, keyboard or mouse.  Remember, this is a media server.  You put into a closet (or basement in my case), connect it to your home network and turn it on.   After that, forget it exists.


3.  Put the ISO onto your flash drive.

I used Rufus to put the ISO onto the flash drive and make it bootable.


4.  Boot your system from the Linux install flash drive.

ANAND wrote up a great step by step at HTPC Beginner.  I have two notes:  For Step 13, I chose to install Ubuntu to my 1 TB hard drive, I accepted the defaults and did the whole drive.  For Step 20, I selected Samba file server, standard system utilities, virtual machine host and OpenSSH server.  We’ll need Samba and OpenSSH towards the end when we connect remotely.  The VM host software is because I like to play with VMs.  You can leave it out if you like.  So, go ahead, follow those instructions and then come on back when you’re done.  We’ll wait.


5.  Install xRDP (and the Mate desktop).

As a headless server (no monitor, keyboard or mouse) we need an alternate way to manage the computer.  xRDP and SSH are our tools of choice.  (Almost every version of Windows has the RDP client installed already so I like to use it.)  Griffon did a step by step that covers the basics.  I cover the steps here, following Griffon's steps 1 through 3.  Step 4 is useful if you need to change keyboard layouts but I skipped it.  When you finish this step, you will be able to RDP and SSH from your Windows computer and access Mate Desktop or command line on the server.


Why would we want both xRDP and SSH?  It's a matter of preferences.  Some things are just easier and quicker to do via SSH but there are also times that the GUI interface is more familiar and easier to use.  By installing both, you have the option to use whichever you chose.


Install xRDP with the following command:

sudo apt-get install xrdp

Install Mate with the following two commands:

sudo apt-get update && sudo apt-get install mate-core mate-desktop-environment mate-notification-daemon

What are we doing here?  The "sudo apt-get update" refreshes our packages with the latest version information for the various programs/components that are installed in Ubuntu.  The "&&" portion of the command allows us to run two commands on one line with the second command (the "sudo apt-get install....") running only after the first command successfully completes.


Set Mate as the default desktop for xRDP with this command:

sudo sed -i.bak '/fi/a #xrdp multiple users configuration \n mate-session \n' /etc/xrdp/startwm.sh

In order to connect with the Windows RDP client we need to know the server's IP address.  Find the IP address with this command:


Take note of the IP address NOT associated with LO or virbr0.  (The LO is the local loopback address, it's an address the OS can always use to talk to itself.  The virbr0 address corresponds to the interface for virtual machines, not really applicable to our needs at the moment.  If your computer has two network interface cards, use the first one.)  Write the address down because we’ll need it in the following steps.



Let’s get connected with RDP and SSH.

Ubuntu is installed.  xRDP and SSH are installed and Mate is set as the desktop for RDP sessions.  RDP is easy to check so let’s start there.  On your Windows computer, press the Windows key, type RDP, and then click on the Remote Desktop Connection application.



The RDP program will open to this window.



Enter the IP address you copied down before and press the Connect button.  You’ll get a window like this one.



Don’t be shy, go ahead and enter your username and password and the press OK.  After a few moments you’ll get a desktop similar to mine but without the drive or terminal icons.  Please be aware that sometimes I do get an error when I try to log in and I need to go through the process a second time.  The second time has always been a charm.



Poke around the menu a bit and you’ll quickly see there’s very little software installed.  This is by design.  This installation of Mate is minimalist.  There's no bloat included and it lets you install only what you need.  We’ll need to install a couple of things but we’ll do it from the console through SSH.  Go ahead and close out your RDP session.  (Pro tip:  RDP is different from the typical VNC session in that it allows your Linux session to continue after you close out the RDP session.  You can leave a program running and when you log back in it will be there waiting for you.)  Close out your session by hitting the X in the upper right corner.


We’re going to do some SSH now but we’ll need a client.  I suggest you download and install (on your Windows machine) a program called Putty.  You can find it here.  Download the version appropriate to your system, install it and then fire it up.  Enter your server's IP address where the block for Host Name (or IP address) is.



The first time you do this you will get a message about certificates and fingerprints.  Accept the message and you’ll end up at the following screen.



Enter your username and hit enter, then enter your password and hit enter.  You’re working in CLI (command line interface) which means you’re on the way to becoming a power user.



Now we get to install the missing software we’ll need.  We want an easy way to install some software from the GUI so use this command to install the Mate Welcome Center, Ubuntu Software Center, disks, gparted and the Chrome web browser:

sudo apt-get install ubuntu-mate-welcome software-center gnome-disk-utility gparted chromium-browser

For the moment we are finished with the console so go ahead and close it out by typing exit and hitting enter (or … hit the X in the upper right corner).


6.  Prepare the storage drives.

Quick Note:  Preparing the drives can be done from the command line.  I haven't figured it out yet so feel free to chime in if you know how to do it.


Format and mount storage drives.

This section is for preparation of virgin storage media.  If your drives already have content that you do not want to lose due to a hard drive reformat then you should probably skip down to "Create Media Folders and Set Permissions", "Samba Sharing" or "Installing Emby."


If you’ll remember, I have two new 2 TB hard drives installed.  In an ideal world I would set these up as a Raid 0 storage solution and have one storage volume of 4 TB.  This is the real world.  I’m kind of dumb and couldn’t figure out how to get it to work so I set up the hard drives individually as storage1 and storage2.  I keep my videos/movies on storage1 and all my other media on storage2.  There’s no rhyme or reason to this, it’s just how I decided to do it and Emby really doesn’t care.  So, let’s jump back into our RDP connection and fire up GParted.  You’ll find it under System->Administration->GParted.



After you enter your password you’ll have to wait a few seconds as GParted checks out which drives are installed.  When you finally get to the main screen you’ll see an arrow on the right hand side just after the text “/dev/sda” or something similar.  Click on the arrow and you’ll see the other drives that are installed.



Click on the /dev/sdb drive.  Then right click on the long rectangular block that says /dev/sdb 1.82 TiB…. Ok, at this point I’ve run out of images to help walk through the rest of the steps to create a partition and format it.  (My drives are already formatted and contain data that I don’t want to lose.)  Don’t despair, check out this post from Chris for a nice walk through of getting it done.  Follow the steps to delete the partition (if there is one), create a partition and then format it.  Do this for both storage drives.


Pay attention:  format the drives to ext4, not NTFS and label your drives storage1 and storage2 by typing the names into the Label: field in GParted.  (Chris leaves the field blank in his example.)  Come back when you’re finished.


Right.  The drives are partitioned, formatted and labeled.  They are also assigned a mount point.  This is important to know because when you reboot your server, these drives will not automagically mount themselves to be available for Emby.  We need to do one more thing to make that happen:  set up fstab entries using Disks.  Close out GParted and open Disks.  You’ll find it under Applications->Accessories->Disks




Once Disks opens you’ll get a nice screen like this.



On the left side of the window select the first storage hard drive with a left click.  Click the gear icon just below the volume graphic and select Edit Mount Options.  Change the options to look like mine.



Changing the Automatic Mount Options to off means the server will always mount the drives on boot.  This avoids problems with Emby attempting to automount the drives.  Make sure to change the Identify As option to LABEL=storage1.  This is the label that will show up on your desktop and it will also make mapping drives in Emby a bit easier.  Click OK and do the next storage drive.  You’ll probably need to enter your password a few times to authorize the changes.  Once finished with both drives, close out Disks and you should find two new drive icons on your desktop.  Neat, huh?


Now we need to create the folder structure on the storage drives.  Along the way we’re also going to put the MATE Terminal icon on your desktop.  Click on Applications->System Tools and then right click on MATE Terminal.  You’ll get the following menu options.  Select Add this launcher to desktop.



Create media folders and set permissions.

Now your desktop looks just like mine.  Splendid.  Let’s open up the terminal and get back to work.  When the terminal opens we want to change directories to the first storage drive.  Type the following command to do that:

cd /mnt/storage1

Then create the folder for the videos using this command:

sudo mkdir Movies

Look to make sure it’s there with:

ls –l

This image shows all of the commands on one screen.  Note that I got an error message saying the directory couldn’t be created.  That’s because it’s already there.  Also note that my Movies permissions and owner information are likely different than yours.  (The permissions are the long string of drwxrwxrwx at the beginning.)  This is important but we’ll sort that out later on.




Now let’s go to the storage2 drive and create some folders over there.

cd /mnt/storage2
sudo mkdir Pictures
sudo mkdir Music
sudo mkdir TV
sudo mkdir Recordings
sudo mkdir Recordings/TV
sudo mkdir Recordings/Movies
ls –l

We’ve created a folder structure to store pictures, music and TV shows.  The Recordings folder is where I stash my temporary recordings of TV shows and Movies.  (I use an HDHomeRun Prime to provide cable to Emby.)  The recordings are later moved out of the Recordings folder and into their respective folders in /mnt/storage1/Movies or /mnt/storage2/TV.


So, we’ve got the drives prepped and the folders created.  There’s just three more pieces left:  set up ownership, permissions and Samba sharing.  We'll do the first two later on (after we install Emby), the Samba Sharing is next.


Samba Sharing

Lets set up media folder sharing over the network.   We do that with Samba.  Samba is already installed so our next step is fairly straightforward:  edit the correct file and restart the samba services.  Let’s use Putty for the remaining steps so start Putty and log in.


If you didn't install Samba during the OS installation, you can drop into a terminal session and use the following command:

sudo apt-get install samba samba-common system-config-samba

You can learn more about this at HowtoForge.


Use the following command to open your samba configuration file:

sudo nano /etc/samba/smb.conf

Scroll down to the line that mentions “workgroup =”.  If you created a new workgroup for the computers then you will need to change the samba workgroup name.  My home network is different than the standard workgroup name so I modified the line to show my home workgroup name:

 workgroup = PARADISE

This allows my media server to show up in my workgroups when I browse the network in Windows.  Double clicking on the media server’s name will cause it to show the shared folders.  Speaking of shared folders, let’s go ahead and add those into the config file.


Scroll to the bottom of the file and add in these lines:

  comment = Movies and Videos
  path = /mnt/storage1/Movies
  browseable = yes
  read only = no
  guest ok = yes

  comment = Shared Music folder
  path = /mnt/storage2/Music
  browseable = yes
  read only = no
  guest ok = yes

[TV Shows]
  comment = Shared TV Shows
  path = /mnt/storage2/TV
  browseable = yes
  read only = no
  guest ok = yes

  comment = Shared Pictures
  path = /mnt/storage2/Pictures
  browseable = yes
  read only = no
  guest ok = yes

  comment = Shared Recordings
  path = /mnt/storage2/Recordings
  browseable = yes
  read only = no
  guest ok = yes

What have we done here?  The “[Name]” entry creates the share name we’ll see over the network.  The comment entry is the description that will show up under certain circumstances.  The path statement tells samba which folder we want to share.  The browseable entry means the users will be able to click between the different subfolders and see directory listings.  We mark the share as “read only = no” so our users can make changes and the “guest ok = yes” prevents requests for user names and passwords.  Press Ctrl-X and answer Y (and enter) to save the file.  Restart samba to implement these changes with the following two commands:

sudo service nmbd restart
sudo service smbd restart

Well, it looks like we’re ready to install Emby.  Finally.


7.  Installing Emby.

Instructions to install Emby are available at the web site.  Select the option for the Ubuntu install and follow the write-up.


8. Setting up the permissions on the storage drives.

File and directory permissions need to be modified so Emby can read/write the files and store other files within the directories.  This step will walk you through setting up a script to automate the process and ensure the script runs every hour to keep the permissions up to date.  The lead-in I got to do this came from a discussion on the forums, specifically this post set me on this path.  Feel free to read up on it yourself for more background information.


To keep things simple we're going to create a script in the root directory and then we'll set the permissions so the script will execute.  In Terminal enter these commands:

cd /
sudo nano perms.sh

Nano will open up.  Enter the following lines:


chown -R emby /mnt/storage1/Movies
chgrp -R emby /mnt/storage1/Movies
chmod -R 0777 /mnt/storage1/Movies

chown -R emby /mnt/storage2/Pictures
chgrp -R emby /mnt/storage2/Pictures
chmod -R 0777 /mnt/storage2/Pictures

chown -R emby /mnt/storage2/TV
chgrp -R emby /mnt/storage2/TV
chmod -R 0777 /mnt/storage2/TV

chown -R emby /mnt/storage2/Music
chgrp -R emby /mnt/storage2/Music
chmod -R 0777 /mnt/storage2/Music

chown -R emby /mnt/storage2/Recordings
chgrp -R emby /mnt/storage2/Recordings
chmod -R 0777 /mnt/storage2/Recordings

Here's a screen capture:



Save the file by pressing Ctrl-X and saying yes when asked if you want to save the file.  What have we done here?  The “#! /bin/sh” line tells the command interpreter that this is a script file to run.  Each “chown –R emby /mnt/xxxx” line changes the owner to emby for all files and folders in the specified directory.  Likewise, the “chgrp –R emby /mnt/xxxx” line changes the group membership.  The “chmod –R 0777 /mnt/xxxx” command changes the permissions on the files and folders to let everyone read, write and execute the files.  While in the security world this is considered really, really, really bad, I find it to be expedient to getting Emby up and running.  Be aware: your guests/visitors/family members have the power to delete or change your files with this setting.


Before we can run the script we must change the permissions.  We do that with this command:

sudo chmod 755 perms.sh

Now we can manually run the script with this:

sudo ./perms.sh

Run the script once just to ensure it works the way it should.  But our end goal is to have the script run automagically every hour to ensure that Emby (and users) have continued access to the files and folders.  (What does this really mean?  Say you record a movie in Emby and have it setup to auto-organize the recording into the Movies storage.  All is good.  But if you copy or move a folder and file over the network into storage then Emby will not have permissions to play the file or add in metadata to the folder.  We overcome this by running the script every hour, giving Emby the necessary ownership and permissions to read the files and make the modifications we want.)  Do this by setting up a cron job at the command line:

sudo crontab –e

A new window will open in nano, scroll to the bottom and enter this line:

0 * * * * /perms.sh

Your entry should look like this:



Press Ctrl-X and answer yes to saving the file.  What we’ve done is told the computer to run the /perm.sh script at zero minutes (that’s the 0) of every hour (the first *) of every day (second *) of every month (third *) on every weekday (fourth *).  Check out this site for more info about crontab if you like.


That’s it.  You should be able to access your Emby installation and set it up to point to the correct directories.  From your Windows machine open an RDP session and go to http://localhost:8096 in Chrome on the Ubuntu desktop.  You can also go there directly from Windows by going to http://<IP Address>:8096 where <IP Address> is the address you wrote down at the end of step 5.

I'll leave the customization of Emby up to you, it should be cake and pie from here on out. 


URLS used in this document

Ubuntu 16.04 Server:  http://releases.ubuntu.com/16.04/

Rufus:  https://github.com/pbatard/rufus

ANAND’s Ubuntu installation step by step:  http://www.htpcbeginner.com/install-ubuntu-server-16-04/

Griffon’s xRDP and Mate installation step by step:  http://c-nergy.be/blog/?p=8952

Putty:  http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

GParted walkthrough:  http://comtech247.net/2012/07/05/formatting-a-hard-drive-using-gparted/

HowtoForge - Samba Server Installation on Ubuntu 16.04:  https://www.howtoforge.com/tutorial/samba-server-ubuntu-16-04/

Emby Linux permissions topic:  http://emby.media/community/index.php?/topic/31142-permissions/

Crontab explanations:  http://crontab.guru/#0_*_*_*_*

Emby package:  https://software.opensuse.org/download.html?project=home%3Aemby&package=emby-server

Edited by panamajim
Link to comment
Share on other sites

  • 2 weeks later...

Nice write up! I'm a super linux newbie, who happens to have a phenom II x4 955 laying around, so this is super helpful since I haven't done anything yet. How's the temperature in the mATX case? I was also looking into docker

Edited by teivalp
Link to comment
Share on other sites


Thank you. I hope the step-through helps you out.


So far the temps really haven't risen that much. I set the BIOS hardware monitor to turn the system off when the CPU hits 80C. It's not gotten close to that yet so I'm not too worried. Of course, your mileage may vary depending on case, number of case fans, airflow and usage so you'd need to take my results with a grain of salt.


I read your original post and must admit that I don't have any experience with PCI tuner cards in this build. I've used them in the past with Window Media Player and I was never happy with the results which lead me to using the Silicon Dust solution. I have a second Silicon Dust box that does only OTA from cable and antenna. I plan to add that into the mix in the future.


I've no experience with Docker but the write ups I've read glow in the praise for it. Sorry I can't help you on that one.

Link to comment
Share on other sites


Thank you very much for this great step-by-step guide. I'm a newbie in Linux, used OpenSuse for the past few days but had some problems. Now I'm on Ubuntu and everything works like a charm!

Edited by Theumis
Link to comment
Share on other sites




You're most welcome. I'm glad it worked for you. I'll be the first to admit that there are some areas that can be improved and I hope to document them in the near future. The read/write permissions for one. They can be locked down a bit to improve security in the shared files but I need to test them before I commit to paper. SSH security can also be improved so the system can be placed with Internet facing access but it's just not there yet. Another thing to add in when I get the chance. I think, however, that the system is solid for use on a home network as it stands.


Feel free to post back and updates you find that help speed things up and/or improve security.

Link to comment
Share on other sites

  • 2 months later...

Awesome guide!!  thank you


What is it needed for? We have easy ubuntu installation instructions on the website.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...