Overview of the Raspberry Pi Cluster

Now I have the power supply and built the stacking system I can show off the clusters initial state.

Every Raspberry Pi in the cluster

Here are the 7 initial Pi’s that are to become part of the cluster. Each have been given a codename to designate its position in the cluster. The Raspberry Pi designed “M” will be the initial master Raspberry Pi as this is a Raspberry Pi 1 B+. Nodes 1 to 4 are all Raspberry Pi 1 revision 1.2 (512 MB version). The unlabelled one with the blue SD card is “chewpi” the original Raspberry Pi I have been using. This is again a Raspberry Pi revision 1.2 (512 MB). The final node, Node 5, is an original Raspberry Pi 1 (256 MB) which wont sit in the cluster stack but will be joined eventually.

Shots of casing assembly

Here you can see the master node sitting in its casing. I have decided to mount this one at the top for ease of accessing its USB ports.

Here you can see the modifications to the casing means that I am able to easily stack the older Raspberry Pi’s with the newer ones with the mounting holes. I described how to modify the case in an earlier post.

The open sides of the case should allow for good ventilation as when the Raspberry Pi’s are running they are expected to generate some heat.

Here the final cluster sits in all its glory. In this configuration all the needed ports (power, USB and Ethernet) are accessible out the side of the case. If I want to access some of the GPIO ports I may convert the cluster into several stacks of 2 or 3. However I wont be doing this initially as this suites current my purposes fine.

Encryption using Veracrypt on the Raspberry Pi Cluster

One of the  objectives for the Raspberry Pi cluster is to manage a number of servers including syncing their contents and backing up databases. The data included may contain personal information so they are always backed up to an encrypted drive. This means I need to be able to access the encrypted content on the Raspberry Pi Cluster.

What is Veracrypt?

Veracrypt is a piece of software that allows on the fly encryption. This means that while you are writing to a veracrypt volume the file is immediately encrypted. In addition to this when reading files from a veracrypt volume they are decrypted as they are read.

To encrypt your data, Veracrypt allows encrypting full disk partitions or creating an encrypted file. Both of these act like a partition once opened and provide transparent encryption. The volumes can be protected by a number of methods including passwords and keyfiles.

However on the fly encryption adds additional slowdown when writing or reading data since it must be encrypted/decrypted first. For systems that support this at the hardware layer this slowdown can be very minor.

Veracrypt is based on the popular encryption software Truecrypt that was discontinued on the 28th of May, 2014. A number of improvements have been made to the software since being forked and is my chosen method of full disk encryption.

The Raspberry Pi’s do not appear to have hardware crypto support so it is likely to be slow encrypting files. This is something that I am going to need to be aware of.

Installing Veracrypt on a Raspberry Pi

Veracrypt includes a binary compiled for Raspbian which can be downloaded from their website.

To install the downloaded files you can run:

tar -xf veracrypt-1.19-raspbian-setup.tar.bz2
chmod u+x veracrypt-1.19-setup-console-armv7
sudo ./veracrypt-1.19-setup-console-armv7

The first line uncompressed the file. Once it has been extracted it needs to be made executable by running chmod. Since I only want to run the program on the command line I have made the command line program executable. The final line then runs the installer.

Pressing 1 during the installer will install veracrypt. This will prompt you to read the terms and conditions. Once they have been read q will quit out and then entering yes will accept the terms.

Once this has been done running veracrypt should give a prompt explaining its usage.

However if when running this command you get the below error:

error while loading shared libraries: libwx_baseu-3.0.so.0: cannot open shared object file: No such file or directory

You will need to install libwxbase 3.0 which can be done by running the below command:

sudo apt-get install libwxbase3.0-0

Once this has been done Veracrypt should be ready to use.

I wont be documenting its use in this blog post but once you have an encrypted volume or file you can mount and decrypt it using

veracrypt test_encrypted.veracrypt /mnt/test

Where test_encrypted.veracrypt is the file or volume (e.g. mounting a partition can be done using /dev/sda1) and /mnt/test is the location to mount the encrypted volume. Once it has been mounted you can access the files as normal files.

Now I am able to mount my encrypted drives I can work on setting up backups.

Stacking Raspberry Pi’s

The stackable Raspberry Pi case purchased allows stacking Raspberry Pi B+ and Raspberry Pi 2/3 but I was planning to modify this to stack older Pi’s.

Stacking the Raspberry Pi (256 MB)

The original Raspberry Pi does not have any mounting points. This makes it quite hard to stack using my chosen stacking solution. Therefore for the time being I have chosen not to stack this Raspberry Pi.

Stacking the Raspberry Pi (512 MB)

Mounting holes shown in red

Revision 1.2 of the Raspberry Pi increased the amount of memory to 512 MB and added mounting holes among other changes. These two holes (highlighted above) allow easy mounting of the Pi to a surface. However the product I purchased isn’t designed for these mounting holes.

