User Rating: 3 / 5

Star ActiveStar ActiveStar ActiveStar InactiveStar Inactive
 

For a few years now, I've been an avid user of Dropbox. It's incredibly handy that your files are automagically backed up without even thinking about it, en that they're accessible from everywhere. Still, I can easily pull up some reasons why I'd want to leave Dropbox:

  • Price/Storage space: You'll get a free account to Dropbox for 2 GB. You could stretch this a bit by using a referral code and inviting friends in, and end up with an extra 2 or even 4 Gigs of space. Once you start storing digital photographs though, even this kind of storage is filled in no time. A paid subscribtion costs you $99 per year for 100 GB... for 1 single user.
  • Users: ... and this brings to my second issue: $99 per year might be affordable if it really helps you out. But all of the sudden your family consists of you, your spouse and possibly a few children... The total price will be rising.
  • Black Box Software: Je don't know what the software does with your data. How reliable is their service? After the whole Snowden-affair, it appears that Dropbox got a friendly visit from the NSA and was friendly (or maybe not so friendly) asked to give access to their (and consequently your) data. Owncloud - the software used to build your own cloud server - is completely open source. This means you can check the code for malicious code if you would want to. Security services normally won't have access to the tiny server peacefully sitting under your desk.
  • Safety: Any company can go bancrupt. Even though it doesn't look like Dropbox will put down the books pretty soon, smaller competitors will fail every now and then... and with them disappearing, you're backup is gone all of the sudden too. And then it's up to you...
  • Internet traffic: in our current generation with broadband internet, this might not be the biggest argument, but possibly it's key where the internet connection is slow, unreliable or really expensive: sending a huge blob of files to some cloud service, will push a bunch of gigabytes over your intertubes. The traffic will add up to your possible limits (and could in principle also get monitored by all the safety agencies of countries your traffic passes trough).

Using a SkyPi, you'll be deciding how big your cloud will be - you're the one buying a USB-(hard)drive. Connect it to your Pi, and all of the sudden, you've got 2 terabytes of backup space for a one time fee. The data gets backed up inside your LAN, so your data is at no time exposed to the internet (unless you decide otherwise, for example by sharing them with others). Since the Raspberry Pi is really economical, your tiny server will have a very small footprint.

For the sake of honesty, there are a few caveats:

  • Your backup is nog inside your house. Critical backups are best (also) stored off-site!
  • The system isn't very powerful. If multiple users use it at the same time, it gets really slow.
  • Didn't check if the system would be powerful enough to allow strreaming video...
  • If your drive crashes, you loose your backup. Don't forget to regularly check your backup. You could figure out a system to write all data twice (to 2 seperate drives) - ideally it would be a RAID 0 setup. But this is outside the scope of this article.
  • You're responsible for the maintenance of your hardware and software. Do your updates!

If you don't like these caveats, you can always buy a NAS out there (you have have a pretty decent solution for around $500) and combine these with the standard backup software on your system...

Off course you'll then miss out on the satistying experience of figuring stuff out yourself, and getting hands on!

Step 1: connecting the Raspberry Pi

Connections needed during installation (temporarily):

  • HDMI: attach a monitor (if you don't have an HDMI, newer TV's also tend to have this connection)
  • USB: keyboard + external hard drive (or USB-stick)
  • UTP: network/internet connection
  • micro-USB: only used as power supply (and to turn the machine on/off)
  • SD-reader: Raspbian on the card (see step 2)

Final situation:

  • USB: external hard drive (or USB stick)
  • UTP: network/internet connection
  • micro-USB: only used as power supply
  • SD-reader: Rasbian on the card (main OS)

CloudyPi

Step 2: Installing the default software

