Social Icons

Showing posts with label Raspberry Pi. Show all posts
Showing posts with label Raspberry Pi. Show all posts

Install OwnCloud 8 with Nginx and MySql on Raspberry Pi

This article has been long due from our side since OwnCloud 8 has been released, the product is pretty stable and popular now with the latest stable release of version 8.1.1

Like previous iterations, keeping in mind the small footprint and power of Raspberry Pi we would be using following components:
  • Nginx (as Webserver instead of Apache, as it would be faster)
  • MySql
  • Php 5
So without much ado, let get straight into Business...

Step 1.
Update the repositories
sudo apt-get update

Step 2.
Install MySql
sudo apt-get install mysql-server

Enter a password for root account when prompted, and do remember it :)














Step 3.
Let's now configure the mysql so that it runs better on our tiny resource tight Raspberry Pi
Backup existing config
sudo mv /etc/mysql/my.cnf /etc/mysql/my.cnf.bak

Use a suitable config for Raspberry Pi
sudo cp /usr/share/doc/mysql-server-5.5/examples/my-small.cnf /etc/mysql/my.cnf

Edit the config file
sudo nano /etc/mysql/my.cnf

Find the [mysqld] section of the file and place the following line in it:
query_cache_size = 8M

Step 4.
Now we will connect to the database and created required db objects and users
mysql -u root -p

Execute the following at MySql prompt (change the fields in red as per your setup)
CREATE DATABASE owncloud;
CREATE USER techjawab@localhost IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON owncloud.* TO techjawab@localhost;
FLUSH PRIVILEGES;
exit;


Step 5.
Install Php5 and related libraries
sudo apt-get install php5-mysql openssl ssl-cert php5-cli php5-common php5-cgi php-pear php-apc curl libapr1 libtool php5-curl libcurl4-openssl-dev php-xml-parser php5-dev php5-gd memcached php5-memcache

Step 6.
Install Nginx
sudo apt-get install php5-fpm nginx

Step 7.
Install and configure OwnCloud
Create directories required for owncloud
sudo mkdir -p /var/www/owncloud
cd /var/www/


Download OwnCloud and set permissions
sudo wget https://download.owncloud.org/community/owncloud-8.1.1.tar.bz2
sudo tar -xvf owncloud-8.1.1.tar.bz2
sudo chown -R www-data:www-data /var/www


Create SSL certificates for https connection
sudo mkdir -p /etc/nginx/ssl
sudo openssl req -x509 -nodes -days 36500 -newkey rsa:2048 -keyout /etc/nginx/ssl/owncloud.key -out /etc/nginx/ssl/owncloud.crt

Configure owncloud
Edit the below file and copy - paste the config given below
Note:  Remember to edit your domain name or ip under "server_name" field both for http and https
sudo nano /etc/nginx/sites-available/owncloud



Enabling owncloud settings
sudo ln -s /etc/nginx/sites-available/owncloud /etc/nginx/sites-enabled/owncloud
sudo unlink /etc/nginx/sites-enabled/default


Configure Php FastCGI Process Manager
sudo nano /etc/php5/fpm/php.ini


Set the following values accordingly in the config file, change value for upload directory according to your setup

default_charset = "UTF-8"
upload_max_filesize = 10G
post_max_size = 10G
upload_tmp_dir = /mnt/usbstorage/owncloud/tmp
max_input_time = 360000
#The maximum time in seconds a script is allowed to parse input data.
max_execution_time = 360000
memory_limit = 512M
extension=memcached.so
extension=memcache.so


Restart the services
sudo service nginx restart
sudo service php5-fpm restart


Create directories for owncloud on your mounted external storage
sudo mkdir -p /media/NASDRIVE/owncloud
sudo chown -R www-data:www-data /media/NASDRIVE/owncloud


sudo mkdir -p /media/NASDRIVE/owncloud/tmp
sudo chown -R www-data:www-data /media/NASDRIVE/owncloud/tmp


Step 8.
Open Browser and browse to your domain name or ip address


You would need to setup the following:
  • setup admin username / password
  • Provide the owncloud storage path created above
  • Provide database name, username and password created in step 4, and click "Finish setup"













Viola, you have your "own"cloud up and running now...



Install MiniDLNA on Raspberry Pi



*These steps works both on Raspbian Wheezy & Jessie*

