Run a Bitcoin node on Raspberry Pi

In this tutorial we will make a remotely accessible Bitcoin node on a Raspberry Pi.

Bitcoin is a new fully digital currency. It is the first decentralized peer-to-peer payment network that is powered by its users with no central authority or middlemen. From a user perspective, Bitcoin is pretty much like cash for the Internet.

To use Bitcoin you do not need to run a full node (you can for example use web-based wallets, such as Coinbase or Blockchain.info), but it helps the network by providing better reachability.

 

Requirements

  • Raspberry Pi Model B, B+ or Raspberry Pi 2 Model B (at least 512MB RAM is needed)
  • At least 64GB (micro-)SD card (you need to download the whole blockchain for the node to work. At the time of this writing, the blockchain is over 37GB.
  • A clean install of Raspbian Linux distribution on the SD card.
  • Network access (Ethernet or Wifi adapter)
  • Mouse, keyboard, monitor (only during installation)

Please note that this tutorial has been tested with Raspberry Pi 2 Model B. The previous models may not be powerful enough to run the full Bitcoin node.

 

Setup

  • Boot up Raspberry Pi with Raspbian installed
  • Login using your credentials
  • Update Raspbian to latest packages:
sudo apt-get update
sudo apt-get upgrade
  • Install some required dependencies for Bitcoin:

sudo apt-get install build-essential autoconf libssl-dev libboost-dev libboost-chrono-dev libboost-filesystem-dev libboost-program-options-dev libboost-system-dev libboost-test-dev libboost-thread-dev libtool


Installing Berkeley DB

Unfortunately Raspbian has a very old version of the Bitcoin client (called Bitcoin Core). That's why we need to install Bitcoin Core and Berkeley DB version 4.8 manually.

  • Download Berkeley DB version 4.8:
wget http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz
  • Extract the file and change to that directory:

tar -xzvf db-4.8.30.NC.tar.gz
cd db-4.8.30.NC/build_unix/
  • Configure the package:
../dist/configure --enable-cxx
  • Compile the package and install (this will take a while)
make 
sudo make install

 

Installing Bitcoin Core

And finally, we can install the Bitcoin client.

  • Go to https://bitcoin.org/en/download and check the latest version (at the time of this writing it's 0.11.0. Substitute this number in future for yours if it's different)
  • Clone the git repository
git clone -b 0.11 https://github.com/bitcoin/bitcoin.git bitcoin-0.11
cd bitcoin-0.11
  • Configure the package
./autogen.sh
./configure CPPFLAGS="-I/usr/local/BerkeleyDB.4.8/include -O2" LDFLAGS="-L/usr/local/BerkeleyDB.4.8/lib"
  • Compile Bitcoin Core (this will take several hours)
make
sudo make install

 

Usage

You now have a complete Bitcoin node installed. You can start it anywhere by typing:

bitcoind

Do remember to check the settings for bitcoind (with 'bitcoind --help'). One useful setting is -dbcache, which sets the database cache limit. Around 50-100 should be fine.

To run the client automatically on startup, edit '/etc/rc.local' file and append to the end of the file:

/usr/local/bin/bitcoind &

 

Additional stuff

Bitcoin uses port 8333 to communicate with the network, so make sure to open port on your router if necessary.

Syncing the whole blockchain can take days. To get current status of your client, you can run:

bitcoin-cli getinfo

You can find the latest blocks on blockexplorer.com.

You can access your computer remotely with SSH. Run the raspberry pi configuration tool and enable SSH server.

sudo raspi-config

Comments

I ran this on a headless Raspberry 2 but had a number of crashes, until I finally uninstalled all unnecessary processes related to GUI, by using:

sudo apt-get -y purge libx11-6 libgtk-3-common xkb-data lxde-icon-theme raspberrypi-artwork penguinspuzzle

Otherwise all is fine.

I couldn't get past the ./config stage following these instructions and try to compile 0.12. Has anyone else succeeded with 0.12?

On DietPi, I needed to install libevent-dev to get it past the config stage 0.12.0.
But then it fails building with "virtual memory exhausted" (on a 512MB RPi-B).
It would be nice if there were prebuilt kits for RPi...

#Increase swap file size
free -m
sudo nano /etc/dphys-swapfile # Edit according to the comments below
# comment CONF_SWAPSIZE=100
# uncomment CONF_SWAPFACTOR=2
# uncomment CONF_MAXSWAP=2048
sudo /etc/init.d/dphys-swapfile stop
sudo /etc/init.d/dphys-swapfile start
free -m

Add new review

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.