Sunday, August 16, 2015

Home Server based on Pi



About one year ago I bought Banana Pi, which at that time, was a  raspberry Pi clone on steroids. At the beginning it had no goal nor purpose - another toy added to the collection. After one year it evolved into a fully functional home server which, to putting it simply, makes my life easier.

It started from OpenMediaVault. The first idea was to use Truecrypt with OMV to create a NAS box for home. Even though this seems to make sense, unfortunately OMV has its drawbacks, for example you can’t use it with a filesystem which wasn't created by OMV. For those of you who do not "speak" IT: it won’t work with truecrypt. As a great tool as OMV is it wasn't able to fulfill my needs. If you are looking for a simple out of the box NAS solution - it is perfect for you.

Even if it sounds unbelievable, installation of truecrypt on the Pi was extreamly easy. Everything is written somewhere in the internet, so excuse me i will omit it here.

In my case logical replacement for OMV was just Samba, my home network is based on windows and Linux machines, and if really there is someone non it here: both Linux and Windows speak Samba, of course Linux speaks more than just one language (Samba), but Windows.. Well that's a different story.

As simple samba installation is, its configuration is always a pain in the a.. .Therefore I’ve installed SWAT for web base samba administration. Unfortunately like always there had to be "but's" all over the place.

First of all mounted truecrypt volume by default is available only for root. There are two ways of doing things: add samba user to root group or play around with mount options in truecrypt. Trust me that’s not an easy thing to do, when most of the documentation is for truecrypt on windows.

I had encrypted NAS which is not easy to buy in store. I was happy (silly not to). The beauty of the solution is, that I can detach the usb drive from the Pi and connect it to a laptop or any other PC.It will work with truecrypt on windows without any problems.

For a while I was using OUYA with Kodi as a media center, because OUYA can "speak" samba. But I've bought Blue ray Home Theater. I found out that up scaling algorithms in the Home Theater can do magic.To put it simple as I can: image quality on it is better than on Kodi (at least installed on OUYA).

Home Theater do not "speak" Samba, there are "hacks" which can be used to fix that, but I prefer clean solutions. Home Theater speaks DLNA. Installation of miniDLNA on Pi is easy and the only thing you have to do is configuration file modifcations. There is no rocket science there. My Home Theater can now speak with NAS box. Perfect!

Few weeks after I found an unused USB DVB-T dongle, and thought it would be nice to test out proof of concept: stream TV out of the Pi. I've tracked down a solution which I could use, TvHeadend. It was already in Linux repository, so the installation was simple, just "apt-get". Done.
The problem here was, how to find the right firmware for the USB dongle. In my case the 5-th worked. TvHeadend configuration wasn't easy nor difficult - youtube will tell you all. Everything worked like a charm.

I had to add DVBS2 to the setup.I bought second hand DVBS2 USB device for $30 and proceed. And yes there were problems.. at the beginning I thought the usb device is damaged, because I could not make it work. Finally, I found the root cause, which was the old version of the TvHeadend. I've downloaded source code and compiled it manually. Version 4.x fixed the issue. At least this one.

A minor issue I faced, is that the version of VLC plug-in must be compatible with TvHeadend version installed on the server. If that does not work, or there is shattering - just update the plug-in. Kodi is able to update it's plug-in’s on its own. If a plug-in on my phone or ouya was newer than the servers I would have to update the server. I can live with it.

Setup was complete, but there was one "small tiny little" problem which is truecrypt performance. Originally the drive connected to Pi was used before on a PC. For the encryption  I've used SHA512 + AES-Twofish which was an overkill for the Pi. To be precise, I was able to achieve write speed of 3,5-4,5 MB/s. For those who download something with speed less than 20MBits/sec, it's fine. I needed it more.

I've recently decrypted and re-encrypted the volume again. Trust me there is no other option like copy the data somewhere and copy it back again. I've changed the encryption algorithm to RIPEMD-160 + AES which  gives me more than 7,5MB/s. It is sufficient for downloading stuff onto the NAS with the speed of 50MBit/sec . I have faster internet than that.

I bought ceramic heat sink for the Pi. I hoped I would be able to push it further than current 1.1Ghz. Unfortunately the heat sink allowed me to achieve.. big nothing. I'm not able to push it even to 1.15Ghz.  I know I'm at the end of the road. I know that the next NAS box will be based on x86, even though Orange Pi offers Quad core and 1Gigabit network. I'm sick of the cables, and small power supplies everywhere.



Overall I'm happy with the result, because I'm able to:

  • - stream TV over internet on PC, or Kodi(to be honest I do not watch TV)
  • - download any media and stream it on any device I have
  • - use encrypted NAS with all of my devices
  • - in future connect to it printer and it will work

There are things which can be added to the setup, like printer shared with Samba, or ownCloud. Some may ask about OpenVPN? I prefer not to put that on NAS box. Some things are meant to be separated. The NAS BOX no.1 is final.

0 comments:

Post a Comment