pi home server

Upload: khedotglorya

Post on 06-Jul-2018

229 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/17/2019 Pi Home Server

    1/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 microSDcard (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 runlsblk command,

    which will give you the device node for your card. It should besomething 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

    http://www.itworld.com/resourceshttp://resources.itworld.com/ccd/assets/95831/detailhttp://resources.itworld.com/ccd/assets/95831/detailhttp://www.itworld.com/resources

  • 8/17/2019 Pi Home Server

    2/16

    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 tooptimize the OS for the device. Just follow the instructions.

    Step 1, 2 are important so don’t 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 .

    If (and only if) you don't have a monitor and keyboard tospare, 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 thenssh into the Pi. You may need to

    install openssh packages on your main PC:

    ssh pi@IP_ADDR!!

    Example:

    ssh pi@"#.#.#.""#

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

    thesudo raspi$%onfig 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

    http://resources.itworld.com/ccd/assets/95804/detailhttp://www.itworld.com/resourceshttp://resources.itworld.com/ccd/assets/95804/detailhttp://www.itworld.com/resources

  • 8/17/2019 Pi Home Server

    3/16

    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

    http://www.itworld.com/article/3005754/ipad/ipad-buying-guide-how-to-choose-an-ipad-pro-ipad-air-or-ipad-mini.htmlhttp://www.itworld.com/article/3000673/holiday/how-to-buy-the-best-productivity-focused-android-ios-or-windows-tablet.htmlhttp://www.itworld.com/article/2994231/holiday/10-truly-classy-tech-gifts-for-50-or-less.htmlhttp://www.itworld.com/article/3005754/ipad/ipad-buying-guide-how-to-choose-an-ipad-pro-ipad-air-or-ipad-mini.htmlhttp://www.itworld.com/article/3000673/holiday/how-to-buy-the-best-productivity-focused-android-ios-or-windows-tablet.htmlhttp://www.itworld.com/article/2994231/holiday/10-truly-classy-tech-gifts-for-50-or-less.html

  • 8/17/2019 Pi Home Server

    4/16

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

    sudo apt$get insta&& samba samba$%ommon samba$%ommon$bin

    Then add the user 'pi' to samba group:

    sudo smbpass'd $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 installntfs-3g packages.

    Connect the hard drive and find the UUID of the partition

    where your data is stored:

    b&(id

    It will give you an output similar to this:

    pi@s'api ) * b&(id

    /dev/mm%b&(#p"+ !,_-P=msdos 0A10=boot

    22ID="4#A$"413 -P=vfat

    /dev/mm%b&(#p+ 22ID=f4a4545$f4b$4%ad$a36#$a"76859#35e% -P=e:t4

    /dev/sda"+ 0A10=;I 22ID=837$"3D -P=vfat

    /dev/sda+ 0A10=M

  • 8/17/2019 Pi Home Server

    5/16

    Now we have to mount the partition with proper permissions.

    sudo mount $t ntfs$7g $o uid="###gid="###umas(=##3/dev/sda" /media/storage

    In the above command replace 'ntfs-3g' with the format of yourpartition and and 'storage' with your mount point.

    All we have to do now is add the mount point tofstab so the

    drive auto mounts between reboots. Open the fstab file:

    sudo nano /et%/fstab

    Then add the following lines at the end:

    22ID=#A,4D8#3,4D9;947 /media/storage ntfs$7g

    uid="###gid="###umas(=##3 # #

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

    UUID’s 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 /et%/samba/smb.%onf

    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? -he name of the shared dire%tor<path = /media/storage/movies -he path of the shareddire%tor<read on&< = o nsures that itBs not read on&<bro'sab&e =

  • 8/17/2019 Pi Home Server

    6/16

    Now restart the Samba server:

    sudo servi%e 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 theE 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, andpassword when asked. If you are on Mac OS X, then go

    toFinder > 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 onhow 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)

    http://www.itworld.com/article/2896576/how-to-install-android-apps-on-amazon-fire-tv-stick-and-turn-it-into-a-media-center.htmlhttp://www.itworld.com/article/2896576/how-to-install-android-apps-on-amazon-fire-tv-stick-and-turn-it-into-a-media-center.htmlhttp://www.itworld.com/article/2852683/amazon-fire-tv-stick-vs-chromecast-which-should-you-buy.htmlhttp://www.itworld.com/article/2896576/how-to-install-android-apps-on-amazon-fire-tv-stick-and-turn-it-into-a-media-center.htmlhttp://www.itworld.com/article/2896576/how-to-install-android-apps-on-amazon-fire-tv-stick-and-turn-it-into-a-media-center.htmlhttp://www.itworld.com/article/2852683/amazon-fire-tv-stick-vs-chromecast-which-should-you-buy.html

  • 8/17/2019 Pi Home Server

    7/16

    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 areawith 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 installon 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 doesn’t stop there, you can

    http://kodi.tv/download/http://kodi.tv/download/http://kodi.tv/download/

  • 8/17/2019 Pi Home Server

    8/16

    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.

  • 8/17/2019 Pi Home Server

    9/16

    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.

  • 8/17/2019 Pi Home Server

    10/16

    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 platform-

    tools' folder.

    First stop the adb server:adb (i&&$server

    Then start itadb start$server

    Now start a connection between the Stick and your PCadb %onne%t IP_ADDR!!_C;_!-I,

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

    established:adb devi%es

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

    Now run the following command to install apps on the stick

    adb insta&& /path_of_(odi.ap(

    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.

    http://www.itworld.com/resourceshttp://www.itworld.com/resources

  • 8/17/2019 Pi Home Server

    11/16

    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 it’s resource hungry for low-

    powered 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 passwordprotect the server and restrict your kids from accessing your

  • 8/17/2019 Pi Home Server

    12/16

    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 installingSamba, 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 EMovies? $G -he name of the shared dire%tor<path = /media/4tb/movies $G -he path of the shareddire%tor<read on&< = o $G nsures that itBs not read on&<bro'sab&e =

  • 8/17/2019 Pi Home Server

    13/16

    'riteab&e =

  • 8/17/2019 Pi Home Server

    14/16

    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.

  • 8/17/2019 Pi Home Server

    15/16

    Give username and password to access the shared directory.

    Click on the ‘OK’ button at the bottom and if that’s 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.

  • 8/17/2019 Pi Home Server

    16/16

    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 FireTV Stick, just add those directories to the samba config file.

    Enjoy your private Netflix!