Showing posts with label raspberrypi. Show all posts
Showing posts with label raspberrypi. Show all posts

Tuesday, September 24, 2013

Energy saving with Raspberry Pi ssh server

I've noticed that after couple days of running my Raspberry Pi server (Raspberry Pi driven Dropbox alternative) I had a problem with connectivity to ssh. Not sure why, but it doesn't really bother me, as I've noticed it only once up to now. Once restarted ssh worked again.

Anyway as I don't need it to be running 24/7 but rather there are couple hours in night, when there is definitely no need to have it up.

Electronic timer switch

As I had a chance to buy electronic timer switch at "Flohmarkt" (in Riem seems to be one of the biggest ones), as it was a good deal I bought 3, where 2 seem to work (still it was worth it). After some googling I've found quite detailed manual (for I guess the British version).

Final setup

I ended up with following:
  • electronic timer switch has been programmed in the way it turns off at 01:00am and goes back on at some time in the morning (depending on weekday or weekend) and
  • cron job has been setup to switch the Raspberry Pi 5 minutes before hard unplug (in my setup are 5 mins enough):
    # m h dom mon dow command
    55 0 * * * /sbin/shutdown -h now
    
That's it. I neither need to worry about hard shutdown (and mess caused to my data) nor about manual startup my ssh server. It's been working fine for couple weeks already for me.

Thursday, August 22, 2013

Raspberry Pi driven Dropbox alternative

As mentioned earlier I bought Raspberry Pi. After some struggles with the board shipping I finally got it almost one month after my order. Components work as expected. I went for official Debian image installation.

Lately there has been quite some publicity about privacy and security on the the public services hosting data. So I decided to minimize the Dropbox usage for file sync and go for locally hosted solution. It doesn't mean I'm out of dropbox, but rather I use it only for things I need to share outside my LAN.

My synchronization requirements

  • two way sync
  • non-interactive sync
  • sync over ssh/local dirs (as pi works with ssh as a server out of the box)
  • support for star topology - PC1..n (laptops) <-> Server (Raspberry Pi)
  • keep additional dependencies to be installed on Raspberry low
  • enable sync within LAN only (as I have quite some restricted internet connection with respect to data transfer quotas)
  • operating on demand, rather than instantly (I want to use pi for other things as well and it's performance is not too impressive)

Alternative synchronization programs

I checked briefly only following:
  • rsync
  • Unison
    • quite well known,
    • but not actively developed any more, still patches seem to be applied from time to time.
  • ownCloud
    • looks actively developed
    • but compared to other 2 - eats more resources (on both sides, client and server)
To me, the unison looks like a winner. So I went for it.

Unison setup from scratch on Pi

I followed these steps:
  1. [on server] changed default raspberry password via:
    passwd
    
  2. [on clients and the server] set up password-less authentication for ssh connection (following the howtoforge tutorial)
  3. [on clients and the server] installed unison:
    • For Fedora:
      sudo yum install unison
      
    • For (X)ubuntu/Debian:
      sudo apt-get install unison
      
  4. [on clients] setup unison with ssh as a synch protocol (following the howtoforge tutorial) with the custom unison preferences file (see next section for reference).
That was basically it.

Custom setup

I created new unison preferences file:
~/.unison/unison.prf 
that has following contents:
# WATCH OUT: keep in sync across clients!

# dirs
root = /home/pb/unison
root = ssh://pi@192.168.2.109//media/My Book/pi/unison

# Work silently
batch = true

auto=true
times = true

# logging
log = true
logfile = /home/pb/.unison/unison.log

# Prevent deletion of all files if all files are locally deleted
confirmbigdeletes = true

# Check fast, don’t compare bit by bit
fastcheck = true # "the default on Unix systems", see docs

# ignore stuff
ignore = Name *~   ## ignores all files with ~ (gedit backup files)
Then I went for one more step. To synchronize via command line I issue following command on my client machines:
unison -ui text unison
To make my life easier, I created in:
~/.bashrc 
alias:
alias u-u="unison -ui text unison"
So that I can simply initiate the synchronization with:
u-u
That's it for my setup. Please note the paths as well as server IP should be adapted in case you'd be using it.

More info/inspiration

For more information, that I got inspired with, see:

Monday, July 8, 2013

Raspberry Pi - my new home server for 70 EUR

I'm quite excited, I just ordered the Raspberry Pi.

But wait, you might ask: Excited to buy single core 700MHz CPU in 2013?
If someone would tell me couple years ago, I wouldn't believe, I guess :)
Nevertheless I see the use case for my small home server running Raspberry Pi.

I'll document what has been achieved, rather than summing up my dreams, so for today, I'll stick with the HW components I went for.

I decided to document my setup as things can vary in:
  • additional components you might need, as well as
  • country/shop you buy at.
The primary intent is to keep things summed up for me. But you might still find the information useful.

Components

The board itself is one thing, however having all the other components required is something different. So after some research I ended up with the following setup:
  • Raspberry Pi board itself
  • USB keyboard + mouse
  • as the previous 2 would occupy both of available USB ports, I need USB HUB
  • SD card
  • USB Wifi adapter - as I need to connect to my Wifi Router and no I don't want any new hole in the wall :)
  • monitor (well this one as well as keyboard and mouse) might won't be plugged permanently, if running as server (ssh should do the job), but still I need it
  • power supply
  • some box?
  • hope I didn't forget anything important :)
OK out of all these I have power supply, keyboard, monitor and mouse already, so let's go for the rest. And box? Lego should do the job for me (if my daughter borrows me some pieces :)

My order

I'm ordering in the Germany, but didn't really compare with other coutries. I've found all the shops for the components I need on the amazon.de with quite OK prices.

For the decision making I followed the rule of:
  • the lowest price as well as 
  • component compatibility and of course
  • shipping costs matter.
Following is my configuration of choice:
  1. Raspberry Pi Mod. B Rev 2.0 (512 MB RAM) 
  2. Transcend SDHC 32GB Class 10 
  3. Mini Highspeed 4-Port USB 2.0 Hub 
  4. TP-Link TL-WN725N Wireless N Nano USB-Adapter 
OK so my very new Raspberry Pi related costs up to now are: 70,23 EUR

Now I just need to be patient till all the components arrive and if all works as expected.
I'll keep you updated.