[Docker] OpenWRT Images for x86, x64, Raspberry Pi and Raspberry Pi 2

As some of you know, I am trying to learn to use Docker.
I love the simplicity of this tool and the fact that a lot of my Appliances could be built and mainted more efficiently with the use of it.
So I thought "Well, I should at least try to create some useful Images for the Docker Registry / Hub" - and so I came up with the Github Repo of x-drum which I could not help - but fork ;). So, x-drum showed an easy way to build x86 Images for 14.07 and 15.05 OpenWRT.
And I thought "well, lets extend that". So now, we also got 12.09 OpenWRT x86, as well as trunk x86... and while I was doing some research, I slapped the x64 Versions for trunk and 15.05 on as well :).

But wait - somethings missing - yeah: We need some Raspberry Pi Stuff ;):
The guys over at Hypriot did an really awesome job with creating Hypriot OS - basically an bootable Image for RPi1/2 to use a recent Version of Docker :). But - truth been told - they already created some special RPi (ARM) Images on the Docker Hub - but... it would be nice to get some more base images to play with...

So I basically used Hypriot OS on a RPi 1 to create the OpenWRT 12.09, 14.07, 15.05 and Trunk Docker Images - and on a RPi 2 to create OpenWRT 15.05 and Trunk Docker Images.
The RPi 1 Images are also usable on a RPi 2 - so I recommend to use them. RPi 2 Images are only usable on a RPi 2 :).

Everything can be grabbed from my Github Repo: https://github.com/nmaas87/docker-openwrt or directly on Docker Hub.
The x86/x64 Images can be found on https://hub.docker.com/r/nmaas87/docker-openwrt/, while the RPi 1 and RPi 2 Images are here: https://hub.docker.com/r/nmaas87/rpi-openwrt/.

Have fun :)!

[RPi] The cheapest Raspberry Pi Cluster Ever Made v2

Ok, an little update on the PiZero Cluster Front:
Now, that OTG is compiled directly into the "next" kernel of RPi, we can use the OTG USB Virtual Ethernet directly - which makes it a lot easier. So I updated this :).