Install MiniDLNA
sudo apt-get update
sudo apt-get install minidlna


Open and edit MiniDLNA's configuration file
sudo vi /etc/minidlna.conf

Configure your media directory
media_dir=V,/media/NASDRIVE/Movies

Note:
Adding "V," as prefix to the path will restrict the media dir to video content type.
Similarly, "A," for Audio and "P," for pictures respectively.

Set a name for your DLNA servers, this will show up on clients
friendly_name=RasPiDLNA

Set inotify to yes to let MiniDLNA automatically pick up file / media changes
inotify=yes
notify_interval=300 

Un-comment the line
log_dir=/var/log

Add minidlna user to pi group
sudo usermod -a -G pi minidlna

Force Restart MiniDLNA to let it build it's media database
sudo service minidlna force-reload

Check the logs at /var/logs (check if your media library is being indexed)
tail -f  minidlna.log



Viola... Your video collection should soon  show up on your DLNA devices :)

Dynamic DNS the easy way

THIS GUIDE IS NOT VALID ANYMORE SINCE dns4e.com IS NOT AVAILABLE ANYMORE
PLEASE REFER TO OUR OLD GUIDE HERE
In a previous post quite sometime back we explained how to configure a DynDNS service on your Raspberry pi or any similar unix system. This is no different, except for the super easy way of doing the similar thing.

Here we would be using the free DynDNS service of dns4e.com

Step. 1
Goto to https://dns4e.com/registration and sign up

Step. 2
Verify the registered email to activate the service

Step. 3
Add a zone in your account (e.g.: techjawab.dns4e.net)
You can add your own host (which you might have bought separately), in that case you will also need to update the name-servers after this step.

Step. 4
Setup a cron job to update your dynamic ip to dns4e
sudo crontab -e

In the editor add the following line on a new line to update your DNS every 10 minutes
*/10 * * * * curl 'https://api.dns4e.com/v7/<zone address>/a' --user '<Public Key>:<Secret Key>' --data '' -X POST

That's all, you should be able to reach out to your hosted server via the zone address you just configured after the DNS propagates.

Note: If your raspberry pi or unix box is behind a router or firewall then you might have to do port forwarding accordingly to enable the outside world to reach your server.

How to install Transmission on Raspberry Pi (with external storage)


Well there are already many guides on this topic, however, what I found is not all are in complete detail, or misses out on something of the other (completely personal opinion though :) ). Here comes my guide to install Transmission BitTorrent client on headless Raspberry Pi. This will especially be helpful for users who have followed my guides on setting up NAS drive with RasPi.

Let's Start...

Step 1
Install transmission
sudo apt-get update
sudo apt-get install transmission-daemon

Step 2
Create required directories on your NAS storage (path to storage is assumed as /media/NASDRIVE)
mkdir -p /media/NASDRIVE/Torrent_inprogress
mkdir -p /media/NASDRIVE/Torrent_complete

Step 3
Permissions
Transmission by default runs with user "debian-transmission", as it is recommended not to change this due to security reasons. In our setup the NASDRIVE has the permission set as 770 for pi : pi. Thus we will add user "debian-transmission" to "pi" group to give rwx access on our NASDRIVE. You can go ahead and modify this step as per your security requirement, but just make sure your torrent download directories are having rw access for "debian-transmission" user.
sudo usermod -a -G pi debian-transmission

Step 4
Configure Transmission
While most of the parameters are self explanatory in the conf file, you can use the file given below, except for modify the parameters download-dir, incomplete-dir, rpc-username, rpc-password 
Note: rpc-password will automatically converted to hashstring on saving the file
sudo nano /etc/transmission-daemon/settings.json


Step 5
Reload Transmission
Do not restart, It overwrites the configuration file in that case
sudo service transmission-daemon reload

Step 6
Open web browser and hit http://your_raspberry_pi_IP:9091
Enter the user id and password you've configured, and viola!

How to setup ownCloud 7 on Raspberry Pi





This is the second installment of the guide to install ownCloud on Raspberry Pi. Our earlier guide was for ownCloud 5.0.20 (Enterprise Edition) and can be found here.

There has been certain changes with the latest version of ownCloud 7, and this guide should be able to help you to sail through smooth. Without much ado about what is ownCloud (which you already know) let's dive deep into tech details.