There are 2 common ways to install Raspbian (Raspberry Pi version of Debian) (http://elinux.org/RPi_Easy_SD_Card_Setup)

  • Use NOOBS (Requires an SD-card of min. 4 GB)
  • There's also the advanced approach by bitcopying an image file to an SD card. This is what I did on my linux machine.

Here are the steps I took:

  1. Put the SD-card in the reader of your computer (not the Raspberry Pi)
  2. We need to figure out how the Linux system adresses the SD-card (device name)
    1. I used gparted for this. In the upper right corner, you'll be able to choose between the different disks (in my case: sda, sdb and sdd)
    2. If this fails, you can open a terminal window, and type "sudo fdisk -l"  (this will give an overview of all your drives and partitions.) You'll see how big every drive is, so it's easy to pick out the right one.
    • jurgen@desktop:~$ sudo fdisk -l

      Disk /dev/sda: 64.0 GB, 64023257088 bytes
      255 heads, 63 sectors/track, 7783 cylinders, total 125045424 sectors
      Units = sectors of 1 * 512 = 512 bytes
      Sector size (logical/physical): 512 bytes / 512 bytes
      I/O size (minimum/optimal): 512 bytes / 512 bytes
      Disk identifier: 0x000ad37d

         Device Boot      Start         End      Blocks   Id  System
      /dev/sda1   *        2048   125044735    62521344   83  Linux

      Disk /dev/sdb: 750.2 GB, 750156374016 bytes
      255 heads, 63 sectors/track, 91201 cylinders, total 1465149168 sectors
      Units = sectors of 1 * 512 = 512 bytes
      Sector size (logical/physical): 512 bytes / 512 bytes
      I/O size (minimum/optimal): 512 bytes / 512 bytes
      Disk identifier: 0x000e5d5f

         Device Boot      Start         End      Blocks   Id  System
      /dev/sdb4   *   523552766  1141062713   308754974    5  Extended
      /dev/sdb5       523552768   539238399     7842816   82  Linux swap / Solaris
      /dev/sdb6       539240448  1141062713   300911133   83  Linux

      Disk /dev/sdd: 2030 MB, 2030043136 bytes
      24 heads, 23 sectors/track, 7182 cylinders, total 3964928 sectors
      Units = sectors of 1 * 512 = 512 bytes
      Sector size (logical/physical): 512 bytes / 512 bytes
      I/O size (minimum/optimal): 512 bytes / 512 bytes
      Disk identifier: 0x00000000

         Device Boot      Start         End      Blocks   Id  System
      /dev/sdd1             251     3964927     1982338+   6  FAT16
      jurgen@desktop:~$
  3. Download the Raspbian image file (http://www.raspberrypi.org/downloads)
  4. Unzip the download (unzip 2013-12-20-wheezy-raspbian.zip)
  5. Now we need to transfer the image file to our SD-card (in my case: /dev/sdd)
  6. Important: prior to removing the SD-card, we'll need to empty the write buffer. Execute the sync command as root.

The /dev/sdX drive entered will be overwritten without notice. Double check that you entered the right value!

sudo dd bs=4M if=2013-12-20-wheezy-raspbian.img of=/dev/sdd
sudo sync

This comand can easily take a few tens of minutes (maybe even half an hour). Now is a good moment to have a bite, grab some coffee, or have a quick look to the rest of my blog :)

Okay... that's done. Now we can put the SD-card in our Raspberry Pi. Let's power up the Raspberry Pi over its micro-USB slot. For this project, my computer could deliver enough power. You're advised to find yourself a real micro-USB power outlet though (maybe some smartphone charger?). Anyway, if you plan to use the setup as a small server, it would make sense to have it up all the time, so an independent power supply sounds pretty reasonable, don't you think?

If all went well, you'll and up with a text console on the display hooked to the Raspberry Pi. The system will probably ask you for a username and login. The default user is "pi" and the default password would be "raspberry" (both all lowercase). Once logged in, raspi-config will power up and offer you some tweaking options. You really need to execute at least the first two:

  1. Expand filesystem - pretty self-explanatory: if the SD-card is bigger than 2 gigs, it will expand so the system can use the whole card
  2. Change User Password - Unless you actually would want other people fooling around with the server, it's not a smart thing to leave this unchanges (especially if you plan on making it accessible through the internet. In this case, a strong password will save you a lof of headaches...

Okay... so now we have a stock Raspberry Pi, waiting for your orders. The next step is to tweak it to become a true Cloud Server! For this, we'll be needing two things: One: plenty of disk space... and Two: A fully configured Owncloud instance.

Before taking off, let's first get rid of that nasty keyboard and display. After all, we're talking servers here, aren't we? Since this little box is running Linux (Debian actually), all the tools are already there to access the machine remotely. We'll be using the approach called SSH (Secure SHell) and it will let us talk to the SkyPi through the IP-address. So it would be handy if the IP-address wouldn't change on every reboot. There's 2 ways to do this:

  1. Use the DHCP-server on your router. On my D-link, I need to access the IP-address of the router (typically 192.168.0.1, but this can differ) and log in with my credentials. Next SETUP >> NETWORK SETTINGS >> ADD DHCP RESERVATION
  2. You could also disable DHCP on your Raspberry Pi, and have it pick it's own IP-address (https://www.modmypi.com/blog/tutorial-how-to-give-your-raspberry-pi-a-static-ip-address)

Personally, I prefer the first approach, because it allows you to manage all your IP addresses from one central location. If assigned the IP 192.168.0.200 to my SkyPi, that's an easy one to remember.

To phone into your SkyPi over SSH, you'll be needing an SSH client.

So in Linux, you'll be typing:

ssh 192.168.0.200 -l pi

The parameter '-l' tells the system you want to log in with the user called 'pi'. Once you entered your new password, you'll see the remote prompt:  pi@skypi ~ $
Whatever you type now, will happen on the Raspberry Pi. The only thing you can't do, is enter the graphic environment (but we don't need that either).