0. Preparing Minibian Jessie Image
I used some old Appliance Image I created from an Minibian Wheezy Image (https://minibianpi.wordpress.com/) earlier this year - for the 1.) section on the RPi Modell B pre 2.0 and RPi Modell A+. For the 2.) section, I used an special Appliance Image I made from an Minibian Jessie Image. However, I will document needed changes here, to get it running from any source. I recommend the Minibian Jessie Image as starting point, with this changes:


apt-get update
apt-get install -y raspi-config keyboard-configuration
raspi-config
# Default Configuration and Expand Filesystem using raspi-config
# Enter Finish and press Yes on Reboot the Device

apt-get install -y rpi-update sudo
apt-get -y dist-upgrade
reboot

rpi-update
reboot

# Create Default User pi
adduser pi
# Enter Password as wanted, i.e. raspberry
# Add user to default groups
usermod -a -G pi,adm,dialout,cdrom,audio,video,plugdev,games,users pi
# Add sbin Paths to pi
echo 'export PATH="$PATH:/sbin:/usr/sbin:usr/local/sbin"' >> /home/pi/.bashrc
# Add user to sudo
visudo
# Add under
# # User privilege specification
# root ALL=(ALL:ALL) ALL
pi ALL=(ALL:ALL) ALL
# Save and Exit
reboot

# Disable root login
sudo passwd -l root

or - and default RPi Jessie Image.

1. Building mpich 3

# Update and Install Dependencies, then reboot
sudo apt-get update
sudo apt-get -y dist-upgrade
sudo apt-get install -y build-essential
sudo reboot

# Make MPICH 3.2
cd ~
wget http://www.mpich.org/static/downloads/3.2/mpich-3.2.tar.gz
tar -xvzf mpich-3.2.tar.gz
cd mpich-3.2
# This will take some time
sudo ./configure --disable-fortran
# This will take several cups of tea ;)
sudo make
sudo make install

# Create SSH on Master, distribute to Slaves

cd ~
ssh-keygen -t rsa –C "raspberrypi"

Default location should be set to /home/pi/.ssh/id_rsa if you're using the standard user pi. Then choose this command to distribute the key to all your "slave maschines":
cat ~/.ssh/id_rsa.pub | ssh pi@IP_OF_SLAVES "mkdir .ssh;cat >> .ssh/authorized_keys"
( Was taken from http://www.southampton.ac.uk/~sjc/raspberrypi/ - he was the original father of the RPi Clusters and his work inspired me already years ago - so please read and support his work :)! Additional infos can be found at http://westcoastlabs.blogspot.co.uk/2012/06/parallel-processing-on-pi-bramble.html)
You could also just
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
to your own authorized files, shutdown your Master Pi after that and clone the card several times for all your Clients. This way, you would only need to do the work once - however, maybe you should release the keys in ~/.ssh/ so that only your Master Pi could command the slaves

2. PiZero on Virtual Ethernet
I build my MPICH as mentioned in 1) on an Minibian Jessie image (SDCard running on an RPi B). Then I installed the new RPi Kernel and prepared the image for OTG Ethernet, using the new information provided by NicoHood:


#install new kernel with OTG support
sudo BRANCH=next rpi-update

# This is required in the config.txt
echo "device_tree=bcm2708-rpi-zero.dtb" | sudo tee -a /boot/config.txt

# Regarding the readme this is applied automatically for a pi zero (and yes it works without) - so not really needed
# echo "dtoverlay=dwc2" | sudo tee -a /boot/config.txt

# Only use this, if the new kernel causes sd card errors
# echo "dtoverlay=mmc" | sudo tee -a /boot/config.txt

# permanently add the g_ether (or any other) module, add it to /etc/modules
echo "dwc2" | sudo tee -a /etc/modules
echo "g_ether" | sudo tee -a /etc/modules

# Add settings to network interfaces
echo '
allow-hotplug usb0
iface usb0 inet static
address 192.168.7.2
netmask 255.255.255.0
network 192.168.7.0
broadcast 192.168.7.255
gateway 192.168.7.1
dns-nameservers 8.8.8.8' | sudo tee --append /etc/network/interfaces

# Some additional tweaks:
Add

# Turn HDMI Off
/usr/bin/tvservice -o
# Turn HDMI Back On
#/usr/bin/tvservice -p

# Turn ACT LED Off on Pi Zero
echo none | tee /sys/class/leds/led0/trigger
echo 1 | tee /sys/class/leds/led0/brightness

to your /etc/rc.local before exit 0 to turn off the HDMI Interface on boot,
as well as the LED of the Pi Zero to use less energy. Found on:
http://www.midwesternmac.com/blogs/jeff-geerling/raspberry-pi-zero-conserve-energy and http://www.midwesternmac.com/blogs/jeff-geerling/controlling-pwr-act-leds-raspberry-pi

This was enough to create an Pi Zero Slave Image.
Shutdown the RPi now with

sudo shutdown -h now

remove the Power and insert the SDcard into your Pi Zero.

On the Master Machine, I did following changes:

# Add settings to network interfaces
echo '
allow-hotplug usb0
iface usb0 inet static
address 192.168.7.1
netmask 255.255.255.0
network 192.168.7.0
broadcast 192.168.7.255' | sudo tee --append /etc/network/interfaces

# Allow Ipv4 Forward
echo 'net.ipv4.ip_forward=1' | sudo tee --append /etc/sysctl.conf

# Install iptables
sudo apt-get install -y iptables

# Define NATing rules
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -A FORWARD -i eth0 -o usb0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i usb0 -o eth0 -j ACCEPT

# Save NAT rules / load iptables on interface up
sudo touch /etc/iptables_masq.rules
sudo chown pi:pi /etc/iptables_masq.rules
sudo iptables-save > /etc/iptables_masq.rules

Add
pre-up iptables-restore < /etc/iptables_masq.rules under the eth0 section in the network interfaces sudo vi /etc/network/interfaces i.e. auto eth0 iface eth0 inet dhcp pre-up iptables-restore < /etc/iptables_masq.rules ( Info taken from: http://serverfault.com/questions/405628/routing-traffic-on-ubuntu-to-give-raspberry-pi-internet-access )

#After that, I shutdown the RPi via
sudo shutdown -h now
#removed power from it.

Then I attached the Pi Zero to the Hub of Pi B via an Micro USB Cable by using the Micro USB OTG Slot on the Pi Zero, connecting it to the Hub of the Pi Modell B. Next, I powered up the Pi B - and both booted.

I pinged 192.168.7.2 - which was the IP of the Pi Zero - and it answered. Now I only had to use cat ~/.ssh/id_rsa.pub | ssh pi@192.168.7.2 "mkdir .ssh;cat >> .ssh/authorized_keys" from Section 0 to get the SSH Key, created in Step 0 onto the Pi Zero and could use that to automatically login in into the Pi Zero.
With the new IP of the RPi B and Pi Zero in the machinefile of mpich I could then use my both RPis with higher speed and nearly zero costs for cabeling and power :)!
The clou: I don't need an additional powersupply for the Pi Zero - nor network adapters, RJ45 cabling, an switch - only one USB A to USB Micro cable per Pi Zero - and maybe an big, active USB Hub ;)!

Now, I need to get more Pi Zeros - I plan on using an Modell B as Master with an big active USB Hub to support 4 Pi Zeros - or an Modell B+ with an REALLY BEFFY USB Supply to work them all the same RPi - but that would come down to trying this... And I got only one Pi Zero - so I need some more time (or some sponsors?) to get me more RPi Zeros to try and see, whether this approach does scale ;)!

