OK, so I wrote a guide before on how to install Serviio on a Windows machine. This is fine for a lot of people, but living in Thailand means crap TV and extremely expensive Cable TV fees. So, to beat that, I decided to build a dedicated server for the job of looking after my media. I wanted to incorporate my torrenting, media storage, data backup and make a bit of a test platform with the one unit.
Starting out with a donated laptop and a 1TB USB HDD (WD Elements powered unit for those interested) I went about installing Ubuntu and getting Serviio to work with it. This guide will show you how to do it, you’ll see that it’s not quite as simple as it’s made out to be, especially to a relative noob to Linux!
OK, the choice of hardware is up to you, but I’d recommend something with a minimum of 1GB of RAM, Serviio uses Java and is pretty resource heavy. People install Serviio on NAS units, but my personal experience is that on these setups it runs like a dog and won’t allow for transcoding, which is 90% of the beauty of Serviio anyway. So dedicated machine it is – do you have an old desktop from within the last 10 years? It’s probably a good candidate to be the media server!
OK, so now we have ourselves a machine to install the software on, let’s start with the OS (Operating System). I chose Ubuntu because I had experience with it at my workplace and I was comfortable with using it on the command line. You can choose other flavours of Linux, but for the sake of this guide (and my sanity) I’m just going to talk about Ubuntu.
Go to the Ubuntu website download section and choose Ubuntu Server 12.04 LTS – there are newer versions available but this one has long term support meaning it will be more stable than later versions. I chose 32bit for my machine, but you can use 64-bit with very little changes needed to this guide (if you spot any, leave a comment!).
Burn the ISO to a CD or DVD and slap it in your machine (making sure your optical drive is set as the primary boot device in the machine’s BIOS). You could use a USB stick or Memory card if you don’t have an optical drive available.
Follow the instructions for installing Ubuntu, available here. I personally recommend not switching on Automatic Updates (this could overwrite a tweaked file that makes everything stop working – believe me, it’s happened to me before when I didn’t carefully check what I was updating!), also, you will want to install the LAMP, Samba and OpenSSH server software when it offers the option. Make sure you have a working network connection on the machine, Ubuntu should pick this up automatically during the installation process.
Personally, I chose to install all of the OS folders into one partition and I haven’t had any problems in over a year, however, the proper way to do it would be to create partitions on the hard drive for each part – there are many guides and posts on the subject, this one here is pretty good and relevant.
Once finished, we’ll move on to setting up Samba file sharing.
Now would be a good time to make sure all of your hard drives are installed – remember that if they are formatted in NTFS they will need to be reformatted. I used this guide here to carry out the operation of partitioning/formatting for all of the media drives I was connecting up (4 in total now, with a total space of 9TB). I gave each of my drives a mount point starting with ‘mediadrive’ followed by the number (mediadrive1, mediadrive2, etc.). So that I can easily copy and paste things to and from the drives using my Windows laptop I configured shares in Samba for each drive.
One thing I would definitely do (from my own experience this works best) is to assign the drives in fstab using their UUID.
Type the following to find out the unique IDs for the media drive partitions you want to automatically mount:
If you’re accessing through a terminal client like PuTTY you’ll be able to copy and paste the output of that command into a text editor, alternatively you may have to use trusty pen and paper to note down the UUID, then type the following at the command line:
Then at the end of the existing file add the following for each drive partition you’re adding (when using blkid you’ll have to figure out which drive partition is which you’re self by the naming convention of sda, sdb, sdc etc.)
# useful comment to remind you what drive is what goes here
UUID=xxxxxxxxxxxx-xxxxxx-xxxxx-xxxx /var/whatever ext3 noatime 0 2
The great thing about using this method is that you can use the hard drive in USB or connected in SATA and it will still have the same UUID. The partitions will never swap places either (which happened to me before with a WD drive) and everything remains rock solid. I ran drives via USB2.0 like this with no problems for over a year, and they mounted just like an internal drive.
Do the Samba!
Samba is a network file sharing service, which is cross platform and mimics Windows file sharing in a few ways. It’s a great piece of software with massive amounts of options for all sorts of different things (this can actually be the problem when configuring it as there are so many choices). As a template, I used an old guide on the internet which is slightly out of date now on www.bit-tech.net – the guide is here.
Samba should have installed with Ubuntu if you have everything done right, but if not, then at the command line type in the following:
sudo apt-get install samba
Hit ‘y’ to accept the download and use of space and then it should install.
To write a Shell script for adding users, type the following at the command line:
sudo nano adduser.sh
Here is an example Shell script you can use to add new users to the server (I only used this 3 times, one for a public user for friends to copy stuff when connected to my network and 2 secure users for me and Gina). To make a shell script from the command line, type the following:
# Useradd script written by Andrew Hardy
echo -n "Username: "
useradd -d /var/mediadrive1/$username -m -s /bin/bash $username
smbpasswd -a $username
To run the script to add a new user, type the following:
sudo sh adduser.sh
Follow the prompts and the new user should be added to the Unix users and Samba user database (smbpasswd).
The next thing to do is to configure the file shares in Samba, type in the following:
sudo nano /etc/samba/smb.conf
Here’s an example taken from my Samba configuration file (smb.conf):
panic action = /usr/share/samba/panic-action %d
workgroup = workgroup_name
netbios name = name_of_machine
server string = Whatever You Want
invalid users = root
security = user
wins support = no
hide files = no
strict locking = no
log file = /var/log/samba.log
log level = 2
max log size = 1000
syslog = 1
deadtime = 15
encrypt passwords = true
passdb backend = tdbsam
socket options = TCP_NODELAY IPTOS_LOWDELAY SO_KEEPALIVE
dns proxy = no
passwd program = /usr/bin/passwd %u
passwd chat =*EntersnewsUNIXspassword:* %nn *RetypesnewsUNIXspassword:* %nn .
obey pam restrictions = yes
pam password change = no
null passwords = no
unix password sync = yes
map to guest = bad user
security mask = 0770
writeable = yes
admin users = user
path = /var/media
comment = Media drive 1
valid users = user
create mode = 0770
public = yes
browsable = yes
Hit ‘Ctrl and X’ and hit ‘Y’ to save the file.
Now you need to restart Samba, so type the following:
sudo service smbd restart
This restarts the Samba Daemon (hence smbd) and applies the changes made in the configuration file.
To test whether this has worked or not, try mapping the file share using your OS network drive mapping options, using the following server path:
The username and password should be the same as those added using the new user script – fingers crossed this works, if not, then go through the smb.conf file using nano to see if there are any obvious mistakes!
Make administration easy with Webmin
Webmin is a great tool and one that I use a lot for administering my home media server, as well as in serious production environments. It allows a headless machine to have nearly all of the core functions carried out with a web-based graphical interface. Great for noobs like me who are getting to grips with the command line (although I find more and more of my work is being done from the cli now, Webmin is a great fallback).
Visit Webmin’s download page for debian packages and follow the instructions on that page for installing on Ubuntu, the main command line stuff being:
dpkg --install webmin_1.630_all.deb
It probably will complain about missing dependencies, so you should use the following to install those then repeat the last line after that has completed:
apt-get install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl apt-show-versions python
Once installed, you should be able to visit your servers webmin site by typing the following into your browser address bar (as long as you’re connected to the same network!):
From here, you can move files, create users, install software, apply updates etc. Basically, you can do all of the things you need to do in an Operating System from here, and if not, then you can fall back to the command line for the more complicated stuff!
At this point you will be able to do the work from a seperate machine on the same network, so the thing to do now would be to install PuTTY on your normal work computer, it can be found for download here.
Once open, add your Ubuntu box server address and use the standard port of 22. A command line prompt should appear in the window, use your login details to connect to your machine. You can now work from the command line as you did before using it directly.
We are going to need to extract zip files in a little while, so make sure you install ‘Unzip’ by typing the following in the command line:
sudo apt-get install unzip
Serviio itself is pretty easy to install, installing the pre-requisite codec libraries and software isn’t so easy. This part of the guide should really be followed to the letter to get it to work properly.
Use the following website guide for the YASM part ONLY! The rest of the ffmpeg stuff will be done using the guide on Serviio’s wiki:
Use the following website guide for the FFMPEG part – please try and install everything as stated so that you get the best viewing experience with Serviio! All of this software should be extracted and installed in the /opt folder (as in ‘Optional’ software):
Serviio uses the default Java Runtime Environment (I believe it’s version 6) , to install it, use the following command:
sudo apt-get install default-jre
Finally we get to the installation of the good stuff! I use version 1.0.1 purely because it’s stable and I’ve got it to work nicely with the PHP Web Interface, but you may want to try newer versions with the newer web interfaces so that you get the added features they provide (the online content handling is much improved from what I can see in the screenshots). I prefer stability though, so using my guide you should get it working nicely:
Download Serviio 1.3.1 – I recently had problems with 1.0.1 which caused me some headaches, but upgrading to the new version has solved pretty much all of them!
Make sure you move the file to the folder where you want it installed then use the following command to extract the folder:
tar -xvzf serviio-1.3.1-linux.tar.gz
Once that’s done, one of the main points to note in the installation guide is to create the script for starting the Serviio service when networking of the computer starts. Making the script is a pretty much foolproof way of getting this to work and I’ve had no problems with it ever since. If you don’t do this, every time you restart your server you will have to manually start the service using PuTTY or similar (i.e. a big pain the rear end). Create a file called ‘serviio.conf’ in the folder /etc/init/ – the file should read as follows:
start on started networking script /<path-to-serviio>/serviio.sh end script
That’s pretty much it for the Serviio installation, you will need to remember the location of the installation to tell the Web Interface where it’s located.
As my server is headless, I mainly control Serviio by pointing the Windows based console on my laptop to the server, or by means of a web interface. Enthusiastic devleopers have made third party software to interface with Serviio, which allows you to make changes to Serviio remotely. I use the WebUI in PHP. There is a guide on how to install it available here. Then install the PHP Web UI (easiest one to install) – using this wiki here. For this guide I use WebUI for Serviio-1.3 – this has removed a few bugs with earlier versions and now includes the rather excellent option to add online sources from ServiiDB
Basically, it’s a case of downloading the file, extracting it into your server’s apache website folder (/var/www) and then rename the folder to something you’ll remember (I use /var/www/serviioweb). To then access this webpage on your network, type in the following:
If your web browser tries to download an XML or PHP file, then make sure you have PHP5-XMLRPC and PHP5-CURL installed, type in the following:
sudo apt-get install php5-xmlrpc
sudo apt-get install php5-curl
Once you get this working, you should go through all of the options and add media drives (remember the ones you mapped in Samba?) and then test it out on your DLNA media player connected to the same network.
ServiiDroid – Control Serviio from your Android Smartphone
Having got my first ‘proper’ smartphone (a Lenovo A706 – a quad core Android smartphone for £120 in Thailand – I’ll write a long term review in the near future) I’ve started trying out all sorts of apps. One of the best apps out of all of them has to be ServiiDroid. As long as you have the connection settings set for your box right, it works, and not just some of it, but all of it. Hats off to the guys that made it – it’s really good. I can now control Serviio, refresh the library, add sources (even from ServiiDB) without having to get the laptop out.
It’s also free, which is always the best price!
I’ve had some issues after a recent update to Ubuntu which caused Transmission to break – and nothing I could do seemed to fix it. Couple that big problem with the fact that binding it to a VPN interface (tun00 etc.) meant I’ve now swapped over to using Deluge.
Linux Home Server Guide has a rather excellent post on how to set up a home server with Deluge, available here, which should help get you started. The initial configuration file is the hardest part, but if you can use a template you can always modify it to match your own preferences. The great thing is that, once running and connectable, you can make changes to the settings all from within the web interface. No more head scratching over whether the syntax for a variable is correct for us linux-noobs!
There are various Android apps to connect to Deluge as well, but I’m still in the ‘testing’ stage of these at the moment, so I can’t really say which one is best.
Extend Serviio with Plugins
You can find all sorts of plugins for Serviio on the forums – http://forum.serviio.org. Download them and then add them to your Serviio server using the Webmin upload feature (browse to serviio install folder, go to plugins and then upload the .groovy files from the Serviio forum here: http://forum.serviio.org/viewtopic.php?f=20&t=3820 ). Once installed, you’ll have to restart the serviio service. From the command line this would be a simple case of:
sudo service serviio restart
Sources can take a while to populate, so give it a few minutes (maybe more if you’re running on a slow connection and/or CPU or you’ve got a huge load of playlists to populate) and you should be away. I’ve found that different DLNA players work with varying levels of success. Overall, Samsungs tend to beat everything else hands down, we have a 22″ full HD Samsung in the bedroom now which handles everything thrown at it, especially in comparison to the slightly cranky Sony Bravia KDL42W653 we have in the living room (42″ – beautiful TV, but the Smart TV/DLNA part is just off the mark compared to the Sammys).
Well, this has been a bit of a beast of a guide to write, and I’m sure it’s a bit of a beast to read, but I do hope it helps people get a bit closer to having a home entertainment system that will see them right for a good few years!
The next step now will be to write a guide on getting access to your home media server from across the internet – I’ll need some assistance from people with regards to the correct way to go about security (particularly writing htaccess files to protect web programs amongst other things like SSH tunneling) – I’ll connect this post with a link when I’ve found the time to finish writing it!
Please leave any comments or queries you have about what I’ve written in this guide at the bottom of this post!