You are on page 1of 16

What we need

We need some hardware and software to get started. We


need the latest Raspberry Pi 2, a 5V, 2mA charger, a microSD
card (minimum capacity 8GB), external hard drives which will
be used as storage and optional keyboard and an HDMI
monitor (for initial set-up only). We will be using the Pi
headless.
Connect all the hardware and burn the Raspbian image on the
microSD card.

How to install Raspbian


Raspbian is a Debian based distribution optimized for
Raspberry Pi that is powered by an ARMv7 processor.
Download the OS from the official site (Don't download any
software, even if it's open source, from unknown sources).
Extract the .zip file to get an .img file.
Then plug in the SD card to the PC and run lsblk command,
which will give you the device node for your card. It should be
something like /dev/sdX. Instead of X it would be something
like a,b,c,d...in my case it was /dev/sdc. Once you have
determined the device node, run the dd command to convert
and copy the operating system files to the sdcard:
sudo bs=4M dd if=/path_of_raspbian.img of=/dev/sdX

RESOURCES

WHITE PAPER
2015 Mobile Malware Report from Blue Coat Security Labs

VIDEO/WEBCAST
Sponsored

A Guide to Mobile Enterprise Authentication


SEE ALL
Go
One important note: While running the above command, do
not use any number followed by the device node, so it should
not be /dev/sde1, it must be /dev/sde.
Once the image is written to the SD card, plug it into the Pi,
connect the device to the ethernet cable, connect the monitor,
power cable and keyboard and mouse.
Once you boot into Pi, it will throw some instructions to
optimize the OS for the device. Just follow the instructions.
Step 1, 2 are important so dont skip them, the second step
will allow you to create a password for your Pi. If you want to
give a custom name to your Pi (the name that will show up on
your local network) then also click on the step 8 [Advanced
Options] and click on A2 to change the Hostname. You are all
set and just click on <Finish>.
If (and only if) you don't have a monitor and keyboard to
spare, you can manage your Pi from a different PC via ssh. To
do this, first find the IP address of the device from your
modem settings and then ssh into the Pi. You may need to
install openssh packages on your main PC:
ssh pi@IP_ADDRESS

Example:
ssh pi@10.0.0.110

In order to run the Raspbian configuration via ssh, just run


the sudo raspi-config command and you will be greeted by
the configuration window.

Update the OS and install the needed software


By default, the system user is pi and the password is root.
Now update and upgrade the OS so it's secure.
THE HIT LIST


iPad buying guide: How to choose an iPad Pro, iPad Air, or iPad mini

How to buy the best productivity-focused Android, iOS, or Windows tablet

10 truly classy tech gifts for $50 or less


sudo apt-get update
sudo apt-get dist-upgrade

Once your system is fully up-to-date, install samba server


sudo apt-get install samba samba-common samba-commonbin

Then add the user 'pi' to samba group:


sudo smbpasswd -a pi

Mount the external hard drive


Now we need to mount the external hard drive where all your
data is saved. I am assuming that the drive is formatted in
'ext4' format. If the drive is NTFS (which I won't recommend)
then you also need to install ntfs-3g packages.
Connect the hard drive and find the UUID of the partition
where your data is stored:
blkid

It will give you an output similar to this:


pi@swapi ~ $ blkid
/dev/mmcblk0p1: SEC_TYPE="msdos" LABEL="boot"
UUID="140A-14B7" TYPE="vfat"
/dev/mmcblk0p2: UUID="f24a4949-f4b2-4cad-a780a138695079ec" TYPE="ext4"
/dev/sda1: LABEL="EFI" UUID="67E3-17ED" TYPE="vfat"
/dev/sda2: LABEL="MyBook" UUID="94240D3D240D2438"
TYPE="ntfs"

Here sda2 is the partition on the HDD where all my files are.
Now what we need from here is the UUID number. Note it
down.
Now create the mount point:
sudo mkdir /media/storage

Exchange 'storage' with your desired name (it must be short


and in lower-case). Change the permissions of the mount
point:
sudo chmod 770 /media/storage

Now we have to mount the partition with proper permissions.


sudo mount -t ntfs-3g -o uid=1000,gid=1000,umask=007
/dev/sda1 /media/storage

In the above command replace 'ntfs-3g' with the format of your


partition and and 'storage' with your mount point.
All we have to do now is add the mount point to fstab so the
drive auto mounts between reboots. Open the fstab file:
sudo nano /etc/fstab

Then add the following lines at the end:


UUID=0AC4D607C4D5F543 /media/storage ntfs-3g
uid=1000,gid=1000,umask=007 0 0

You have to make three changes in the above code: change


UUIDs number to the one you found for your partition,
exchange storage with the mount point you created and if not
using the NTFS partition, change it to the appropriate file
system. Save and close the file then reboot the system. Your
drive should auto mount now.

Configure Samba server


Now edit the Samba config file to add the partitions that we
want to share over the local network.
sudo nano /etc/samba/smb.conf

At the end of the file add a section for shared directories using
the following pattern. If you have different kinds of data and
you want to restrict access and keep things clean, you can
create different sections for each data type. In my case I have
created different sections for movies, music, pictures and
documents:
[Movies] #The name of the shared directory
path = /media/storage/movies #The path of the shared
directory
read only = No #Ensures that it's not read only
browsable = yes #Ensures that the subfolder of the
directory are browsable
writeable = yes # Ensures that user can write to it
from networked device
valid users = swapnil #The system user

Now restart the Samba server:


sudo service samba restart

You are all set. Now you can access all the files on the
storage drive from any of the devices connected to the same
local network.
If you are on Android, install the E S File Manager from the
Play Store, go to LAN settings and give the ip address,
username and password for the samba server. You have your
files on your Android. You can play videos, listen to music, see
pictures and edit and read documents.
If you are on iOS you can grab any file manager that supports
'Samba' such as FileExplorer. Open the app click on the +
icon and then select the Linux/UNIX, it will show you the
Pi' server in the list. Click on it and choose Registered user,
and then give the samba user and password. All of your files
are there on your iPad.
If you are on Linux (unfortunately each desktop environment
deals with it differently), open the file manager and then go to
the network option. Provide the IP address, username, and
password when asked. If you are on Mac OS X, then go
to Finder > Go > Connect to the server option.
You can also use the current set-up as a media streaming
server. I have earlier written two articles on how to use Samba
as media server, check them out.

Build your own Netflix, Pandora at home without wasting the bandwidth
on watching the same shows over and over again.
I bought an Amazon Fire TV Stick last year, even though I
already had the Google Chromecast. While the Chromecast is
plugged into the TV in the living room, the Fire TV Stick (FTS)

is plugged into the TV in my office - for productivity reasons, of


course.
Both devices have their pros and cons, Amazon certainly has
more channels than Chromecast, however there was one area
with which I struggled: Playing local content.
There can be many solutions to this problem, I am picking a
solution that provides me with more flexibility and control.
The solution lies in a little known secret of Fire TV Stick.
Similar to Android devices, there is a feature that allows users
to install apps from 'unknown' sources. It doesn't require a
super-geek knowledge of Linux.
These are the steps to take in order to extend the features of
the Fire TV Stick:

Get the apps you want to install on FTS.

Enable FTS to install apps from other sources

Install Android tools on PC

Install apk files on FTS

Install Samba

Use Kodi

Get the apps you want to install on Amazon Fire TV Stick


First let's grab the apk files of the apps that we want to install
on Amazon TV stick, just keep in mind not all apps will work
on the device, even if they installed just fine. Here we are
going to install Kodi (formerly XBMC), which will take care of
multi-media needs. Download the latest .apk file for Android
ARM from 'download' page of the official site.
The fact is, you can also install apps like ES File Manager
alongside Kodi, which will make it easier to scan local
networks for multimedia files. It doesnt stop there, you can

also install Firefox and many other such apps on your FTS (I
will cover that in a future post).

Work to be done on Amazon Stick


Go to Amazon Fire menu: Settings > Developer Options and
enable both 'ADB Debugging and 'Apps from unknown
sources' options.

Enter the developer mode of the Amazon Fire TV Stick.

Enable dubugging and installation of apps from unknown sources options.


Then move up to the 'About' section and note the IP address
of the Stick.

Note down the IP address of the Stick.

RESOURCES
Install 'Android tools' on your Linux distribution; it's in the
official repository of every major distro. Now head over to this
Amazon site and download the Android SDK platform-tools. It
should be a zip file, extract the file content, open the
Terminal and change directory to the 'Android SDK platformtools' folder.
First stop the adb server:
adb kill-server

Then start it
adb start-server

Now start a connection between the Stick and your PC


adb connect IP_ADDRESS_OF_STICK

If there is no error message, check if the connection is


established:
adb devices

It should give you the device number. We are almost there.


Now run the following command to install apps on the stick
adb install /path_of_kodi.apk

If the apps successfully installed on your Amazon stick, you


will see the 'success!' output.
Open the Settings option on the Fire TV Stick and go
to Applications > Manage All Installed Apps.
There you will see your newly installed Kodi app.

Kodi installed successfully!


THE HIT LIST

Turn your Linux PC into file and media share server


Our local Netflix or media empire depends on the file
sharing capabilities of our PC. You must have Samba installed
on your Linux box so that we can share the files that we want
to access from the Stick.
Plex could be a potential candidate instead of Samba but it
has its own limitations: I am building a media server using the
newly launched Raspberry Pi 2 and Plex is not yet available
on the ARM platform. Then Plex does all transcoding on the
host machine, which means its resource hungry for lowpowered device. A third problem with Plex is that if you have a
huge amount of media files, it will take forever to scan and
index those files. Every time you add new files you have to run
an index again.
All of these issues are muted with Samba server. One of the
biggest advantages of Samba is that you can password
protect the server and restrict your kids from accessing your

movies. You can easily create a Kids section for their movies
using a new Samba user. On Plex, whatever is added to it is
accessible to everyone.
Every Linux distribution has its own method of installing
Samba, in this article I will talk about Ubuntu and openSUSE.
Install and configure Samba on openSUSE
First install Samba and then add system user to the Samba
group:
sudo
sudo
sudo
sudo

zypper install samba


groupadd smbgroup
usermod -a -G smbgroup name_of_user
smbpasswd -a name_of_user

Install and configure Samba on Ubuntu based systems:


apt-get install samba
sudo smbpasswd -a name_of_user

Share directories (applicable to all Linux distributions)


Edit the smb.conf file and add a section for the directory you
want to share.
nano /etc/samba/smb.conf

You have to add 6 lines at end of the conf file. Follow the
pattern as shown below:
[Movies] -> The name of the shared directory
path = /media/4tb/movies -> The path of the shared
directory
read only = No -> Ensures that it's not read only
browsable = yes -> Ensures that the subfolder of the
directory are browsable
writeable = yes -> Ensures that user can write to it
from networked device
valid users = yourname -> The system user

Below is the section I added to my config file (if you have more
than one directory to share, please create new section for
each directory):
[Movies]
path = /media/4tb/movies
read only = No
browsable = yes

writeable = yes
valid users = swapnil

Now start Samba.


openSUSE
systemctl start smb.service nmb.service
systemctl enable smb.service nmb.service

Ubuntu/Kubuntu:
sudo service nmbd restart
sudo service smbd restart

Now these directories are available on other device connected


to the same local network.

Lets start our media empire


Launch your Fire TV Stick and visit Kodi from Settings >
Applications > Manage all installed applications > Kodi >
Launch Application
There Select the Videos > Files option. Then click on Add
Videos. Select the Browse option and go to Windows
Network (SMB)'.

Select the SMB option from the list.

It will show you the name of shared workgroup (you can


change that name in the smb.conf file), which would be either
WORKGROUP or HOME. Select the group and it will show
you the name of your PC.

Choose your shared work group.


Click on it and there you have: the directory that you shared in
Samba settings. When you select the directory it will ask you
to enter username and password for the Samba server.
Provide it with the username and password we created earlier.
Also select the option 'Remember for this path' so you don't
have to add it again.

Give username and password to access the shared directory.


Click on the OK button at the bottom and if thats the only
directory you want to access, click on the OK button on side
which will bring you to the summary window. If everything
looks fine, click on OK at the bottom.

Summary of the directory added to Kodi.

Now you can simply open the video files stored in that
directory and start 'streaming' it on your Amazon Fire TV
Stick.
You can also stream images, and music to your Amazon Fire
TV Stick, just add those directories to the samba config file.
Enjoy your private Netflix!

You might also like