Best thing: This can also be used to try the awesome work of http://blog.hypriot.com/ to build an Docker Cluster from that - cool, ain't it?

[RPi] Measuring RPi Zero USB Network Speed with iperf

As I saw Jeff Geerlings Website and his iperf Benchmarks of different RPis (Link), I wondered how the RPi Zero would perform by using the USB Virtual Ethernet Interface on my Windows 7 x64 PC.

So I got the latest iperf 2 Version (iPerf 2.0.5-3) from the iperf Website at https://iperf.fr/iperf-download.php, installed iperf from the Raspbian Jessie Packages and launched the iperf Server on my Windows 7 x64 PC via iperf -s. The PC was attached to an Gigabit Switch via an Gigabit Ethernet Interface - so no bottleneck here.

Then I started the iperf tests via iperf -c IP -t 20 -i 2.
And these are results:

RPi Modell B Version pre 2
------------------------------------------------------------
Client connecting to 192.168.2.4, TCP port 5001
TCP window size: 43.8 KByte (default)
------------------------------------------------------------
[ 3] local 192.168.2.98 port 37217 connected with 192.168.2.4 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0- 2.0 sec 13.9 MBytes 58.2 Mbits/sec
[ 3] 2.0- 4.0 sec 13.9 MBytes 58.2 Mbits/sec
[ 3] 4.0- 6.0 sec 13.6 MBytes 57.1 Mbits/sec
[ 3] 6.0- 8.0 sec 14.4 MBytes 60.3 Mbits/sec
[ 3] 8.0-10.0 sec 14.5 MBytes 60.8 Mbits/sec
[ 3] 10.0-12.0 sec 14.6 MBytes 61.3 Mbits/sec
[ 3] 12.0-14.0 sec 14.5 MBytes 60.8 Mbits/sec
[ 3] 14.0-16.0 sec 14.6 MBytes 61.3 Mbits/sec
[ 3] 16.0-18.0 sec 14.5 MBytes 60.8 Mbits/sec
[ 3] 18.0-20.0 sec 14.5 MBytes 60.8 Mbits/sec
[ 3] 0.0-20.0 sec 143 MBytes 60.0 Mbits/sec

60 MBit/s? Well... That is not as good as thought...

RPi Modell B v2
------------------------------------------------------------
Client connecting to 192.168.2.4, TCP port 5001
TCP window size: 43.8 KByte (default)
------------------------------------------------------------
[ 3] local 192.168.2.161 port 55453 connected with 192.168.2.4 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0- 2.0 sec 14.1 MBytes 59.2 Mbits/sec
[ 3] 2.0- 4.0 sec 14.1 MBytes 59.2 Mbits/sec
[ 3] 4.0- 6.0 sec 14.0 MBytes 58.7 Mbits/sec
[ 3] 6.0- 8.0 sec 14.8 MBytes 61.9 Mbits/sec
[ 3] 8.0-10.0 sec 14.6 MBytes 61.3 Mbits/sec
[ 3] 10.0-12.0 sec 14.6 MBytes 61.3 Mbits/sec
[ 3] 12.0-14.0 sec 14.6 MBytes 61.3 Mbits/sec
[ 3] 14.0-16.0 sec 14.6 MBytes 61.3 Mbits/sec
[ 3] 16.0-18.0 sec 14.5 MBytes 60.8 Mbits/sec
[ 3] 18.0-20.0 sec 14.6 MBytes 61.3 Mbits/sec
[ 3] 0.0-20.0 sec 145 MBytes 60.7 Mbits/sec

