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.
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)
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.
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
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.
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
Something I want to do with my Raspberry Pi Cluster is mount a hard drive and share it like a windows share. To do this I am going to set up Samba on a Raspberry Pi.
Installing the required packages
To run samba as a service we need to install a couple packages. Running the following command will install what you need.
sudo apt-get install samba samba-common-bin
To modify samba configuration on a Raspberry Pi you can use its config file. This file is located /etc/samba/smb.conf once you have installed the appropiate packages. To set up samba to be liking I am going to modify and add a couple lines to the base settings.
The workgroup setting defines which workgroup the user you will be logging in as will need. By default the setting is WORKGROUP but this can be changed to anything required. Here im going to change the workgroup to “bunker”.
workgroup = BUNKER #customize the workgroup
To ensure that only logged in users are able to access the shares I have set the security level to “user”. This method of security validates against samba user accounts and is the most basic level.
security = user #ensure security level is user only
The default samba settings will expose the logged in users home directory however it will not be writeable. By changing “read only” to no this will allow editing the users home directory
read only = no #allow writing of home dir
Setting up a share folder
To finally set up the share folder you need to add in the details of the share. Again this is modifying the samba config file as above. Below is an example share folder configuration and an explanation of some of the settings.
comment = Bunker Node1 Share
path = /usr/local/bunker
valid users = @samba
force group = samba
create mask = 0660
directory mask = 0771
read only = no
[BUNKER1] is the name that windows will assign to the folder
comment is used in some programs to describe the share
path is the local path on the Raspberry Pi that the share will be exposing
valid users lists all valid users which can be a single user, or list of usernames. Here I have used “@samba” to allow all users of the group “samba” to access the share
force group will force the accessing user to read files as that group. This can be used to determine what the user can access or do.
create mask is used to apply a bitwise and to the generated permissions. 0660 ensures files are not accessibly by any user, this applies to create files
directory mask works similarly to the above but applies to created directories. Here I am setting it to 0771 to ensure all directories are executable (browsable)
read only sets whether you are only allowed to write/delete the files
Configuring users to access samba
Once you have set up samba with the above settings you need to add a user to be able to access samba. Since I have set my folder to require the samba group I can add it to my user by running
By default Raspbian has no samba group so it needs to be created therefore the first command creates one. The second command then adds the “samba” group to the user account “chewett”. The third command will set the samba password for the same user account. This will let the user chewett access samba.
Now we need to restart samba so that config takes effect.
sudo /etc/init.d/samba restart
Accessing Samba from windows
Now you should be able to access samba from windows by going to \\hostname\ . Here the hostname is bunker-node1 so I access it by going to \\bunker-node1
Once I have entered the hostname and selected a folder will present a login prompt asking for a username and password. If your computer is on the same workgroup as the samba config you will just need to enter the username and password. If they are running on different work groups you will need to enter workgroup\username as the username. In this case I need to enter bunker\chewett as bunker is the workgroup and chewett is the username.
Now I have access to my raspberry pi files on windows. I can expand this by adding more folders to the samba config I can mount external drives and have them accessible on the windows network.
Here I suggest some recommended steps to install Raspbian on top of their install guide.
Choosing an OS for the Raspberry Pi
One of the main ways to install a Raspberry Pi OS is to download a disk image called NOOBS. This lets you choose to easily install a number of different OS’s. If you want to try a variety of OS’s or are unsure of what you want to install I recommend this. You can follow the guide below to burn this image to a memory stick.
I decided to install Raspbian Jessie with PIXEL instead of NOOBS. This is because I wanted a fully featured Debian derivative (which is what Raspbian is) installed.
Burning the Image to a SD Card
Now we need to burn the image to the SD card, this is going to explain what you need to do if you are using windows. If you are using Linux/Mac OS I assume you know what you are doing. If you are using windows you first need to unzip the OS image so you have the the .img file available.
Once you have downloaded and unzipped the image you need to burn it, you can do this with win32 Disk Imager. Selecting the image and SD drive and pressing write will burn the OS to the SD card.
Now you can put the SD card into the Raspberry Pi and turn it on.
After Installing Raspbian
When you have installed Raspbian you will want to perform a few bits of basic maintenance.
Changing the user password
The default username for the pi is piand the default password is raspberry . This can be used to login to your pi but it is recommended that this is changed immediately. You can change the password of the current user by entering
Changing the hostname
Since I am planning to run multiple Raspberry Pi’s I need to change the hostname. The default hostname is raspberrypi which you can use to connect to it via ssh. However to change this you can modify the /etc/hosts file on the Raspberry Pi. You can modify this by running the following command.
sudo nano /etc/hosts
Updating the Pi
The Raspbian images are created every now and then so are not going to be fully up to date. You can update the pi by running the following two commands
sudo apt-get update
sudo apt-get upgrade
Running these commands you will update the catalogue of packages and then upgrade any of them which are outdated.
These are some basic steps to install and set up a Raspberry Pi Raspbian install. As I find more steps that I want to perform each time I install Raspbian I will update this blogpost. If you have any questions feel free to ask in the comments.
For the Raspberry Pi cluster I wanted to make sure that they are neatly stored to keep them easy to reach.
Why nicely storing them is important
Each Raspberry Pi requires a power and network cable. When using a single raspberry pi the cables are not an issue but I am planning to use five as a baseline for my cluster. These cables can quickly start to become messy and make the cluster hard to reach.
Stacking the Raspberry Pi’s
Therefore I have selected a solution that would allow me to stack the Raspberry Pi’s on top of each other.
This case allows excess heat to be vented through the sides which many case designs do not account for. Since I plan to be using the Pi’s extensively they will likely be running quite hot.
I plan to stack six raspberry Pi’s on top of each other so I have purchased three of these (two stacked) products.