Start an Ethereum Node on a Raspberry Pi 4 with Geth

Raphael Pralat
4 min readAug 10, 2019

In this article, we will see how to install and use the Ethereum client Geth on a Raspberry Pi 4.

Requirements

Material needed:

  • Raspberry Pi 4B, 4 GB RAM (not tested yet on a 2 GB and 1 GB).
  • 32 Go SD Card.

Recommended software:

Download Raspbian Buster Lite: https://www.raspberrypi.org/downloads/raspbian/

Download and install Etcher: https://www.balena.io/etcher/

Prepare the Raspberry Pi 4

First the Raspberry Pi has to be installed and configured. If you like to test your own configuration, you can go to the next chapter.

Install SD Card

Be careful, your SD Card will be formatted.

  • Mount the downloaded Raspbian image on Etcher.
  • Chose the SD Car device.
  • Click on Flash!

Once finished, unmount and unplug the SD Card. Plug it in the Raspberry Pi, then power on the Raspberry Pi.

Configure the Raspberry Pi

Login

Once booted, the Raspbian lite will prompt a command line access.
Default credentials are:
Login: pi
Password: raspberry

For security it is highly recommended to change the password if you plan to have a long term use of your node.

Use the whole SD Card capacity

Go to raspi-config tool to configure the Raspberry Pi:

$ sudo raspi-config

Go to the Filesystem options:

7 Advanced Options > A1 Expand Filesystem > Ok

Then, reboot:

Finish > Yes

Install Geth client

Next, the Geth client has to be installed to start the blockchain synchronization.

Install Golang

Firstly, Go is required to run Geth (which means Go Ethereum…).

Get Go and install from sources:

$ cd /tmp
$ wget https://storage.googleapis.com/golang/go1.10.1.linux-armv6l.tar.gz
$ sudo tar -C /usr/local -xzf go1.10.1.linux-armv6l.tar.gz

Add /usr/local/go/bin to the PATH environment variable:

$ sudo nano /etc/profile

Add at the end of the file:

# Golang
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$PATH:$GOROOT/bin

Disconnect/reconnect your session. To test if Go is properly installed execute:

$ go version
go version go1.10.1 linux/arm

Install Geth

Go to https://geth.ethereum.org/downloads/ to get the last arm7 version, and extract the archive:

$ cd /tmp
$ wget https://gethstore.blob.core.windows.net/builds/geth-linux-arm7-1.9.1-b7b2f60f.tar.gz
$ tar -zxvf geth-linux-arm7-1.9.1-b7b2f60f.tar.gz

Add the program into /usr/local/bin:

$ cd geth-linux-arm7-1.9.1-b7b2f60f/
$ sudo mv geth /usr/local/bin/

Disconnect/reconnect your session. To test if Geth is successfully installed execute:

$ geth version
Geth
Version: 1.9.1-stable
[…]

Run Geth client on Mainnet

Blockchain synchronization

Geth runs with options (https://github.com/ethereum/go-ethereum/wiki/Command-Line-Options). In order to simply synchronize the Raspberry Pi with the Mainnet blockchain, execute:

$ geth --cache=218 --syncmode "light"

cache option is important to avoid fatal memory error fatal (i.e “fatal error runtime out of memory”).

syncmode options are “fast”, “full” and “light” (https://docs.ethhub.io/using-ethereum/running-an-ethereum-node/). Only light syncmode should be working. With fast the node is always behind ( https://github.com/ethereum/go-ethereum/issues/16796).

It should take several minutes to synchronize…

Allow RPC

With the command line above, the Node is not accessible in RPC. To open RPC communication, execute:

$ geth --cache=128 --syncmode "light" --rpc --rpcaddr 0.0.0.0

rpc enable the HTTP-RPC server.

rpcaddr 0.0.0.0 allow other computers on the network to connect to Geth server.

The node is now accessible on http://<rp4_ip_address>:8545

The rp4_ip_address is accessible with ip command:

$ ip addr
[...]
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
[...]
inet 192.168.1.20/24 brd 192.168.1.255 scope global noprefixroute eth0
[...]

In this example, the eth0 IP is 192.168.1.20.

You can use https://metamask.io/ to test the node connection.

  • Select Custom RPC Network.
  • Add your node name and settings and save.

Metamask should be connected to the Ethereum Mainnet blockchain through your Raspberry Pi node:

Run Geth client on Ropsten Testnet

Blockchain synchronization

To develop, Ropsten is used instead of the Mainnet. To synchronize with the Ropsten Testnet, execute:

$ geth --testnet --cache=128 --syncmode "light" --rpc --rpcaddr 0.0.0.0

testnet enable the pre-configured proof-of-work test network.

It should also take several minutes to synchronize…

Remove blockchains

It might be helpful to remove/reset one or the other blockchain.

To remove Mainnet blockchain and state databases, execute:

geth removedb

To remove Ropsten Testnet blockchain and state databases, execute:

geth --testnet removedb

Conclusion

The Raspberry Pi 4 has just been released. It has more power and RAM, but it is still complicated to run full or fast synchronized node. Only light is working well.

And actually there are three main Ethereum clients: Geth, Parity and Pantheon. For now, only Geth seems to work fine on a Raspberry Pi.

The next step should be testing to send transactions with web3:

$ geth --testnet --cache=128 --syncmode "light" --rpc --rpcaddr 0.0.0.0 --rpcapi "db,eth,net,web3"

--

--