60.7 MBit/s - ok, the RPi Modell B v2.0 got double the RAM (512 MB) than the old version - but that did not have impact on the network speed.

RPi 2 Modell B
------------------------------------------------------------
Client connecting to 192.168.2.4, TCP port 5001
TCP window size: 43.8 KByte (default)
------------------------------------------------------------
[ 3] local 192.168.2.111 port 38411 connected with 192.168.2.4 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0- 2.0 sec 22.6 MBytes 94.9 Mbits/sec
[ 3] 2.0- 4.0 sec 22.4 MBytes 93.8 Mbits/sec
[ 3] 4.0- 6.0 sec 22.5 MBytes 94.4 Mbits/sec
[ 3] 6.0- 8.0 sec 22.5 MBytes 94.4 Mbits/sec
[ 3] 8.0-10.0 sec 22.4 MBytes 93.8 Mbits/sec
[ 3] 10.0-12.0 sec 22.5 MBytes 94.4 Mbits/sec
[ 3] 12.0-14.0 sec 22.4 MBytes 93.8 Mbits/sec
[ 3] 14.0-16.0 sec 22.5 MBytes 94.4 Mbits/sec
[ 3] 16.0-18.0 sec 22.4 MBytes 93.8 Mbits/sec
[ 3] 18.0-20.0 sec 22.5 MBytes 94.4 Mbits/sec
[ 3] 0.0-20.0 sec 225 MBytes 94.2 Mbits/sec

94.2 Mbits/s is a good value, the matches with Jeff ones - so I am feeling a bit better after the bad measurements of the RPi 1 B pre/2.0's...

RPi Zero
------------------------------------------------------------
Client connecting to 192.168.7.1, TCP port 5001
TCP window size: 43.8 KByte (default)
------------------------------------------------------------
[ 3] local 192.168.7.2 port 37992 connected with 192.168.7.1 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0- 2.0 sec 21.9 MBytes 91.8 Mbits/sec
[ 3] 2.0- 4.0 sec 22.1 MBytes 92.8 Mbits/sec
[ 3] 4.0- 6.0 sec 22.2 MBytes 93.3 Mbits/sec
[ 3] 6.0- 8.0 sec 22.1 MBytes 92.8 Mbits/sec
[ 3] 8.0-10.0 sec 22.1 MBytes 92.8 Mbits/sec
[ 3] 10.0-12.0 sec 22.2 MBytes 93.3 Mbits/sec
[ 3] 12.0-14.0 sec 22.2 MBytes 93.3 Mbits/sec
[ 3] 14.0-16.0 sec 22.2 MBytes 93.3 Mbits/sec
[ 3] 16.0-18.0 sec 22.1 MBytes 92.8 Mbits/sec
[ 3] 18.0-20.0 sec 22.2 MBytes 93.3 Mbits/sec
[ 3] 0.0-20.0 sec 222 MBytes 92.9 Mbits/sec

Finally - and that does come in as a surprise: I though the Pi Zero - attached via USB Ethernet would give me any value between some Mbit and some really odd numbers - but it closely matches an really solid 100 MBit Interface - so... Thats cool :)!

[RPi] The cheapest Raspberry Pi Cluster Ever Made

As soon as the Pi Zero came out, I started on thinking about Clusters again. I wanted to create an big - but at the same time, cheap cluster.
Yes, an Pi Zero is not nearly as fast, as an RPi 2. And yes, there are some problems with this idea - especially about the fact, that the Pi Zero is not as common as an - say - RPi Modell B v. 2.0 - but - as this is more about science and trying to just "do it" - I tried it anyway.

TLDR; Yes, it works - and better than you might think :)!

So, the basic problem about the Pi Zero are its interfaces: Yes, we got USB, but none Ethernet Port. So the basic approach would be to buy an 5€ Pi as well as an about 8€ AX88772 Ethernet Interface and some USB OTG Adapters - an we would end up with about 15€+ for each member of the cluster. Well, that is reasonable - but bulky and "not sexy".