To finalize the last step, let's execute two commands and have are system up to date:

sudo apt-get update
sudo-apt-get upgrade

The first command will update all the lists of applications (and where to find them)
The second command will check all those locations and verify the newest version is on the system. If it's not, it will run the updates.

Step 3: Give your USB-drive a spot on your SkyPi

Okay, so now w're logged into our SkyPi. First thing we need to figure out, is where to find our drives. Actually, we already had to do this once before, so we already know the command for that:

pi@skypi ~ $ sudo fdisk -l

Disk /dev/mmcblk0: 7963 MB, 7963934720 bytes
4 heads, 16 sectors/track, 243040 cylinders, total 15554560 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000c4661

        Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1            8192      122879       57344    c  W95 FAT32 (LBA)
/dev/mmcblk0p2          122880    15554559     7715840   83  Linux

Disk /dev/sda: 2000.4 GB, 2000396746752 bytes
255 heads, 63 sectors/track, 243201 cylinders, total 3907024896 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0007139e

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048  3907024895  1953511424   83  Linux

/dev/mmcblk0 is the SD-card running Raspbian, and it's probably way too small to carry the data we want to backup from our different computers. As you've noticed, there's also an external hard drive there, with a partition of about 2 TB, called /dev/sda1. This will be plenty to store all the data I want to backup. I formatted the drive as a ext4 partition. Only the SkyPi needs direct access, so it's doesn't bother if there are Windows machines in the network. They don't need direct access to the drive.

The next step will be to mount the partition to some sensible location. Following the standards, we'll create a folder under /media. I chose for /media/cloud. These are the steps you'll need te set:

sudo mkdir /media/cloud
sudo mount -t auto /dev/sda1 /media/cloud
(in the assumption that /dev/sda1 is the partition on your external drive)

  • The first command creates a folder with the chosen name (make directory = mkdir)
  • The second command mounts the partition /dev/sda1 to it's logical location /media/cloud

Technically, we could have a look and see if the partition is actually there, and if it shows the contents that were on the hard drive (use your favorite search engine to look up the command ls and cd, or use their man pages)

Once we've verifited that the right partition is mounted to the desired location, we'll make this setting permanent. We'll be adding a line in the fstab file for this (fstab = filesystem table).

sudo nano /etc/fstab

This will show you a simple text editor displaying the settings file. Add the next line:

/dev/sda1   /media/cloud   ext4   defaults   0   0

Meaning:
* /dev/sda1: the linux-adres of your selected drive (actually partition)
* /media/cloud: the logical mounting point you chose
* ext4: the file system used to format the partition. Replace this by vfat if it's a FAT partion and you have reasons not to format it to ext4 (being lazy is as good a reason as any other - the command to format your drrive  /dev/sda1as ext4 is: mkfs.ext4 /dev/sda1)
* defaults 0 0  = don't change this unless you know what you're doing.

Did you add the line? Have a look at the bottom of the screen. You'll be pressing Ctrl-O to store the changes, and Ctrl-X to leave the text editor.

Step 4: Installing OwnCloud

Advanced: By default, this Owncloud install works with SQLite. If you prefer MySQL or Postgres, you'll have to install these prior to running script. I installed MySQL using this quideline. There are tutorials on how to get PostgreSQL running with nginx, but I didn't try these.

Installing Owncloud is pretty complicated. There's quite a few steps you need to consider:

  • You'll have to install a web server
  • You'll have to create a certificate to allow an secure SSL-conection (think https:// instead of http://)
  • Extra dependencies need to be installed, settings have to be tweaked.
  • Some settings on the Raspberry Pi can be optimised (f.e. decrease reserved graphics memory, perform a slight overclock action, ...)

Luckily, all this heavy labor has already been done and automated for us, and in such a way that we can look into the command code and learn from it ourselves. A great kudos goes to Florian, aka PetRockBlog, a Raspberry Pi expert (also the designer of a great game emulator for Raspberry Pi). You can read his bash script here (and suggest improvements, fully in the spirit of open source): https://github.com/petrockblog/OwncloudPie

Now it's only a matter of following the steps Florian gives:

First things first, you'll need to get the nifty script on your little server. We'll need to install a few extra programs to be able achieve this:

sudo apt-get install git dialog                         # install  git & dialog
cd                                                      # return to the home folder (/home/pi)
git clone git://github.com/petrockblog/OwncloudPie.git  # suck in the newest version of the script

This command created a new folder called OwnCloudPie. Let's enter the folder, and start the action...

cd OwncloudPie                                # Enter the folder "OwncloudPie"
chmod +x owncloudpie_setup.sh                 # Flag the script as executable (X = executable)
sudo ./owncloudpie_setup.sh                   # Execute the command (as root: sudo)

