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.

Create a Samba Share on Raspberry Pi Cluster

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

Configuring Samba

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

[homes]
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.

[BUNKER1]
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

sudo groupadd samba
sudo usermod -aG samba chewett
sudo smbpasswd -a chewett

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

Browsing via samba to my raspberry pi host “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.

Logging into the samba share with login details bunker\chewett

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.

 

 

Installing Raspbian onto a Raspberry Pi

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 pi and 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

passwd

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.

Final words

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.

VCHI initialization failed Raspberry Pi Fixed

vcgencmd get_mem arm VCHI initialization failed
Example showing VCHI initialization failed error

If when running vcgencmd on a raspberry pi you get VCHI initialization failed then you need to add the video group to your user. The vcgencmd tool requires you have this group role so without it, it will give VCHI initialization failed.

To add the user group to your user you can run:

sudo usermod -aG video <username>

Where <username> is the user you want to run the vcgencmd command with. This command adds the video group to the the user you specify.

Once you have ran the command any new logins will run the command successfully. Logging out and back into the pi will let you use the command.

Why this problem occurs

This issue happens when you try and use the vcgencmd command with a user that isn’t a member of the video group. This typically happens when you create a new user for the raspberry pi and don’t give it the same groups that the pi user has.

The solution above fixes this by adding the correct video group to the created user.

Mysql workbench working with key based exchange mechanisms

It appears newer linux sshd configs (fedora 22) by default include a smaller set of key exchange based mechanisms that they have turned on.

This means that it gives errors saying it is unable to connect to the server. To fix this you need to enable some of the older key exchange mechanisms,

Adding this line to /etc/ssh/sshd_config and restarting the sshd server will fix it

KexAlgorithms curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1

Credits to: http://serverfault.com/questions/692060/mysql-workbench-with-debian-jessie-tcp-ip-over-ssh-does-not-work

Install Virtualbox guest additions on Fedora 21 XFCE

Installing via the normal route didn’t work and meant I couldn’t easily resize the screen. Doing the below allowed me to use the resize easily.

  1. Install rpmfusion on fedora
  2. run `sudo yum install akmod-VirtualBox VirtualBox-guest`
  3. run `cd /usr/src/akmods`
  4. run `sudo rpm -ivh VirtualBox-*.rpm`

Once this was installed, rebooting will give you access to shared folders and fullscreen mode

Found the fix on the fedora forums for fedora 19

Add a user to a group in Linux

How to add a user to a group in Linux

usermod -a -G  

Its a simple as that. So for me adding the user “chewett” to the user “vboxusers” i run the command

usermod -a -G vboxusers chewett

The -a flag means that the new group is appended, without it you will overwrite your current groups with the specified one, In nearly all cases this is not what you want to do!