Raspberry PI – Easy setup a backup NAS server

A little reminder to configure rasperry as NAS server, to backup and access your file everywhere.

How to?
First of all you need an account on www.no-ip.com or a public ip address.

Next, boot your rasperry, go root (or use sudo), and install Samba:

#apt-get install samba samba-common-bin

Open samba config file (/etc/samba/smb.conf) and edit/add these lines:

security = user

# at the end of file, copy/paste the config
[public]
  comment = My Public Store
  path = /home/shared/usbdisk
  valid users = @users
  force group = users
  read only = no
  writeable = yes
  create mask = 0777
  directory mask = 0777
  browseable = yes
  public = yes

In this way you allow the users to login in on your raspy. You need to add a user…

smbpasswd -a pi
# set password, etc...

Save, exit and restart the service

#/etc/init.d/samba restart

Now, create the shared folder (as configured in early in smb.conf), set permissions and mount the usb disk.

## create folders
$cd /home
$mkdir shared
$chown -R root:users /home/shared/
$chmod -R ug=rwx,o=rx /home/shared/
$mkdir usbdisk

## mount disk
#mount /dev/sda1 /home/shared/usbdisk

Next, you need to mound disk at startup. Open /etc/fstab and add this line:

/dev/sda1 /home/shared/usbdisk auto noatime,user,rw,exec 0 0

Note: if you have a NTFS drive, you need install ntfs package

apt-get install ntfs-config
apt-get install ntfs-3g

Well, first part is done.

Now you need to use no-ip service to connect remotely on your rasperry.

I suggest to use a static ip address on your raspy. Setting static ip is easy and it’s explained here.


Install no-ip service

mkdir noip
cd noip/
wget http://www.no-ip.com/client/linux/noip-duc-linux.tar.gz
tar vzxf noip-duc-linux.tar.gz
cd noip-2.1.9-1/
make
make install

Follow instructions, enter your username/password and go on.

After installation, you need to create a noip service (to run on every boot).
Create the file noip in /etc/init.d/noip

vi /etc/init.d/noip

and copy/paste these lines as explained here:

#! /bin/sh
# /etc/init.d/noip
case "$1" in
  start)
    echo "Starting noip"
    /usr/local/bin/noip2
    ;;
  stop)
    echo "Stopping noip"
    killall noip2
    ;;
  *)
    echo "Usage: /etc/init.d/noip {start|stop}"
    exit 1
    ;;
esac
exit 0

Set permission, start, and reboot everything.

chmod 755 /etc/init.d/noip 
/etc/init.d/noip start
#reboot

Connections to rasperry

Open terminal and try:

ssh pi@192.168.0.115       // the raspy static ip
// or
ssh pi@mydyndnsname.no-ip.org  // the no-ip address

you should be able to connect.

If the output is this, you are in!

host-001:~ albertop$ ssh pi@mydyndnsname.no-ip.org
pi@mydyndnsname.no-ip.org's password: 
Linux raspberrypi 3.2.27+ #250 PREEMPT Thu Oct 18 19:03:02 BST 2012 armv6l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Sun Dec  9 13:30:14 2012 from 95.227.126.188

pi@raspberrypi ~ $

If not… i have no idea 😀. Probably you missed something in the way.

One of the common problems could be the port forwarding. Enable to in your router settings the redirect from ssh port and samba ports. (22 for ssh and 137,138,139 for samba. TCP/UDP).
portforward.com could help you.

On Mac OSX, open finder, press CMD+K and type smb://mydyndnsname.no-ip.org.

Login and use your files remotely.
On Windows/Linux is similar, open My PC and select “Connect to server”. Address should be the same.

You can also use FileZillaWinSCP or others sftp client to access your remote shared folder.

Probably i missed something, but you could be able to solve the issue. 🙂
enjoy.


References:
– http://it.wikipedia.org/wiki/Network_Attached_Storage
– http://www.no-ip.com/
– http://compnetworking.about.com/od/workingwithipaddresses/f/what-is-a-public-ip-address.htm
– http://en.wikipedia.org/wiki/Samba_(software)
– http://www.penguintutor.com/blog/viewblog.php?blog=6306
– http://www.stuffaboutcode.com/2012/06/raspberry-pi-run-program-at-start-up.html
– http://portforward.com/
– http://www.google.com

 

[BASH] Create big file (custom) size

This create a 15Mb file. For any use.

[code lang=”bash” autolinks=”false” collapse=”false” firstline=”1″ gutter=”true” htmlscript=”false” light=”false” padlinenumbers=”false” smarttabs=”true” tabsize=”4″ toolbar=”false”]dd if=/dev/random of=BigFile.dat bs=1500000 count=10[/code]

Read More