Newly drilled mounting points shown in red

To mount them to my product I drilled new mounting holes in the acrylic. I used a hole mount guide produced by Raspberry Pi Spy. After printing out the guide I overlaid this on the case and drilled through the mounting guides.

Stacking the Raspberry PI B+, 2, and 3

Mounting holes shown in red

The later Raspberry Pi’s added two additional mounting holes and moved the original two. This made the mounting points more uniform. Since my case has been designed for these mounting holes I didn’t need to add any more.

Final 6 Cluster Stack

Here is an image of the final 6 cluster stack I will be using to start testing the cluster.

This 6 cluster tower is formed of one Raspberry Pi 1 B+ and five Raspberry Pi 1 (512MB version).

By stacking them this allows easier cable management for the power and ethernet cables. It also allows me to reduce their ground footprint to be able to more easily store them.

Next post I will share some images of the cluster with all its cables attached.

RaspberryPiVcgencmd A python library to access Raspberry Pi vcgencmd command

To access some of the lower level aspects of the Raspberry Pi’s config you can use the built in command vcgencmd. This is a useful on the command line but to easily access it in a program you need to parse the output.

I am planning to use this command to store data like the temperature of the Raspberry Pi in python. Therefore to easily access the data I decided to make a small python module to do this.

RaspberryPiVcgencmd Python Module

This python module is a wrapper around the vcgencmd command to allow easy access to some of the internal data of the Raspberry Pi.

To include this module in your git based project you can run

git submodule add https://github.com/chewett/RaspberryPiVcgencmd
git commit

Now I have run the above command the library is installed as a git submodule. This means I can now use it in my python script.

So that I can use the library in my current script I need to import the submodule. To import this module I can add the below import statement to my script.

from RaspberryPiVcgencmd.RaspberryPiVcgencmd import RaspberryPiVcgencmd

This will make the RaspberryPiVcgencmd class available to be used in the current python file. Once I have imported it I can use the library to get the firmware version adding the below to the script.

vcgencmd = RaspberryPiVcgencmd()
print vcgencmd.get_version()

Using the vcgencmd object you can now call any of the functions available in the library.

Full details of what vcgencmd can do is available on elinux.

Current exposed functions

The majority of the useful output from vcgencmd is exposed in the class with the below functions

  • get_cpu_temp – Gets the system temperature of the soc in Celsius or Fahrenheit
  • get_ram_split – Gets the memory split between the gpu and cpu
  • measure_volts – Measures the voltage of various internal components
  • measure_clock – Mesures the clock frequency of various internal components
  • is_codec_available – Returns whether the codec specificed video/audio codec is available on the Raspberry Pi
  • get_version – Gets the version of the firmware installed on the Raspberry Pi
  • set_display_power – Allows turning off/on the video output of the Raspberry Pi

The RaspberryPiVcgencmd module is available on github and is licensed under the MIT licence. If you have any comments, suggestions or improvements you can comment below or raise a github issue.

Building a Raspberry Pi cluster

dsc_0525Today’s blog marks the official start of my Raspberry Pi cluster project. Here I will be documenting the process of assembling, building, and running a small cluster. This blog will include both code snippets,  hardware diagrams and the results of various projects using the cluster.

Aims of the project

The Raspberry Pi cluster will be looking into distributed computing from both a hardware and software perspective. Some of the smaller projects planned include:

  • Youtube playlist syncing and download
  • Dynamic task management and distribution
  • MD5 hash calculators
  • Realtime Reddit thread analysis

But why a Raspberry Pi when it lacks power/ram/etc

Many of the tasks I am planning for the raspberry pi can be run faster and more easily on a single computer. My (5 year old) laptop will have more RAM and processing power than the initial cluster. If I was going for pure power I would run these tasks on a GPU. However the cluster is to experiment with the process of writing and working with a distributed environment.

Part of the reason why I have chosen a raspberry pi is that it is readily available, relatively cheap, and there is a lot of  support for it to run Linux. I am planning on running Raspbian Jessie PIXEL to begin with with the possibility of switching to full on Debian or Fedora later.

First steps to a Raspberry Pi Cluster

Already I have one Raspberry Pi 1 Model B Rev 2 which I am going to start developing software for while I collect the other parts. During this time I will search around for a number of raspberry Pi’s. My preference will be for the older versions so that I may purchase more of them cheaply.

Powering them is going to be an investigative point as I dont want to power them using multiple Raspberry Pi cables as these are costly in larger numbers and will occupy lots of power sockets.

As I am expecting to buy a couple different Raspberry Pi versions I am going to look for Micro SD cards which come with adapters. This is because Raspberry Pi 1 B models take a SD card and later models take a Micro SD card.