Thursday, November 13, 2014

How to setup your Raspberry Pi as NAS

In a previous post I showed a video of my implementation of Boblight on OpenElec.

This post is dedicated to my setup that consists of two Raspberry Pi's:

  1. Running the OpenElec image acting as a streaming device.
  2. Running the Raspbian image image acting a NAS server and a headless Bittorrent client.
Why the two Pi's?
One can't handle all these tasks.

So, we have the first Pi as a streamer and these are the tasks we have for the second one:
  1. NFS (Network File System) server - to share access to the connected hard drives to NFS enabled devices.
  2. Transmission client - headless Bittorrent client to download content directly to the NAS server.
  3. DLNA server - for DLAN enabled devices that will connect directly
  4. NoIp client - I like having access to my NAS server and Bittorrent client when not at home.

Preparing the RPi

Flashing Raspbian image

All you have to do is download the Raspbian image from here. Then follow the instructions here to flash your SD card with the image you downloaded.

Configuring the system

Pop your SD card into the Pi and turn it on (Make sure to plug in your network cable). Start your favorite SSH application (Mine is Putty) and connect to 'raspberrypi'.


The username is 'pi' and the password is 'raspberry' (Write both username and password without the apostrophes).

Once logged in:
We'll begin with updating our system and repositories:
sudo apt-get update
sudo apt-get upgrade
sudo raspi-config
and select "Expand Root Partition to Fill SD Card" and reboot:
sudo reboot
For the next steps log back using SSH and again after every reboot

Mounting Hard Drives and setting up NTFS

To get NTFS support issue this command:
sudo apt-get install ntfs-3g

I usually like to mount my drives under /media/ not for any particular reason, just a habit.
To do so we will need to find the UUID of our drives and place their info and mounting point in the fstab file to auto mount the drives to the same place every time we reboot.

To get your drive's UUID:
sudo blkid /dev/sda1
Notice that your drive may not be sda1. Next we add it to the end of the file fstab
#My mounts
UUID=8C12261112260136 /media/Ohad_HD ntfs-3g defaults,auto,uid=1000,gid=1000,umask=002 0 0

NFS

To install NFS:
sudo apt-get install nfs-kernel-server

To setup a share do (I am sharing my hard drive that is call Ohad_HD):
sudo mkdir -p /export/Ohad_HD
sudo mount --bind /media/Ohad_HD /export/Ohad_HD
To make this bind happen automatically after every reboot we add this line to the fstab file:
/media/Ohad_HD /export/Ohad_HD none bind 0 0
Finally this is my /etc/exports file:
# /etc/exports: the access control list for filesystems which may be exported
#               to NFS clients.  See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes       hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#
# Example for NFSv4:
# /srv/nfs4        gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes  gss/krb5i(rw,sync,no_subtree_check)
#
/export         *(rw,fsid=0,insecure,no_subtree_check,async)
/export/Ohad_HD *(rw,nohide,insecure,no_subtree_check,async)
Here is a video showing how to setup the NFS drive in XBMC (This is my other Raspberry Pi running OpenElec)

Transmission Client

To install Transmission:
sudo apt-get install transmission-daemon
To setup Transmission:
sudo service transmission-daemon stop
sudo adduser pi debian-transmissionsudo nano /etc/init.d/transmission-daemon
Change the USER variable to value to pi
sudo chown pi -R /var/lib/transmission-daemon/info/sudo chown pi -R /etc/transmission-daemon/settings.json
sudo service transmission-daemon start
Next we will change the settings.
sudo nano /etc/transmission-daemon/settings.json
"download-dir": "/media/Ohad_HD/<Where ever you want>",
"incomplete-dir-enabled": false,
"rpc-authentication-required": false
"rpc-whitelist-enabled": false,

Then we reload the service to make our changes take affect
sudo service transmission-daemon reload

DLNA Server

To install the DLNA server:
sudo apt-get install minidlna
After minidlna is installed edit the file /etc/minidlna.conf
Specifically the line media_dir= with your previously mounted hard drives.
After editing the file issue the following command to reload the new configuration:
sudo service minidlna force-reload


Thursday, October 10, 2013

Ambilight system on Rapsberry Pi running OpenELEC

This is a video showing my Ambilight system running on OpenElec on a Raspberry Pi.
It uses my Boblight-DispmanX implementation.

My Boblight-DispmanX code is shared at https://github.com/brooc/boblight-rpi

There is a comprehensive guide explaining how to set this up on your system at http://blog.nadnerb.co.uk/?p=59


How to stream online videos from Chrome to XBMC

Recently I have encountered a problem, where I wanted to stream online media from my browser to XBMC.
I have discovered that this is a fairly easy task to accomplish when the video is from a well known site, such as YouTube, Vimeo, DailyMotion, CollegeHumor, eBaumsWorld, Twitch.TV, SoundCloud or MixCloud. There are a few plugins such as 'Play to XBMC' or 'Send2XBCM' that allow for such streaming.

Here I will guide you through the steps to do this with almost any site.

Step 1:

Install the plugins

You will need to install 2 plugins to accomplish this task:
  1. FVD Video Downloader
  2. PlayIt on XBMC [EDIT] I now use Play to XBMC plugin instead
I am sure that a plugin can be created to accomplish this task in a single plugin, but as of now I could not find one.

The first plugin will find the URL of the video file we want to stream to XBMC.
The second plugin will do the streaming. Make sure to set the correct name or IP address of your XBMC machine in the plugin.

Step 2:

Install the PlayIt addon on XBMC

To be able to stream to XBMC a video we will need to install the PlayIt XBMC addon.
You need to install the aj add-ons XBMC repository on XBMC and then install the PlayIt service.

More detailed instructions can be found here.

[EDIT]
I started using Play to XBMC which works very well and does not require any installation on XBMC.

Step 3:

Stream a video to XBMC

All we need to do now is go to the site of the video we want to watch on XBMC.
Once the video starts playing the 'FVD Video Downloader' icon will turn blue.
Click on the icon and find the video name in the list of found media.
You can now copy the URL of the file being played (probably an mp4 file) into a new tab.
Now click on the PlayIt icon and choose "Play Active URL".
After a few seconds the video should play on XBMC.