Following software / packages we will be using for this setup, ideal for a personal cloud on Raspberry Pi:
  • ownCloud 7
  • Nginx
  • OpenSSL
  • php 5
  • Raspbian Wheezy
1. Tuning up the Raspberry Pi
Following changes needs to be made under Raspberry Pi configuration
sudo raspi-config

a. Expand the root filesystem to have enough space for the cloud
    Select "Expand Filesystem"

b. Change locale to en_US.UTF8
    Select "Internationalisation  Options"

c. Memory split, allocate 16M to video graphics (if you are not using X-server)
    Select "Advanced Options" --> "Memory Split"

d. Overclock to Modest or Medium (Optional Step)
    Select "Overclock" (You might have to reboot if asked)

2. Updating the package lists on Raspberry Pi
  sudo apt-get update
    sudo apt-get upgrade

3. Creating users (Raspbian might already have is user & group)
    sudo groupadd www-data
    sudo usermod -a -G www-data www-data

4. Installing the packages
    sudo apt-get install nginx openssl ssl-cert php5-cli php5-sqlite php5-gd php5-common php5-cgi sqlite3 php-pear php-apc curl libapr1 libtool curl libcurl4-openssl-dev php-xml-parser php5 php5-dev php5-gd php5-fpm memcached php5-memcache varnish


5. Make sure php5-curl is not installed
    sudo apt-get --purge remove php5-curl

6. Creating your SSL certificates for 2 years
    sudo openssl req $@ -new -x509 -days 730 -nodes -out /etc/nginx/cert.pem -keyout /etc/nginx/cert.key

   
sudo chmod 600 /etc/nginx/cert.pem
   
sudo chmod 600 /etc/nginx/cert.key

7. Configuring Ngnix web server
    sudo nano /etc/nginx/sites-available/default

    Copy and replace the entire content below:
    Note: You'll have to replace technet.example.com with the local IP of your Raspberry Pi or the domain name (make sure it matches with the details you have provided to create the certificate, else ownCloud won't work). If you have planned instead to use any Dynamic DNS domain, then use your  domain name instead of the local IP address. You can follow our guide for setting up a Dynamic DNS domain.

8. Configuring max upload limit in php
    sudo nano /etc/php5/fpm/php.ini

    Tip: Use ctrl+w to search below lines and update:
    upload_max_filesize = 1000M
    post_max_size = 1000M

9. Configuring PHP 
    sudo nano /etc/php5/fpm/pool.d/www.conf
    Change the following line from:
    listen = /var/run/php5-fpm.sock
    to 
    listen = 127.0.0.1:9000

    sudo nano /etc/dphys-swapfile
    Change the following line from:
    CONF_SWAPSIZE=100
    to 
    CONF_SWAPSIZE=512

10. Restart web server and Php
    sudo /etc/init.d/php5-fpm restart
    sudo /etc/init.d/nginx restart

11. Install ownCloud (version 7.0.1 used here)
    sudo mkdir -p /var/www/owncloud
    sudo wget https://download.owncloud.org/community/owncloud-7.0.1.tar.bz2
    sudo tar xvf owncloud-7.0.1.tar.bz2
    sudo mv owncloud/ /var/www/
    sudo chown -R www-data:www-data /var/www
    rm -rf owncloud owncloud-7.0.1.tar.bz2

12. Setup admin account
     While setting up the admin account you should provide the path to your data folder. You can ideally set this to your NAS drive or external drive which you may have mounted. Owncloud will complain and not proceed with admin account if the data directory path is not readable & writable by the user www-data. Also it should not be readable by "others". You can refer to our guide here for setting up appropriate permission before proceeding to create the admin account.
     Now in the browser, login to the ip address of Raspberry Pi or if you have configured your domain name then use that and set up the admin account.
    https://yourdomain.com    or    https://192.168.XXX.XX


That's all... Celebrate the fun... Fly high on clouds... and if you liked this guide, got benefited or feel worth reading kindly do share with your network, and share your comments.

How to configure Static IP on Raspbian (Raspberry Pi)

It's a common requirement to have a Static IP address assigned to your Raspberry Pi, as it makes life a lot easier to SSH into a box for which you know the IP address, instead of looking around in your router's pages.

This guide is for Raspbian OS for Raspberry Pi, and also tested on B+ model