Now you'll see a menu showing several options. Whatever you do, you'll need to start with the first option: give a name to your server.

Now you'll see a menu showing several options. Whatever you do, you'll need to start with the first option: give a name to your server. If you're using a Dynamic DNS service, you can enter the URL the service offers... or just any made up name. If you're machine is only accessible inside your LAN, you could just as well enter your IP-address here.

I chose to use nginx as my web server. As much as I love Apache for all its features and power, in my little Raspberry Pi box, it's just a tiny bit too power hungry. As I can use all the speed I can get, I'm going for the lighter server. I can image Apache would be your server of choice though. Nobody's stopping you...

Next, the script will execute a whole plethora of commands (you could examine them in depth in the source code: https://github.com/petrockblog/OwncloudPie/blob/master/owncloudpie_setup.sh) and every now and then, you'll be asked to enter one or a few questions. Enter the same value for the qualified domain name as you used previously (Dynamic DNS, made up name, IP-address).

When the script is done, I just did a reboot for my peace of mind...

sudo reboot

Pretty quickly, you'll be kicked out of your SSH-session. A few minutes later, your server will be alive and kicking again. All that's left now, is to configure the system...

Step 5: Configuring Owncloud

Configuring your little SkyPi box is pretty simple. You can access the machine through a browser, by surfing to the IP-address of the SkyPi, and then head to the subfolder /owncloud:

https://192.168.0.200/owncloud

Notice: Possibly, you'll get warnings that WebDAV isn't working. Unless you know what webDAV is, and actually need it, don't worry about this. The server works just fine.

Probably you'll be recieving a big warning that you're probably visiting an unreliable site... the reason is that you're using a self-signed SSL-certificate (and not some paid-for certificate certitied by some authoriy).

Nitty Gritty: You might be wondering why an SSL-certificate is needed, if it doesn't guarantee you to be who you are after all. Well, an SSL-connection takes care of 2 issues: (1) authentication and (2) encryption. While the value of this authentication might be close to zero, this SSL-connection creates an encrypted connection between your computer and the SkyPi, preventing others to sniff on your network. With a regular HTTP-connection, that's not all that hard.

You'll be asked to enter a username and password (this will become your administrator account, choose whatever your like) but don't forget to also click open the advanced settings! Here, you'll be able to enter the location for your data storage (remember... we made it something like /media/cloud), otherwise the data will be stored on your SD-card, and things would start clogging pretty quick, I can imagine. If you wanted to use MySQL or ProgreSQL, now is also the moment to enter the account settings needed for that.

Step 6: Installing the client on your computer(s)

Obviously, the power of Owncloud is not in using the website, but in the possibility to synchronise folders between your computer and the SkyPi server without you having to do a thing.

You'll need to install the client dedicated to your operating system - you can find these at http://www.owncloud.org/install

Enter your data here (servername will be something like https://192.168.0.100/owncloud or https://myserver.mydynamicdnsprovider.com/owncloud)

The administrator (the first account you created when running the web client the first time, remember?) will be able to add more users (or administrators) to the backend. This way it's possible to keep the data separated for you, your spouse, children, colleagues, etc...

Step 7: (optional) Be accessible from the internet

Nearly all routers will offer the possibility to perform port forwarding. This allows a router to forward all calls to a certain port to an internal IP address. In this case, we'll be wanting to forward all traffic to port 443 (HTTPS) and possibly port 80 (HTTP) to the IP address of our little server. Possibly you'll have to tell the router it's a TCP-protocol. If you also want to enable external SSH (which I would really not recommend!), you'll have to do the same for port 22.

Quite a few routers also offer ways to connect a dynamic IP-address to some URL. DynDNS is the most famous player in this field, but there are others. NoIP (http://www.noip.com/) for example, will be glad to offer you a free account for 1 IP address.

Both DynDNS and NoIP are US-based though - maybe you would prefer keeping everything under your own control and aren't afraid of getting your hands dirty. Askarel, friend from the hackerspace, wrote DynaName: a great script to allow just that. It's outside the scope of this page, and I didn't try it myself yet. It's running in our hackerspace though. I know he accepts patches, and he's also looking for *BSD-users to try out his script. I'd say: eat your heart out and have a go at it. :)

This way, it becomes possible to share files with others, or to access your data from outside your LAN.

Notice: Some ISP's don't allow you to run your own server on the internet. If this is only for limited personal use, they'll probably tolerate this. If you generate a lot of traffic though, they could send you an extra bill, or they could suspend your account without warning. Be sure to check this before you get in trouble!

Leave your comments

Post comment as a guest

0 / 4096 Character restriction
Your text should be in between 42-4096 characters
Your comments are subjected to administrator's moderation.
terms and condition.
Powered by Komento