Tutorial — How to install Beam on your Raspberry Pi

Wilke Trei
BEAM Privacy
Published in
9 min readOct 17, 2019

--

Preface

In my last medium article, I described the benefits in privacy and usability to run an own Beam network node over trusting an external partner and how to realize an own node on a free google cloud instance. While this is an amazing opportunity to strengthen the Beam network and to improve your wallet experience with an always-online wallet, this still requires to use external commercial services to realize it. Therefore this second article about running an own Beam node covers how to make it work on one of the most prevalent and affordable hardware platforms available: a Raspberry Pi. Besides the benefits of running an own command line wallet and node, the article also will cover how to build and install the graphical wallet. Having this the user experience for Beam on your Raspberry is just as amazing as on a standard desktop computer.

This tutorial will assume you are running a Raspberry Pi 3 or 4 with current Raspbian Duster (in my case concretely version dated 2019–09–26). Also, we need to ensure our SD card has at least 16 GByte (better 32), so the operating system, build tools as well as the blockchain fit to it. Thanks to the good scalability of a Mimblewimble blockchain we can expect a clean Raspbian and the Beam blockchain may fit a 16 GByte SD card for at least another year, maybe two.

Preparations

The nature of Beam transaction building process requires that the clock of the computer a wallet runs on needs to be at least roughly correct. Since a Raspberry Pi has no integrated real-time clock please make sure that this is the case for your device before you start running a Beam wallet on it. There are plenty of opportunities to ensure that, e.g. adding a separate real-time clock or a GPS module to your Pi. But also the pure software solutions are sufficient — in case your firewall does not block the time server ports it is likely that the clock will in fact work correct shortly after reboot. Describing different ways on how to ensure it is beyond the scope of this article.

Furthermore, during the build there are some libraries of Beam that require a higher than the standard amount of RAM when building. To cover this we should increase the virtual memory available to Raspbian. In case you own the 4G version of the Raspberry Pi 4 you can skip this step. Open the terminal on your Raspbian and type in:

sudo geany /etc/dphys-swapfile

A text editor will pop up. Edit the number inline 16 to 2048, then store and close the editor. Afterward, type

sudo dphys-swapfile setup

into the command line. Note that this will occupy two GByte of memory on your SD card. After all building work is done you can use the two commands

sudo dphys-swapfile swapoff
sudo dphys-swapfile uninstall

to disable the swap file again. Ideally, you afterward change the size back to the system default and activate it by invoking “setup” again.

How to Build the CLI Node and Wallet

We will start by installing the required dependencies of Beam by copy-pasting the following four lines to the command line, line by line and confirm each with the return key.

sudo apt-get install git
sudo apt-get install cmake
sudo apt-get install libboost-all-dev
sudo apt-get install openssl

Now we already have the dependencies of Beam on our Raspberry Pi, except for the GUI wallet that will be handled later. Next, we will download the Beam source code and change to the right branch of Beam to get a build that can connect to the Beam main network.

git clone https://github.com/BeamMW/beam.git
cd beam
git checkout mainnet

Now we are ready to run the compilation.

In case you want to build the gui wallet as well skip this step and scroll down to the section describing the gui wallet build. You then can resume after this step.

For this, you need to copy the following line to your command line. Note that the parameter after the “-j” is giving the number of threads to be used for building. In case you run a Raspberry Pi 4B with 4GByte of RAM you may choose “-j 4” to use all four processor cores for building. For the 2G RAM version “-j 3” is optimal, while a Raspberry Pi 4 1G or Raspberry Pi 4 should use “-j 2” or even “-j 1”. The rationale is that compiling slows down if RAM is exhausted and the swap file needs to be used.

cmake -DBEAM_NO_QT_UI_WALLET=1 -DARCH_NATIVE=1 . && make -j 3

On the 2G model using -j 3 is very smooth except for a handful of libraries around 65% of the build process where the swap file is used. Overall building beam as a whole requires about half an hour on a Raspberry Pi 4 with 2G RAM — plenty of time for a long coffee break.

When done we built the following executables:

./beam/beam-node
./wallet/beam-wallet

that we can copy to a common folder and use them as described in the Beam documentation or in my previous article about Beam on a cloud VM instance. Note that the initial synchronization of the node will take some hours, although it is quicker than the cloud instance.

How to Install the CLI Node and Setup Autostart

In case that you want to clean the build directory to save some space on your Pi it may make sense to install the Beam node and the CLI wallet in another directory and add this to the system search path. Of course, you also can copy it manually and use it as described in my cloud vm article.

Use the following lines to create a new directory for your beam stuff in your home directory and copy the relevant files over to this directory.

sudo mkdir -p opt/beam
sudo chown pi:pi opt/beam
cp ~/beam/{beam/beam-node,wallet/beam-wallet} /opt/beam

Besides the executables, we will also create a directory for the configuration files and the node data within our home directory.

mkdir -p ~/.local/share/beamcp ~/beam/{beam/beam-node.cfg,wallet/beam-wallet.cfg} ~/.local/share/beam

The relevant files are now copied to the new directory and you can clean up the sources — unless you want to build the GUI wallet as well (see below!).

Now we will tell the system about the new locations of the executables as well as the configurations. Type

geany /home/pi/.bashrc

and scroll down the file. At the bottom add the following lines:

