Hi, and welcome to my instructable!
here I'm gonna show you how to set up your Raspberry Pi to function as a Cloud, you know? Just like Dropbox!
first, lets add a short MoSCoW list:
One thing this PiCloud must definitely have is a good accessibility, you should be able to acces it from every computer in the house.
What this PiCloud should have is a good case to keep it away from dust and protect it.
What the PiCloud could have is accessibility from the net, with this I mean the possibility to acces it from any PC, anywhere.
The function this PiCloud wont have is HUGE storage space, I mean, it's a private server/cloud, why would I want thousands and thousands Gb's?
Now that we've got that list done, lets start with the next, here is all the stuff you're gonna need:
- ABS (you know, the stuff that goes into the 3D printers).
- Triplex (you know, the stuff that goes into the laser cutter).
- Raspberry Pi (in this instructable I'll be using the Pi model B, but any model will do fine).
- A power adapter for the Pi (any phone adapter will work).
- A SD card for your Pi to boot on.
- A monitor (Not for the whole project, just to set some things up).
- A keyboard (Same story as the monitor).
- A mouse (Same story as the monitor and keyboard).
- An Ethernet cable.
- An USB stick or External HDD.
- A laptop, for installation purposes.
We've now got two solid lists of what we want and what we need. let's add the third list, and then we're almost done for this step.
- A Lasercutter, usually found in a fablab.
- A 3D Printer, usually found in a fablab.
- A Dremel tool.
"Yo dawg, I heard you like reading lists, so Imma put a list in your list so you can read lists while you read lists."
In this last list I'd like to put some links to instructables, sites, etc. which I used to create this server.
- Installing Raspbian.
- Thingiverse case Model.
- Thingiverse Hinge model
- MortezaP's turnkey linux setup.
- DrWilson's Pi server.
So, that's it for the lists, let's proceed to step 1.
Step 1: 3D Printing the Case.
Sure, it's all possible to buy a case, it saves lot's of work and time, but you know, they cost money....
So, Let's 3D print a case! This takes a bit longer, but it sure does save you a lot of money.
All you need to do is make or find a template for your model Pi and load it up in a 3D-printer. whenever it's loaded just hit the "print" button and you're set!
I also added two hinges to the case for easy access purposes. I Simply printed them, and then I superglued them in place. After glueing them I found out they were a bit to long, so I used a Dremel to cut off the sharp long edges.
For my model I used the template: Raspberry Pi (Model B) case.
And for the hinges I used: Lift Off Hinge.
Thingiverse is a great site, it's got templates of anything you need 3D-print.
of course it's possible to use another template, or even design your own. but for this project I decided to use this template.
after the printing proces is done, make sure your case is solid and maybe sand it up a bit to smoothen it out.
everything fits and looks okay? Nice! lets proceed to step 2.
Step 2: Lasercutting!
Wow, that sounds spectacular! LASERS!
sorry to let you down, but in fact it's not that interesting, it looks awesome, but it's nothing more than clicking print and you're done.
First I designed the things I need in Adobe illustrator, the parts i needed aren't that hard to design, but it's hard to find a template online, so I went on and made the whole thing myself. What I basically wanted was a rectangular board to mount the case on and than mount that board to the wall. To make it a bit more interesting I decided to add my initials "JvH". I Also added two holes for screws to go through.
You can see my design in the pictures.
As I mentioned before, the designing isn't hard, just make sure the lines are the right color and have the appropriate thickness. After you've got the designing part done, its as easy as 3D Printing, just load it up and click the "print" button.
Lasercutting done? Well done! let's proceed to step 3.
Step 3: Raspbian OS.
Okay, now for the hard stuff.
From now on all we're gonna do is computer magic, programming, installing etc.
First, as mentioned in the title of this step, we're gonna install the OS on the Raspberry Pi.
insert your SD card in your PC and make sure it's formatted in FAT32. then download and install Raspbian on it.
Since there are many many tutorials on how to install Raspbian i'm not going to explain it here, but I will give you the link: Installing OS images.
When you're done installing put your SD card in the Pi and plug it in a power outlet, make sure the red PWR led is on and the green ACT led is blinking/on.
Okay, now your Pi should have an OS on it to work with, let's proceed.
Step 4: Setting Up Turnkey Linux.
Now that you've got Raspbian running it's time to set up Turnkey, which enables lots of server utilities.
Plug in your monitor, mouse, keyboard, SD card and last, your power adapter.
The Pi should now boot like magic and BOOM, there is your OS.
First you'll wanna go to the preferences menu and adjust the next few things (YES, LIST INCOMING):
- Set your timezone.
- Set GPU memory to 16.
- Enable SSH.
- Set a password.
- Boot to CLI on startup.
After you've done that shutdown the Pi and disconnect everything but the SD.
Now your Pi is what they call "Headless", you can acces it without a keyboard, mouse or monitor.
So let's move on and plug your Pi into your router and power it on.
Next up, we're going to ssh to your Pi and install Turnkey.
On my macbook, I opened terminal and typed:
At the "IP-adress" I entered the Ip adress of my Pi.
This should result in a line asking for your password, fill that one in, and Boom! you're in.
Now we'll need root acces, to do that, type:
You'll get asked for a UNIX password, make sure it's a good one!
After that you'll need to logout and ssh into the root account, this is done by:
Now that you should be logged into the root account, let's setup the Turnkey download and installation. It's quite simple, just copy and paste the following commands one by one (YAY! A LIST):
- git clone https://github.com/mortezaPRK/Raspliance-Core /tmp/tkl
- cd /tmp/tkl/
- tklpatch-apply / ./core/
When that's done you've successfully completed step 4! let's proceed.
Step 5: Webmin.
Okay, first a bit of explanation, Webmin is the service to host all of your tools on. It makes sure you'll be able to manage and install stuff like MySQL, OwnCloud, PHP, etc.
To make use of Webmin you'll need to start the service, SSH into your root account and type service webmin start.
Now you can logout and open your web browser. go to "IP-adress":12321. This is the port for Webmin, you should see a login screen. Login with your root account and password.
On the bottom of you're screen there should be something like "Update webmin", hit that link and let it run for a bit.
Whenever it's done, SSH into your root or pi account and reboot the Pi.
Well done! Webmin should now be updated and running! Let's proceed.
Step 6: Storage Space.
Let's add some storage space to our cloud, to do so, shutdown the Pi, add plug in your USB or External HDD and restart it.
Make sure your USB is formated in FAT32 before you're plugging it in.
When your Pi has restarted, head to Webmin (Remember? "IP-adress":12321) and under the tab system click "Disks and Network Filesystems".
In the empty bar type: /media/"Your Drive name", Select the dot "Disk", there should be only one option in the menu. Hit "Create" and you're done!
Step 7: MySQL, Databases, and That Kinda Stuff.
Next up, we're going to setup a database.
This is a simple, yet important, step in setting up your cloud. The database is needed to store your accounts.
Okay, Let's setup MySQL. Go to webmin and click on the unused modules, and then click on MySQL.
There should be something like an install button or link, press that one and you're set. Webmin will begin installing MySQL on your PiCloud.
After the installation you should be in the MySQL Window. Here click the button "Add database". You can name your database whatever you want, I've called mine "OwnCloud". the other options are already on the right settings, so please don't touch them. Wasn't that easy? Next up, we're adding an user to the database. It's almost as easy as creating the database. go to the "User Permissions" tab and hit "Add User". The Username should be "Owncloud", I'll leave the password up to u. Next, you'll need to select all the permissions except for superuser.
Done? Nice, click "Create" and you've successfully added a user.
To make sure the database and the cloud can work together we'll also need to setup PHP. This should be the most easiest thing you've ever done. ssh into your root account, and enter apt-get install php5 php-pear php5-mysql. The Pi now should start installing PHP.
Got everything installed, setup and ready? Nice, It's almost coming to an end now! Let's Proceed.
Step 8: OwnCloud, Your Own Cloud.
Okay, the real deal, your cloud. See those pictures? Awesome ay? Let's make it happen.
Open up webmin, and go to the "System software Packages" (It's in the System dropdown menu).
onee you're there, look at the "Install a new package" section, check the "Package from APT" checkbox and type "owncloud". Smash the install button and it should start the owncloud install.
For OwnCloud to work, we'll need an folder with the corresponding permissions on the harddisk.
ssh into your root account, cd into your harddrive and enter the following commands (Yep, Listman is back!):
- mkdir cloud
- chmod 750 /media/serverhdd/cloud
Once the installation is done, we can head into OwnCloud, you can do this by opening you browser, and typing: "YourIPAdress"/owncloud.
Here you should see a setup screen. Enter a username and password for your admin account, then type the path of your folder in the box, so mine is "//Media/serverhdd/cloud".
Fill in the database data and set the bottom box to "Localhost".
That's it! you now got a OwnCloud admin account.
Now, Let's add another user.
On the top right, click your user and hit "Users". it should take you to the user management page. Here you'll be able to add, delete and manage users. First create a group, I created "Normal Users". After that you'll be able to enter a username and password, select the right group and hit create.
Made an useraccount? well done! let's proceed to the last step!.
Step 9: Finishing Up!
Okay, nice! you've got everything setup.
When I was done with setting up the Raspberry Pi, I put it in the case and mounted it to the wall, after that I connected it to my Router again and booted it. When it booted it should work like a charm, with my cloud being on "IPAdress"/Owncloud, but shit didn't work.
after some research I found out that, of course, I needed to start the webmin service after rebooting. So i ssh'ed into my root account and entered service webmin start. After that things worked like a charm.
From now on, you'll be able to acces your cloud from anywhere in the house by typing your ip / owncloud in any browser. you can even add accounts for your parents, roommates, etc.
Thanks for following this instructable!