0. Building mpich
I used some old Appliance Image I created from an Minibian Wheezy Image (https://minibianpi.wordpress.com/) earlier this year - for the 1.) section on the RPi Modell B pre 2.0 and RPi Modell A+. For the 2.) section, I used an special Appliance Image I made from an Minibian Jessie Image. However, I will document needed changes here, to get it running from any source. I recommend the Minibian Jessie Image as starting point, with this changes:


apt-get update
apt-get install -y raspi-config keyboard-configuration
raspi-config
# Default Configuration and Expand Filesystem using raspi-config
# Enter Finish and press Yes on Reboot the Device

apt-get install -y rpi-update sudo
apt-get -y dist-upgrade
reboot

rpi-update
reboot

# Create Default User pi
adduser pi
# Enter Password as wanted, i.e. raspberry
# Add user to default groups
usermod -a -G pi,adm,dialout,cdrom,audio,video,plugdev,games,users pi
# Add sbin Paths to pi
echo 'export PATH="$PATH:/sbin:/usr/sbin:usr/local/sbin"' >> /home/pi/.bashrc
# Add user to sudo
visudo
# Add under
# # User privilege specification
# root ALL=(ALL:ALL) ALL
pi ALL=(ALL:ALL) ALL
# Save and Exit
reboot

# Disable root login
sudo passwd -l root

or - and default RPi Jessie Image.

Building MPICH 3 was quite easy:


# Update and Install Dependencies, then reboot
sudo apt-get update
sudo apt-get -y dist-upgrade
sudo apt-get install -y build-essential
sudo reboot

# Make MPICH 3.2
cd ~
wget http://www.mpich.org/static/downloads/3.2/mpich-3.2.tar.gz
tar -xvzf mpich-3.2.tar.gz
cd mpich-3.2
# This will take some time
sudo ./configure --disable-fortran
# This will take several cups of tea ;)
sudo make
sudo make install

# Create SSH on Master, distribute to Slaves

cd ~
ssh-keygen -t rsa –C "raspberrypi"

Default location should be set to /home/pi/.ssh/id_rsa if you're using the standard user pi. Then choose this command to distribute the key to all your "slave maschines":
cat ~/.ssh/id_rsa.pub | ssh pi@IP_OF_SLAVES "mkdir .ssh;cat >> .ssh/authorized_keys"
( Was taken from http://www.southampton.ac.uk/~sjc/raspberrypi/ - he was the original father of the RPi Clusters and his work inspired me already years ago - so please read and support his work :)! Additional infos can be found at http://westcoastlabs.blogspot.co.uk/2012/06/parallel-processing-on-pi-bramble.html)
You could also just
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
to your own authorized files, shutdown your Master Pi after that and clone the card several times for all your Clients. This way, you would only need to do the work once - however, maybe you should release the keys in ~/.ssh/ so that only your Master Pi could command the slaves

1. Frist Try: Serial (did work, but not choosen)

ppplink

First idea was, to use the Serial Line of the Pi Zero for IP communication:
I wanted to have an Master Pi (Modell B) with Ethernet Port for network connectivity and connect up to 4 Pi Zero to it via Serial. And as the RPis only have one serial port, I would use an Serial to SPI Converter to keep it small and simple. But as it turns out, I could not find the MAX14830 (https://www.maximintegrated.com/en/products/interface/controllers-expanders/MAX14830.html) for sale on the net, so I got two 2 Port MAX3109 Serial to SPI Converters (https://www.maximintegrated.com/en/products/interface/controllers-expanders/MAX3109.html).
They were on the way to my home, so I wanted to already test some basic stuff by using an RPi Modell B pre 2.0 and an RPi Modell A+.

As we only had one serial port, we could only drive the one RPi Modell A+ with that. I will use the B pre 2.0 as Master, and the A+ as Slave. First, we connected both RPis via Serial (both shutdown and unpluged!). Just connect the Serial TX of RPi B to the Serial RX of the RPi A+ and vice versa. Then connect a Ground Pin of the RPi B to the RPi A+. Thats it.
Then we powered on the RPis and made some changes:
(Some ideas taken from MagPi 41: https://www.raspberrypi.org/magpi/)

Guest:

# I actually prepared the whole sdcard of the RPi A+ Guest while having that SD Card in the RPi B - because of the networking connection :).
# Install ppp
sudo apt-get install ppp -y
# Change Hostname
sudo vi /etc/hostname
sudo vi /etc/hosts
# Add DNS Server
echo 'nameserver 8.8.8.8' | sudo tee --append /etc/resolv.conf
# Remove Serial Console
cd /boot
sudo cp cmdline.txt old_cmdline
sudo vi cmdline.txt
# Normal should read about
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsc
# Remove console=ttyAMA0,115200 from that line, save and quit

# Disable Serial Console by using sudo raspi-config and the option, to be sure

# Increase Clock on the Serial Line, so drive the Serial Line at not only 115200 baud, but 1 MBit/s (taken from: http://www.thedevilonholiday.co.uk/raspberry-pi-increase-uart-speed/)
echo 'init_uart_clock=64000000' | sudo tee --append /boot/config.txt

# Add the following line to /etc/rc.local before exit 0
pppd /dev/ttyAMA0 1000000 10.0.5.2:10.0.5.1 noauth local defaultroute nocrtscts xonxoff persist maxfail 0 holdoff 1 &

# and shutdown
sudo shutdown -h now

After that, insert that SD Card into the A+.

Host:

# Now insert the real SD Card for the B into the B and power it on.
# Install ppp
sudo apt-get install ppp -y
# Enable ipv4 Forward for networking access
echo 'net.ipv4.ip_forward=1' | sudo tee --append /etc/sysctl.conf
# Remove Serial Console
cd /boot
sudo cp cmdline.txt old_cmdline
sudo vi cmdline.txt
# Normal should read about
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsc
# Remove console=ttyAMA0,115200 from that line, save and quit

# Disable Serial Console by using sudo raspi-config and the option, to be sure

# Increase Clock on the Serial Line, so drive the Serial Line at not only 115200 baud, but 1 MBit/s (taken from: http://www.thedevilonholiday.co.uk/raspberry-pi-increase-uart-speed/)
echo 'init_uart_clock=64000000' | sudo tee --append /boot/config.txt

# Reboot
reboot

# After having rebooted the RPi B, boot up the RPi A+ as well.
# Wait a little bit, then...

# Start PPP Connection
sudo pppd /dev/ttyAMA0 1000000 10.0.5.1:10.0.5.2 proxyarp local noauth nodetach nocrtscts xonxoff passive persist maxfail 0 holdoff 1

In a new putty window, you can now ping 10.0.5.2 - your RPi A+ and can SSH into it.

After that, I could use MPI with both machines, B and A+ - by entering their IP addresses into the machinefile and executing the cpi example to crunch some Pi Numbers.

But after all - it was quite ineffective and slow. So I tried to think of something better.. And then LadyAda came with her christmas present to me:
https://learn.adafruit.com/turning-your-raspberry-pi-zero-into-a-usb-gadget/ethernet-gadget - that was the moment my jaw dropped and I thought "YES! Thats it!".

2. Second Try: PiZero on Virtual Ethernet (Solution)

usblink

Now my prefered solution: As the USB Port of the PiZero is an real OTG Port, you could repurpose it as an Serial or even Virtual Ethernet port. And hell, Lady Ada striked again :)! So to sum it up shortly:
I build my MPICH as mentioned in 0) on an Minibian Jessie image (SDCard running on an RPi B). Then I installed her special kernel:


cd ~
wget http://adafruit-download.s3.amazonaws.com/gadgetmodulekernel_151224a.tgz -o gadgetkernel.tgz
tar -xvzf gadgetkernel.tgz

sudo mv /boot/kernel.img /boot/kernelbackup.img
sudo mv tmp/boot/kernel.img /boot

sudo mv tmp/boot/overlays/* /boot/overlays
sudo mv tmp/boot/*dtb /boot
sudo cp -R tmp/boot/modules/lib/* /lib

# Load virtual ethernet module on boot
echo 'g_ether' | sudo tee --append /etc/modules

# Add settings to network interfaces
echo '
allow-hotplug usb0
iface usb0 inet static
address 192.168.7.2
netmask 255.255.255.0
network 192.168.7.0
broadcast 192.168.7.255
gateway 192.168.7.1' | sudo tee --append /etc/network/interfaces

# Add DNS Server
echo 'nameserver 8.8.8.8' | sudo tee --append /etc/resolv.conf

# Some additional tweaks:
Add

# Turn HDMI Off
/usr/bin/tvservice -o
# Turn HDMI Back On
#/usr/bin/tvservice -p

# Turn ACT LED Off on Pi Zero
echo none | sudo tee /sys/class/leds/led0/trigger
echo 1 | sudo tee /sys/class/leds/led0/brightness

to your /etc/rc.local before exit 0 to turn off the HDMI Interface on boot,
as well as the LED of the Pi Zero to use less energy. Found on:
http://www.midwesternmac.com/blogs/jeff-geerling/raspberry-pi-zero-conserve-energy and http://www.midwesternmac.com/blogs/jeff-geerling/controlling-pwr-act-leds-raspberry-pi

This was enough to create an Pi Zero Slave Image.
Shutdown the RPi now with

sudo shutdown -h now

remove the Power and insert the SDcard into your Pi Zero.

On the Master Machine, I did following changes:

# Add settings to network interfaces
echo '
allow-hotplug usb0
iface usb0 inet static
address 192.168.7.1
netmask 255.255.255.0
network 192.168.7.0
broadcast 192.168.7.255' | sudo tee --append /etc/network/interfaces

# Allow Ipv4 Forward
echo 'net.ipv4.ip_forward=1' | sudo tee --append /etc/sysctl.conf

# Install iptables
sudo apt-get install -y iptables

# Define NATing rules
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -A FORWARD -i eth0 -o usb0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i usb0 -o eth0 -j ACCEPT

# Save NAT rules / load iptables on interface up
sudo touch /etc/iptables_masq.rules
sudo chown pi:pi /etc/iptables_masq.rules
sudo iptables-save > /etc/iptables_masq.rules

Add
pre-up iptables-restore < /etc/iptables_masq.rules under the eth0 section in the network interfaces sudo vi /etc/network/interfaces i.e. auto eth0 iface eth0 inet dhcp pre-up iptables-restore < /etc/iptables_masq.rules ( Info taken from: http://serverfault.com/questions/405628/routing-traffic-on-ubuntu-to-give-raspberry-pi-internet-access )

#After that, I shutdown the RPi via
sudo shutdown -h now
#removed power from it.

Then I attached the Pi Zero to the Hub of Pi B via an Micro USB Cable by using the Micro USB OTG Slot on the Pi Zero, connecting it to the Hub of the Pi Modell B. Next, I powered up the Pi B - and both booted.

I pinged 192.168.7.2 - which was the IP of the Pi Zero - and it answered. Now I only had to use cat ~/.ssh/id_rsa.pub | ssh pi@192.168.7.2 "mkdir .ssh;cat >> .ssh/authorized_keys" from Section 0 to get the SSH Key, created in Step 0 onto the Pi Zero and could use that to automatically login in into the Pi Zero.
With the new IP of the RPi B and Pi Zero in the machinefile of mpich I could then use my both RPis with higher speed and nearly zero costs for cabeling and power :)!
The clou: I don't need an additional powersupply for the Pi Zero - nor network adapters, RJ45 cabling, an switch - only one USB A to USB Micro cable per Pi Zero - and maybe an big, active USB Hub ;)!

Now, I need to get more Pi Zeros - I plan on using an Modell B as Master with an big active USB Hub to support 4 Pi Zeros - or an Modell B+ with an REALLY BEFFY USB Supply to work them all the same RPi - but that would come down to trying this... And I got only one Pi Zero - so I need some more time (or some sponsors?) to get me more RPi Zeros to try and see, whether this approach does scale ;)!

Best thing: This can also be used to try the awesome work of http://blog.hypriot.com/ to build an Docker Cluster from that - cool, ain't it?

Merry Christmas :)!

Yours,

Nico

[RaspPi] Multiboot with BerryBoot

If you start using Raspberry Pis, you will run out of Sdcards rather quickly. Reason for this is, there are so many awesome Distros you would like to use - that you are becoming something like an Discjokey for Sdcards: An awful load of sdcards with just some 100 MBs of distros - spread all over your desk. And while sdcards are somehow cheaper than they used to be - today - it is still an awful waste of money.

Enter BerryBoot:

BerryBoot is an multiboot OS for Raspberry Pi (1 & 2).
It does use packed (squashfs) Images of different OSes, boots into them by using a shared library base and saves differences onto its own data structure on a second (ext4) partition. Quite cool!

To use Berryboot, just head over to http://www.berryterminal.com/doku.php/berryboot and download your copy.

HOWEVER, there are some caveats:
The CEC function does not work correctly on the current RPi 1 Version - so you can't navigate the menu of BerryBoot or i.e. OpenElec via your TV IR Remote. This seems to be due to a bug in the Raspberry Pi start files. RPi 2 Version does work well... So I tried to mesh the two versions - and it worked in the end. So my receipe is the following:

1.) Download from http://www.berryterminal.com/doku.php/berryboot the berryboot-20140814.zip ( http://downloads.sourceforge.net/project/berryboot/berryboot-20140814.zip ) as well as the berryboot-20150916-pi2-only.zip ( http://downloads.sourceforge.net/project/berryboot/berryboot-20150916-pi2-only.zip ).

a) If you do not yet use berryboot:
2.) Now, format your Sdcard (if you are newly creating a Berryboot System) to fat32.
3.) Unzip all files from the berryboot-20150916-pi2-only.zip to the root of the newly created Sdcard. Then unzip ONLY the kernel_rpi_aufs.img from berryboot-20140814.zip and copy it to the Sdcard.

b) If you own a Berryboot RPi 1 Sdcard and want to upgrade:
2.) Make a backup of your current berryboot sdcard! MANDATORY! Remove all files from the fat32 berryboot partition (the one with the config.txt, start files, etc.)
3.) Unzip all files from the berryboot-20150916-pi2-only.zip to berryboot partition. Then unzip ONLY the kernel_rpi_aufs.img from berryboot-20140814.zip and copy it to the Sdcard.

If you want to decide which image should be booted "on boot":
Just create on the berryboot data partition in /data/ an textfile named "default" and enter which image should be loaded, i.e.: OpenELEC_6.0.0.img128
There should also be an default_bootonce or so called file which does only boot on the next boot up - but i have not tried that.
With that knowledge, you could mount the berryboot data file from an booted image and change - while beeing in the system - the next bootimage via commandline.
Neat :)?

[RaspPi] Minibian Basic Setup

For basic appliances with an very specific task, an complete Raspbian Installation can be too heavy weight and unnecessary. Striping down Raspbian of things like Mathematica can be time consuming. Enter Minibian: Just download the Image at https://minibianpi.wordpress.com/ and flash it to your SD Card like a normal Raspbian Image. Following is the procedure to setup Minibian with raspi-config, rpi-update and sudo / Default User pi.

How much resources does Minibian need after installation?
About 469 MB of space on the SD Card.
About 60 MB of RAM.
I think that is way better than Raspbian.

apt-get update
apt-get install -y raspi-config
raspi-config
# Default Configuration and Expand Filesystem using raspi-config
# Enter Finish and press Yes on Reboot the Device

apt-get install -y rpi-update sudo
apt-get -y upgrade
reboot

rpi-update

# Create Default User pi
adduser pi
# Enter Password as wanted, i.e. raspberry
# Add user to default groups
usermod -a -G pi,adm,dialout,cdrom,audio,video,plugdev,games,users pi
# Add sbin Paths to pi
echo 'export PATH="$PATH:/sbin:/usr/sbin:usr/local/sbin"' >> /home/pi/.bashrc
# Add user to sudo
visudo
# Add under
# # User privilege specification
# root ALL=(ALL:ALL) ALL
pi ALL=(ALL:ALL) ALL
# Save and Exit
reboot

# Disable root login
sudo passwd -l root

[Art] Suomalainen Äänimaisema

Suomalainen Äänimaisema was an project of Melanie Windl, an artist from the University of Mainz, Germany on which I helped as technical advisor and programmer. The idea of the project was to field-record several sounds and music of Finland, load them onto some Raspberry Pis and let them play, as soon as a person came close enough to the object. The project was realised using three Raspberry Pi, Modell B+, some PIR sensors and USB Soundcards. You can find more about the project here: https://atelier-windl.com/portfolio/suomalainen-aanimaisema-2/

Exhibition
Suomalainen Äänimaisema
25.03.-02.04.2015
Titanik Galleria, Itäinen Rantakatu 8
20700 Turku, Finnland

Suoma_01

A short video showing the project can be found here