export PATH=/opt/beam:$PATHfunction BeamNode {
pushd ~/.local/share/beam
beam-node $@
popd
}
function BeamCLIWallet {
pushd ~/.local/share/beam
beam-node $@
popd
}

Close the text editor and type

source ./.bashrc

Now — and whenever you open your console later — your system will know the two commands “BeamNode” and “BeamCLIWallet” and switch to the right working directories automatically — and come back to your current working directory when done.

The corresponding configuration files for your node can be accessed by typing

geany /home/pi/.local/share/beam/beam-node.cfg

for the node configuration. To run the node in a very basic configuration its needed to change just two lines. First head out for line 25, which is

# peer=

and change it to

peer=eu-nodes.mainnet.beam.mw:8100

You also can pick any other Beam node to start your sync with. A list with known and trusted nodes can be found here.

Furthermore to enable fast syncing — which saves space and CPU time on your Raspberry-Pi add the line

fast_sync=1

to the bottom of the file. Then you already could start your node and strengthen the Beam network. Other options are only required in case you want to connect your own wallet or want to solo mine with your node.

Configure your node for your needs and type in “BeamNode” to start it for its first sync. This will take several hours and also will put a lot of load to the CPU. Best do this overnight but do not worry: once the node is fully synced the system load of the running node is almost zero.

Still not enough? It would be cool to start the node on each reboot in the background to keep it always on and synced, right? Ok, let’s do so!

For this task, we will install tmux that allows us to start a console program on boot-up and get the command line to front in case we need it.

sudo apt-get install tmux

Once this is done we will create a cron job that will launch our beam node on each boot-up. Type in

geany /opt/beam/beam.cron

to open the text editor and copy in the following lines.

#!/bin/bash
sleep 5
/usr/bin/tmux new-session -d -s beamSession ‘/bin/bash’
/usr/bin/tmux send-keys -t beamSession “source /home/pi/.bashrc” C-m
/usr/bin/tmux send-keys -t beamSession “BeamNode” C-m

Save the file and close the editor. Note that we did set a sleep time of 5 seconds before the node is supposed to start after reboot. This is to allow the system to establish the network connection first. Also starting multiple tmux instances at the same time may cause problems, so if you want to start multiple programs (e.g. a CLI wallet) by this method I recommend to set different sleeping times.

Now we will make cron aware of this file. Type in

crontab -e

In case you never did so till now you will be asked a question about the editor to use. Hit 1, so nano will be used.

Navigate with the arrow keys to the bottom of the file and insert the following line

@reboot /opt/beam/beam.cron

Then hit ctrl+o to save the file and crtl+x to close the editor. Now on every boot, the system will start your beam node in a separate session. When you open the command line you can see the running session by typing

tmux attach-session -t beamSession

Do this on your first reboot to ensure everything is working. If not it is likely that some aspects are missing in the configuration file — I assume that the node is completely configured by this file and does not require additional command line parameters.

How to Build and Install the GUI Wallet

In order to build the beam GUI wallet, we will need to install some additional dependencies that are used by the graphical interface of the wallet. This can be done by copying the following four lines to your command line.

sudo apt-get install qt5-default
sudo apt-get install qtdeclarative5-dev libqt5svg5-dev
sudo apt-get install qttools5-dev-tools qttools5-dev
sudo apt-get install qml-module-qtquick-controls qml-module-qtquick-controls2

The installation of these dependencies will require approximately 200 MByte extra space on your SD card. Once done we can start the build of the beam GUI wallet. Note that in case you have not built yet the node itself this will do it. In case you already have built it, it may be required to type

rm ./CMakeCache.txt

before the build, so the building system notices the changes.
To start the actual build type in

cmake -DARCH_NATIVE=1 . && make -j 3

You may again customize the -j parameter to the specs of your Raspberry Pi as described in the section about the node build process.

Once the build is done we will copy the beam GUI wallet executable to a different location — so we are able to clean up the build space afterward — and create a menu entry for it.

Type in

sudo mkdir -p /opt/beam
sudo cp ./ui/BeamWallet /opt/beam
sudo cp ./ui/icons/beam_mainnet.png /usr/share/pixmaps/
sudo geany /usr/share/applications/BeamWallet.desktop

and a text editor will open up. Copy the following lines into the empty open file and store it.

[Desktop Entry]
Name=Beam Wallet
Comment=GUI Wallet for BEAM MW Mainnet
Icon=/usr/share/pixmaps/beam_mainnet.png
Exec=/opt/beam/BeamWallet
Type=Application
Encoding=UTF-8
Terminal=false
Categories=Network;

Now on the next reboot or after typing in

lxpanelctl restart

you will be able to see the shortcut for your beam gui wallet in the network menu of your Raspbian. The usage is exactly as used from other Linux based systems.

Enjoy using Beam on your Raspberry Pi! In case you liked this article leave me a clap or a small donation on my Beam donation address. Thank you for reading!

2346a827cb56ca74e34680593e50d7b1fa4a169332415a1d5984c6f874395c3684b

Come discover Beam and join our community!

Download Beam Desktop Wallet here

Download Beam iOS Wallet on App Store

Download Beam Android Wallet on Google Play

Learn more about Beam on our website and blog

Telegram: t.me/BeamPrivacy

QQ Beam 中国官方社区: https://jq.qq.com/?_wv=1027&k=5Mbs8N4

Reddit: reddit.com/r/beamprivacy/

Twitter: twitter.com/beamprivacy

--

--