Log on into Raspbian onto command line and list the network interfaces currently available:
cat /etc/network/interfaces



Note, eth0 is by default configured as dhcp (dynamic ip address)

We will change this behavior to static.

Before we proceed we need to determine the following information. All of these you can easily determine if you have setup your local network (wifi router/switch/hub/etc..), alternatively if your have your Raspberry Pi connected to LAN (eth0) you can run the following commands to get details:
ifconfig



Now note the following values:
inet addr:192.168.2.2
Bcast:192.168.2.255
Mask:255.255.255.0


Next get the Gateway and Destination address (ideally your router IP addess, or use below command):
netstat -nr

Gateway Address – 192.168.2.1
Destination Address – 192.168.2.1

Now, we will edit config and set the static ip details:
sudo nano /etc/network/interfaces


Change the line that reads:
iface eth0 inet dhcp

to

iface eth0 inet static

Next enter the details that you have collected in previous steps:

address 192.168.2.2                Pi's IP address
netmask 255.255.255.0           Mask address
network 192.168.2.1                Destination address
broadcast 192.168.2.255      Broadcast address
gateway 192.168.2.1          Gateway address



Now reboot your Raspberry Pi, and next check the config once again:
sudo reboot

after reboot
ifconfig


That's all folks!

Install Java SE on Raspberry Pi without complete upgrade


As you must be aware the latest versions of Raspbian OS comes pre-installed with Java VM. However enthusiasts who are already running their Raspbian installation from some prior version and have their perfect environment set might not like the idea of doing a clean install of the Raspbian OS again.

To solve this, there is a simple way to get the latest Java VM installed on your Raspbian without any hassle and start exploring the power of Java on your RasPi.

Step. 1
pi@raspberrypi ~ $ sudo apt-get update

Step. 2
pi@raspberrypi ~ $ sudo apt-get install oracle-java7-jdk
(Note: oracle-java8-jdk is also available)

Verify the installation:
pi@raspberrypi ~ $ java -version
java version "1.7.0_40"
Java(TM) SE Runtime Environment (build 1.7.0_40-b43)
Java HotSpot(TM) Client VM (build 24.0-b56, mixed mode)

You should see the version details of your installed Java VM.

Simple way to update Raspbian OS


If you are wondering about how to update the Raspbian OS which you have probably installed on your SD card months or a year back and already have setup many components or modules on it, here is the answer.

You simply need to run the following commands to safely update your Raspbian OS:

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

That's all... 

Setup BitTorrent Sync on Raspberry Pi

While all the hype is all about cloud storage, Dropbox, Google Drive, or self-hosted OwnCloud, here comes P2P based file syncing tool called BitTorrent® Sync. The main ideology is your data remains yours and just with you, not on any third party server, thus possibly keeping away prying eyes like NSA, ICMS, etc. In our previous article on OwnCloud we have seen how to set up our own cloud storage, and this time its P2P Sync from the makers of BitTorrent. One down-side of self hosted file sharing / syncing system is that it needs to be left turned on always for 24x7 availability. And Raspberry Pi is a perfect choice for this, low power consumption, small size, etc. So let's get straight into business...

Step 1
Download BitTorrent Sync
wget http://download-lb.utorrent.com/endpoint/btsync/os/linux-arm/track/stable/btsync_arm.tar.gz


Step 2 
Unzip & Untar the downloaded file
cd /home/pi
tar -zxvf btsync_arm.tar.gz

Step 3
Start BitTorrent Sync
./btsync

Step 4
Configure Raspberry Pi to start btsync everytime it starts
sudo crontab -e

Add the following line and ctrl+x and confirm to save
@reboot /home/pi/btsync

Step 5
Now just go ahead and point your browser to your Raspberry Pi

http:[Your Raspberry Pi IP]//:8888
e.g.: http://192.188.1.2:8888

Your need to configure the folders you plan to sync with other devices, and login credentials as you wish to choose.

This is far more easier than OwnCloud way, the Android client app for BitTorrent Sync comes for free and have great utility. Go for it...

How to setup your own cloud on Raspberry Pi


With growing concerns of data privacy across the world, one thing is established for sure, if you want to protect your sensitive data then do it yourself, keep it with you, safe and secure. While there is practically nothing invincible, we must try to safeguard our personal data to the extent possible, atleast to make eavesdropper's life tougher in breaking it. This can help you to get rid of using services like Dropbox, Box, Google Drive. I would like to clarify that I do not intend (or mean to intend) that commercial or non-commercial services named above does give away your data, but following this guide can help you to stay away from them at your own risk, the data will be with you at your disposal with the benefits of cloud computing.

Enough talking... Let go ahead and see how we can setup a personal cloud on a small and tiny Raspberry Pi. We would be using the following softwares broadly to setup our own cloud:
  • ownCloud (open-source enterprise grade cloud software)
  • Nginx (open-source, high-performance HTTP server)
  • OpenSSL (open-source tool kit for SSL/TLS)
  • php5 (free of charge, server side scripting language)
  • Raspbian Wheezy from rapberrypi.org (not ownCloud's version)

Important note: This guide was prepared for OwnCloud 5.0.20
The latest version OwnCloud 7 doesn't work well with this guide. 
If you are going to install OwnCloud 7 on Raspbian Wheezy follow here

1. Tuning up the Raspberry Pi
Following changes needs to be made under Raspberry Pi configuration
sudo raspi-config

a. Expand the root filesystem to have enough space for the cloud
    Select "Expand Filesystem"

b. Change locale to en_US.UTF8
    Select "Internationalisation  Options"

c. Memory split, allocate 16M to video graphics (if you are not using X-server)
    Select "Advanced Options" --> "Memory Split"

d. Overclock to Modest or Medium
    Select "Overclock" (You might have to reboot if asked)

2. Updating the package lists on Raspberry Pi
    sudo apt-get update
    sudo apt-get upgrade

3. Creating users
    sudo groupadd www-data
    sudo usermod -a -G www-data www-data

4. Installing the packages
    sudo apt-get install nginx openssl ssl-cert php5-cli php5-sqlite php5-gd php5-curl php5-common php5-cgi sqlite3 php-pear php-apc curl libapr1 libtool curl libcurl4-openssl-dev php-xml-parser php5 php5-dev php5-gd php5-fpm memcached php5-memcache varnish

5. Creating your SSL certificates for 2 years
    sudo openssl req $@ -new -x509 -days 730 -nodes -out /etc/nginx/cert.pem -keyout /etc/nginx/cert.key

   
sudo chmod 600 /etc/nginx/cert.pem
   
sudo chmod 600 /etc/nginx/cert.key

6. Configuring Ngnix web server
    sudo nano /etc/nginx/sites-available/default

    Copy and replace the entire content below:
    Note: You'll have to replace 192.168.XXX.XXX with the local IP of your Raspberry Pi. If you have planned instead to use any Dynamic DNS domain, then use your  domain name instead of the local IP address. You can follow our guide for setting up a Dynamic DNS domain.
   

7. Configuring max upload limit in php
    sudo nano /etc/php5/fpm/php.ini

    Tip: Use ctrl+w to search below lines and update:
    upload_max_filesize = 1000M
    post_max_size = 1000M

    At the end of the file, we'll add also the following:
    upload_tmp_dir = /srv/http/owncloud/data 
    extension = apc.so
    apc.enabled = 1
    apc.include_once_override = 0
    apc.shm_size = 256

    Next, we create the folder with the associated rights
    sudo mkdir -p /srv/http/owncloud/data
    sudo chown www-data:www-data /srv/http/owncloud/data

8. Configuring PHP 
    sudo nano /etc/php5/fpm/pool.d/www.conf
    Change the following line from:
    listen = /var/run/php5-fpm.sock
    to 
    listen = 127.0.0.1:9000

    sudo nano /etc/dphys-swapfile
    Change the following line from:
    CONF_SWAPSIZE=100
    to 
    CONF_SWAPSIZE=512

9. Restart web server and Php
    sudo /etc/init.d/php5-fpm restart
    sudo /etc/init.d/nginx restart

10. Install ownCloud (version 5.0.11 used here)
    sudo mkdir -p /var/www/owncloud
    sudo wget http://download.owncloud.com/download/5.0.11/owncloud_enterprise-5.0.11.tar.bz2
    sudo tar xvf owncloud_enterprise-5.0.11.tar.bz2
    sudo mv owncloud/ /var/www/
    sudo chown -R www-data:www-data /var/www
    rm -rf owncloud owncloud-5.0.7.tar.bz2

11. Setup admin account
    Now in the browser, login to the ip address of Raspberry Pi or if you have configured your domain name then use that and set up the admin account.

12. Linking your external USB hdd as the storage instead of tiny SD card (Optional)
    Ideally one should opt for using an external storage device since the SD card from which Raspberry Pi runs is barely sufficient to handle your cloud storage. You can follow our guide on How to auto-mount USB HDD. Next you need to follow the below steps to create a directory in USB hdd to hold the ownCloud data folder. Note: The mounted path to USB hdd is taken as /media/USBHDD here, change it accordingly.
    sudo service nginx stop
    sudo mkdir /media/USBHDD/OwnCloud5
    sudo chown www-data:www-data /media/USBHDD/OwnCloud5
    sudo mv /var/www/owncloud/data/ /media/USBHDD/OwnCloud5/


    Configure USB directory path in Nginx config.php
    sudo nano /var/www/owncloud/config/config.php

   Change the below line
   'datadirectory' => '/var/www/owncloud/data'
    to
   'datadirectory' => '/media/USBHDD/OwnCloud5/data'

    sudo service nginx start

13. For USB hdd with NTFS filesystem [This step was required for OwnCloud version 5.0.20, later versions probably fixed this and this step won't be required then]
    You might get the following warning on the login page of ownCloud.

Data directory  /media/USBHDD/OwnCloud5/data') is readable for other users. Please change the permissions to 0770 so that the directory cannot be listed by other users.

    To fix this, comment out the section in /var/www/owncloud/lib/util.php which checks for directory permissions.
    sudo nano /var/www/owncloud/lib/util.php

public static function checkDataDirectoryPermissions($dataDirectory) {
...
...
/*
                else {
                        $permissionsModHint = 'Please change the permissions to 0770 so that
the director$
                                .' cannot be listed by other users.';
                        $prems = substr(decoct(@fileperms($dataDirectory)), -3);
                        if (substr($prems, -1) != '0') {
                                OC_Helper::chmodr($dataDirectory, 0770);
                                clearstatcache();
                                $prems = substr(decoct(@fileperms($dataDirectory)), -3);
                                if (substr($prems, 2, 1) != '0') {
                                        $errors[] = array('error' => 'Data directory
('.$dataDirectory.')$
                                                'hint' => $permissionsModHint);
                                }
                        }
                }
*/
                return $errors;
        }

That's all... Celebrate the fun... Fly high on clouds... and if you liked this guide, got benefited or feel worth reading kindly do share with your network.

Setup Dynamic DNS / DynDNS for *FREE* on Raspberry Pi / Ubuntu


Update: You can try our newer and easier guide which uses dns4e.com here

You might have recently setup your Raspberry Pi or your Linux box as a 24 x 7 torrent downloader, or a small Web server to host your own website. And just then you realize that your ADSL or Cable Internet connection has a dynamic IP address which changes frequently and every time you reconnect. Thus, it becomes hard to access your box with a fixed Domain name or IP address.

To solve this problem you can setup a Dynamic DNS which will update your IP to a DNS name everytime it changes and you can access you hosted website, or ssh into it to monitor torrent downloads with ease.

While there are many paid dynamic dns service providers available, but here you will see one way to do it for **FREE** [Thanks to freedns.afraid.org]

Step 1
Register for a Free domain at http://freedns.afraid.org/signup/
[We will take techhome.homenet.org in this guide]

Step 2
Logon to FreeDNS (where you just registered) and goto http://freedns.afraid.org/dynamic/
Or, simply click on "Dynamic DNS" link from the left navigation menu

Right click on "Direct URL" and copy the URL and paste it somewhere.

You should notice a large and unique alpha-numeric key in the URL, make a note of it as shown below:
http://freedns.afraid.org/dynamic/update.php?[alpha-numeric-key]

Step 3
Install inadyn using the following command:
sudo apt-get install inadyn


Step4
Configure inadyn using the below steps:
sudo nano /etc/inadyn.conf

And add the following contains in it replacing the actual values:
--username techhome
--password mypassword
--update_period 3600
--forced_update_period 14400
--alias techhome.homenet.org,alphanumeric key
--background
--dyndns_system default@freedns.afraid.org
--syslog



Step 4
Now, we need to ensure that the DNS updater (Inadyn) runs automatically after every re-boot

export EDITOR=gedit && sudo crontab -e

Add the following line:
@reboot /usr/sbin/inadyn


Step 5
Reboot system and then run the following command to ensure inadyn is running:

ps -A | grep inadyn

Now your host is ready and up for accessing from internet...

You can trying ssh-ing from another computer over the internet
ssh username@techhome.homenet.org

Or, if any web server is running, then simply browse to  http://techhome.homenet.org

Or, you can just ping it to test ping techhome.homenet.org

To check the logs you can use this:
more /var/log/messages |grep INADYN

This has been re-tested to be working perfectly with inadyn 1.96.2-1 on Raspbian 3.12.22+

How to setup mount / auto-mount USB Hard Drive on Raspberry Pi

Follow the simple steps in the order mentioned below to have your USB drive mounted on your Raspberry Pi every time you boot it.

*These steps works both on Raspbian Wheezy & Jessie*

These steps are required especially if your are setting up a Samba share, or a 24x7 torrent downloader, or alike where your Raspberry Pi must have your external storage already mounted and ready for access by the services / daemons.

Step 0.
Plug in your USB HDD / Drive to Raspberry Pi
If you are using a NTFS formatted drive, install the following
sudo apt-get install ntfs-3g

Step 1.
Log on pi using ssh terminal and execute:
ls -l /dev/disk/by-uuid/

You will see something like the following:

lrwxrwxrwx 1 root root 10 Jan  1  1970 0AC4D607C4D5F543 -> ../../sda1
Note down the value of the UUID --> 0AC4D607C4D5F543

Step 2.
Create a location for mount point:
sudo mkdir /media/NASDRIVE

Give proper permission:
sudo chmod 770 /media/NASDRIVE

Step 3.
Get the uid, gid for pi user and group with id command (usually 1000)

Step 4.
Mount the USB Drive and then check if it is accessible at /media/NASDRIVE
sudo mount -t ntfs-3g -o uid=1000,gid=1000,umask=007 /dev/sda1 /media/NASDRIVE

Note:
ntfs-3g for NTFS Drives
vfat for FAT32 Drives
ext4 for ext4 Drives

Step 5.
Now, we will configure RasPi to do this after every reboot:
Take a backup of current fstab and then edit
sudo cp /etc/fstab /etc/fstab.backup
sudo nano /etc/fstab

Add the mount information in the fstab file (replace UUID with your own):
UUID=0AC4D607C4D5F543 /media/NASDRIVE ntfs-3g uid=1000,gid=1000,umask=007 0 0

Step 6.
Reboot
sudo reboot

Step 8. (Optional, required if using as data storage for owncloud)
If you are configuring ownCloud's data directory on your NAS drive, it should be having a 770 permission for www-data user. You can simply add user www-data to pi group, since its already having 770 as permission as set above in fstab.

sudo usermod -a -G pi www-data


How to Setup Samba network share on Raspberry Pi

Raspberry Pi is one of the hottest thing in the tech world today with endless utilities. One of the common use is to set up a NAS (Network Area Storage) server, which you can access over your home netlibpam-smbpasswork (Wired LAN or WiFi).


Assuming your storage drive (USB HDD in this case) is already mounted we will proceed with the steps. If you haven't followed the steps to mount your USB HDD yet then follow my other guide here, and then return to this point.

Step 1.
Install Samba
sudo apt-get install samba samba-common-bin

Update: Install libpam-smbpass (For auto sync of unix user passwords)
sudo apt-get install libpam-smbpass

Step 2.
Backup Samba configuration file, and then configure Samba
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.backup

Edit smb.conf
sudo nano /etc/samba/smb.conf

You can copy over the configurations from the below snippet replacing the path to your mounted USB drive.


Step 3.
Restart Samba
sudo service samba restart

You should be able to access your NAS from any windows / unix system using the following path \\RaspPiNAS

Remember you will require to provide credentials of a valid user as added on Raspberry Pi to be able to access the share. If you want it to behave differently then change the settings for security = user and valid users = @users related parameters.

USB drive not mounted before transmission daemon startup - Raspberry Pi


Many Raspbian users face a common issue of transmission daemon (service) getting started before their USB HDD is auto mounted by the Raspberry Pi or Raspbian where as for some the issue simply doesn't exists.

The issue lies in the auto mount feature with Raspbian Wheezy, which automatically mounts the USB drives when X-mode (GUI mode) is enabled on bootup. Primarily I would suggest to keep that mode disabled unless you are using RasPi with a head (Read: Monitor / Display), as it otherwise unnecessarily wastes system resources. In case you don't want to disable it for your daily use, just disable it for the time being of this fix but running "sudo raspi-config" and selecting appropriate option then rebooting your pi.

Now, lets see the steps to configure the mount point for USB Drive and set it to be done after every reboot automatically.

Step 0.
Make sure the GUI (X-mode) is turned off
Plug in your USB HDD / Drive to RasPi


Step 1.
Log on pi using ssh terminal and execute:
ls -l /dev/disk/by-uuid/

You will see something like the following:

lrwxrwxrwx 1 root root 10 Jan  1  1970 0AC4D607C4D5F543 -> ../../sda1

Note down the value of the UUID --> 0AC4D607C4D5F543

Step 2.
Create a location for mount point:
sudo mkdir /media/NASDRIVE

Give proper permission:
sudo chmod 775 /media/NASDRIVE

Step 3.
Mount the USB Drive and then check if it is accessible at /media/NASDRIVE
sudo mount -t ntfs-3g -o uid=pi,gid=pi /dev/sda1 /media/NASDRIVE

Note:
ntfs-3g for NTFS Drives
vfat for FAT32 Drives
ext4 for ext4 Drives

Also, if ntfs-3g is not installed u might have to install it by:
sudo apt-get install ntfs-3g

Step 4.
Now, we will configure RasPi to do this after every reboot:

Take a backup of current fstab
sudo cp /etc/fstab /etc/fstab.backup

Add the mount information in the fstab file:
UUID=0AC4D607C4D5F543 /media/NASDRIVE ntfs-3g rw,defaults 0 0

Step 5.
Reboot
Turn on the GUI mode by sudo raspi-config, only if required.





You should see your USB drive automatically mounted at /media/NASDRIVE

Now, even your transmission should also be able to get your drive in mounted state while the service starts. 

How to configure inotify to work with MiniDLNA and pickup changes in media_dir

With the advent smart computing devices like ARM processor based Raspberry Pi there has been a significant rise is people setting up their home DLNA Servers for streaming their multimedia collections like movies, videos, pictures directly to their internet enabled or DLNA enabled smart TVs. Even almost all modern Android devices are capable to receiving DLNA streams.

MiniDLNA is one of the very popular DLNA server being used by raspbian users and also by users of Arch Linux and even a large community of Ubuntu users, mainly due to to it's fairly small size and simple ease of use. However there is some issue with MiniDLNA in automatically picking up changes / additions to the media_dir (Media Directory) i.e. more often it doesn't picks up any new file if added to the folder and updates the database which appears on your DLNA renderer like TV.

It generally throws the following warning in the logs:
[2012/10/19 18:35:41] inotify.c:195: warn: WARNING: Inotify max_user_watches [8192] is low or close to the number of used watches [4] and I do not have permission to increase this limit.  Please do so manually by writing a higher value into /proc/sys/fs/inotify/max_user_watches.

While most of the solutions suggests setting up a cron job to rebuild the whole of the database at some specific time but hardly any of them address the fix to real issue or some says that the kernel or OS version doesn't supports the inotify feature. Also I don't like the idea of rebuilding the whole media library database every day or every time a new file is added, as ideally it should just add the new file in the media database  Some of you might have even tried to update /proc/sys/fs/inotify/max_user_watches but probably failed with a error "E667: Fsync failed" at the vi.

Solution:
Edit sysctl.conf (A file for defining kernel parameters)
sudo nano /etc/sysctl.conf

Find and change as below if the following line exists or add at the bottom:
fs.inotify.max_user_watches=65536

Save the file Ctrl + X and Y(es)

Now run the below command, you should be able to see the values you have set:
sudo /sbin/sysctl -p

Finally restart MiniDLNA service and things should be working:
sudo service minidlna restart

Note: Make sure you have inotify enabled and a notify interval is set as per your requirement in /etc/minidlna.conf per the following settings
inotify=yes
notify_interval=300