As I wrote my experiences to set-up a Raspberry Pi (model 3b) for use as a full bitcoin node in dutch, this post is the english translation for those international readers. Where I used other sources (websites, pages) I’ve included the links that helped me.
The Raspberry Pi can be versatile to execute many tasks with a very small amount of power consumption. At this moment I’m running 1 single Raspberry Pi (model 3b, quad core 1.2GHz) an application to filter add-ware (Pi-hole), a status-overview (using RPi-monitor), BOINC running for Seti@home (using 3 cores dedicated)) and the bitcoin full node.
How I made the configuration with this Raspberry Pi and an external (USB powered) hard disk drive, it will all be described here. I choose the USB hard disk to save the micro SD card, which will age by use of many write-cycles.
This post has been updated in November 2018, to accomodate version 0.17.0.1 of the node software.
What purpose has a full node in the Bitcoin network?
As mentioned earlier, this article will help you setting up a Raspberry Pi as a node in the Bitcoin netwerk, and it will not be used to mine (calculating for (new) bitcoins, which today needs a huge amount of processing power and energy, with small rewards on a single hardware unit. A ‘node’ can everyone run on it’s internet connection to support and optimise communications (relay) of messages between nodes in the Bitcoin network. The more nodes, the less sensitive for degradation and more available alternative routes can be used. Besides this, each node will check transactions against it’s own (local available) downloaded block chain and communicate this with its peer-nodes.
Bill of materials
To put a Raspberry Pi in service as a (full) node, following components are needed:
- 1 Raspberry Pi (latest model 3b will do the job (quad-core, max 1.2GHz, 1Gb RAM);
- 1 micro-SD card with 8Gb capacity. The larger the better, but after initial boot-up, the SD-card will no longer be used as the USB hard drive takes over.
- 1 matching power supply with minimum of 2.5 Amps (also to supply the USB hard drive with power)
- 1 external USB hard disk (minimum USB 2.0). For about 50 EUR an external hard drive of about 500Gb will be sufficient. At the moment (july 2017) the block chain is approx. 140Gb in size.
- 1 case for the Raspberry Pi
- Additional (in case of running BOINC read this as a MUST-have): some heat sink on the Broadcom SoC and a 12Volt fan that will be able to run on 5V onboard.
Because of the huge amount of internet data to download/upload, please check with your internet provider if you have restrictions. If your internet provider does have data restrictions, please consider not to run a Bitcoin full node until switched to a provider without data restrictions
Steps to follow
Briefly the following steps will lead to a fully operational bitcoin full node:
- installation of NOOBS software on an FAT formatted micro SD card, and placed in the Rpi
- After boot-up, install NOOBS Raspbian with Pixel (though, we’re not going to run Pixel, so one may opt for CLI (command line only) Raspbian
- Uninstall in Pixel various apps we’re not going to use (Libre office, wolfram etc). This may be not applicable when using Raspbian Lite
- Update your Raspberry with latest software;
- Activate SSH (to enable remote management/servicing your Pi)
- Set-up your Rpi with a fixed/assigned IP-address (in router as well in Raspbian);
- In RASPI-CONFIG decrease video memory allocation to minimum (16Mb)
- Partitioning of the USB hard disk
- Transfer all data of the micro SD card to the Hard disk, so the boot-up sequence will be running on the hard drive.
- Install Raspberry Pi Full Node software and let it download the block chain. Warning: this will take several gigabytes of data, and depending on your internet connection can take upto 3-4 weeks…
- Open port 8333 for the bitcoin network to communicate with the full node;
- optional: install Pi-Hole (software to block add-ware on web-pages)
- optional: install RPI monitor (to monitor resources of your Rpi using a HTML5 webpage layout)
NOOBS (New Out Of the Box Software) can be downloaded here on the Raspberry pi website
Format the micro SD card as FAT file-system, and copy the (unzipped) files of the downloaded NOOBS archive to the SD card.
After you’ve placed the micro SD card in the Raspberry Pi, connect your keyboard, mouse and monitor and power-supply.
After boot-up, follow instructions on screen, choose your language/keyboard layout. (I choose with a GUI the Raspbian with Pixel, but we wil run the RPI from command line in the end)
After succesvol installation, the RPI will be able to boot up from micro SD card and open with the GUI (Pixel)
Several hundreds of Megabytes can be saved when Raspbian Pixel is completed. Removal will save time in the copy-procedure later, but also along the maintenance.
Several applications can be removed with following command entered in the Command Line on the Raspberry:
sudo apt-get purge libreoffice wolfram-engine sonic-pi scratch
sudo apt-get autoremove
More applications can be removed but these few take almost 1Gb of data. If you run the Raspbian Lite, it will be very likely a lot of utilities and apps are by default not installed and may save you this step.
Update Raspbian to recent version
Software develops along the way, and before we move on, make sure we have the latest versions on our RPI using following commands:
sudo apt-get update
sudo apt-get dist-upgrade
After this the latest (stable) firmware and other software is on the RPI active after a reboot (e.g. using ‘sudo shutdown -r now’)
Activate SSH on Raspberry Pi
We will use SSH to communicate and configure the Raspberry Pi from another computer (which on this turn, also the monitor, mouse and keyboard can be disconnected).
- select Interfacing options
- Navigate to SSH and select
- select Yes
- select OK
- select Finish (and reboot to activate SSH).
After reboot you can connect from your desktop system (Apple e.g) using ‘ssh pi@<ip_address_raspberry>’
Assign a fixed IP-address to the Raspberry
By default, DHCP services on your raspberry or router will assign an IP_address to your Raspberry. But for use as a full node (sort of server) we will manually set-up a fixed IP address in our network.
I have used following information in dutch
Backup your current network settings on the Raspberry:
sudo cp /etc/dhcpcd.conf /etc/dhcpcd.conf.org
Assign a fixed IP_address to your Raspberry using:
sudo nano /etc/dhcpcd.conf
As I’m connecting my Raspberry Node using Ethernet, find in the dhcpcd.conf file for the abbreviaton ‘eth0’. I’m assigning the address 192.168.1.30 to the Node-to-be. For your situation (local network) things may differ, but I think you can get the global picture:
interface eth0 static ip_address=192.168.1.30/24 static routers=192.168.1.1 static domain_name_servers=22.214.171.124
Save changes using key combination CTRL X, Yes, ENTER
and perform a reboot of the network-settings:
sudo reboot -h 0
Use the command ‘ifconfig’ to check if your ethernet-connnection (eth0) has received the assigned IP_address:
After this command, more details (such as gateway, mask) are shown. with a brief test (using ‘ping 126.96.36.199’) you can check if your Rpi can ping/connect Google-servers.
Maximize RAM, minimize video memory
We’re not playing games or videos on the RPI, so I’m restricting the video memory to the minimum which is 16Mb. This on its turn restores more RAM to the system to work with.
- Select item ‘Memory Split’
- select/enter 16Mb at GPU (Graphics Processing Unit) item.
- Select save and exit, and reboot your RPI
Now we’re booting without any monitor attached (hopefully), and assume you’re using SSH to connect for further management. But first switch to full command line boot-up:
In raspi-config select Boot options -> Desktop/CLI –> B1 Console
After reboot, the RPI will startup, and present a login-screen awaiting for a valid login
Setting up the external USB hard disk
Now connect your USB hard drive on a USB port of the Raspberry (RPI supports USB 2.0 disks)
Now we prepare the hard drive, to save the SD-card
First, it starts with partitioning, and then mounting, with some modifications to support a proper boot-sequence. For this chapter I have used following resources on the internet: source #1 en source #2
the 500Gb hard drive is set up:
- 30 Gb partition (/dev/sda1) reserved for Raspbian OS/Linux, with room to spare for future updates, and other additional software;
- 5 Gb partition (/dev/sda2) for swap. Minimum size could be twice the internal memory of the Raspberry (so 2Gb total), but 5Gb is certainly plenty.
- The storage that was left in the end (approx 430Gb) is assigned for the bitcoin blockchain data (/dev/sda3)
So connect your USB hard drive and let the RPI boot up.
On the command line (using SSH, or using the ‘old-fashioned’ keyboard-monitor attached setup):
sudo fdisk -l
A list of devices will be shown. Search for device ‘/dev/sda’. This is your external hard drive being identified in Raspbian. If you see partitions, feel free to remove/delete them, we’re assuming the hard drive is free of any partitions on it.
Now start setting up the partitions:
sudo fdisk /dev/sda
Create the root partion (approx 30Gb):
- Enter ‘n’ with ENTER
- Enter ‘p’ for primary partition
- Enter ‘1’ for first partition (/dev/sda1)
- Select default/standard start-sector (ENTER)
- Enter value ‘+30G’ for a size of 30Gb
Create swap partition (here 5Gb)
- Enter ‘n‘ with ENTER
- Enter ‘p‘ for primary partition
- Enter ‘2‘ for second partition (/dev/sda2)
- Select default/standard start-sector (ENTER)
- Enter value ‘+5G’ for a size of 5Gb
- Enter ‘t‘ to assign a type to this second partition
- Enter ‘2‘ in to select 2nd partition
- Enter ‘82‘ in for Swap partitie (swap Linux / Solaris)
Create data partitie for block chain storage:
- Enter ‘n‘ with ENTER
- Enter ‘p‘ in for primary partition
- Enter ‘3‘ in for third partition (/dev/sda3)
- Select default/standard start-sector (ENTER)
- Select default/standard END sector (ENTER geven), this will create maximum of left-over space to be assigned to the data storage for the block chain.
Use ‘p‘ to list a printed overview of partitions
Select ‘w‘ to write the partition table to disk and quit FDISK
Now format the partitions (using EXT4 file extensions) you’ve created:
sudo mkfs.ext4 /dev/sda1
sudo mkfs.ext4 /dev/sda3
initialise the swap partition and activate the swap partition:
sudo mkswap /dev/sda2
sudo swapon /dev/sda2
Copy data from micro SD card to hard drive
Now we’re transfer the data used in boot-up from the SD-card to the hard drive.
First, we mount the (new) root partition on the (new) harddrive in the current setup in the folder ‘/mnt’:
sudo mount /dev/sda1 /mnt
Now partition /dev/sda1 is found as mounted storage in the folder /mnt.
Now using RSYNC we transfer all files (and meta data (rights, groups etc)) to the mounted hard drive (/dev/sda1) partition.
sudo rsync -avz --exclude '/mnt' / /mnt
This will take a while (count on 1-1,5 hour) depending on choosen Raspbian setup.
After the rsync copy action has been successful, we need to take card that the new (/dev/sda1) partition is to be mounted upon boot-up sequence.:
sudo nano /mnt/etc/fstab We still direct our editor NANO to the still mounted partition (/dev/sda1) to the file to be edited (/etc/fstab)
Using a hash tag (‘#’) I deactivated the initial partioin on the SD_card
You also can see how the SWAP partionion (/dev/sda2) is to be embedded into the /etc/fstab file,
As well as the new root (now copied to the existing /mnt)die nu naar de hard disk is gekopieerd (/dev/sda1) als de bitcoin partitie (/mnt/pidrive) (de pi-drive mount will be subject in later topic, when we install the Bitcoin full node software)
Remove old swap files on the hard drive
sudo rm /mnt/etc/rc?.d/*dphys-swapfile
sudo rm /mnt/var/swap
Create a backup of the cmdline.txt:
sudo cp /boot/cmdline.txt /boot/cmdline.org
update thee cmdline.txt:
sudo nano /boot/cmdline.txt
Check the cmdline.txt, and near ‘root=….’ there was initially another text visible (in the order of ‘mmbclk….’). Update/change it to our new root (here in this post it is: ‘/dev/sda1’
Save the changes using (CTRL X, Yes)
Now the RPI is capable of reading an initial file on the SD-card, and then continue the boot sequence from the hard disk attached on USB.
Enter ‘sudo reboot‘ and see if you see your RPI reboot and using the hard drive to it’s purpose and return you to the command line on the raspberry Pi.
Installation of the Bitcoin full node software
Now the RPI reboots on it’s hard drive, the micro SD-card is saved from numerous write-activities, we’re now ready for the bitcoin full node software.Initially I’ve found this article which helped me very well. As several things have been arranged we continue with other steps needed.
The hard drive (/dev/sda) has several partitions, and the largest one (430Gb on my 500Gb disk, designated as /dev/sda3) will be merely containing the block chain.
Mount the partition for the bitcoin data/block chain:
sudo mkdir /mnt/pidrive
Note PARTUUID of the partition as follows:
and copy the line with ‘/dev/sda3’ the text/data after PARTUUID (see figure below)
Open /etc/fstab and add PARTUUID (see figure earlier used):
PARTUUID="d9e4ca8c-03" /mnt/pidrive ext4 defaults 0 0
Now save changes and exit NANO editor using: (CTRL X, Yes),
and after a reboot the partiotion /dev/sda3 will be mounted automatically in the folder /mnt/pidrive.
Check after a reboot if the mount of the /dev/sda3 partition as /mnt/pidrive is succesfull:
Now install the software, which I used following resource to great value on setting up a full bitcoin node
sudo apt-get install git autoconf libevent-dev libtool libssl-dev libboost-all-dev libminiupnpc-dev
Now download the bitcoin v0.17.0.1 software:
git clone git://github.com/bitcoin/bitcoin -b v0.17.0.1
./configure --enable-upnp-default --disable-wallet --disable-bench --disable-zmq --without-gui --prefix=/usr/
After this, when software installation is succesfull executed following steps:
sudo make install
rm -R ~/bin
Create the bitcoin storage and authorize the (new) user ‘bitcoind’:
sudo mkdir -p /mnt/pidrive/.bitcoinData/
sudo useradd -r bitcoind
sudo chown bitcoind:bitcoind /mnt/pidrive/.bitcoinData
Create system service:
sudo nano /lib/systemd/system/bitcoind.service
Description=Bitcoin's distributed currency daemon
ExecStart=/usr/bin/bitcoind -daemon -pid=/mnt/pidrive/.bitcoinData/bitcoind.pid \
-conf=/etc/bitcoin/bitcoin.conf -datadir=/mnt/pidrive/.bitcoinData -disablewallet
(select in NANO editor CTRL X, Yes to save changes)
sudo ln -s /lib/systemd/system/bitcoind.service /etc/systemd/system/multi-user.target.wants/bitcoind.service
Create a configuration file for Bitcoin:
sudo mkdir /etc/bitcoin
sudo nano /etc/bitcoin/bitcoin.conf
Now start the service manually using:
sudo service bitcoind start
With this the processes will be started, and the block chain downloaded.
with ‘sudo service bitcoind status‘ you can check on the status (summarised)
Now you need to open up port 8333 for the bitcoin netwrok on your router. How it’s done, really depends on your router (brand and model), so consult your supplier (or browse the internet).
As example I’ve posted my settings on a FritzBox 6390:
If all is well, retrieve your external IP address of your internet connection. using (for example) What’s my IP and write it down.
Surf to website van 21.com, and perform a check to see if your raspberry pi Full Node will be recognized as such: BitNodes
Enter your external IP-address, followed with port-number 8333. If all is well, your Node (to-be) will be recognized and upload of block chain blocks will start.
Now it’s time to physically install your Raspberry Pi near your internet connection using ethernet connectivity and leave the RPI download at will the block chain. My experience using an RPI it will take approx. 3 weeks time to have the block chain downloaded and synchronized (dated june/july 2017). The processor load on the Raspberry is very low, common values about 3-5% so plenty of power to spare for other tasks.
I did find this information also for the port 8333 on a Raspberry, which in my opinion are optional (as without it I could setup my Pi communicating with the bitcoin network). But it may help, executing didn’t affect my Pi neither.
sudo iptables -A INPUT -p tcp --dport 8333 -j ACCEPT
sudo iptables -A INPUT -p udp --dport 8333 -j ACCEPT
Optional: Pi-Hole ad-ware blocker
As the RPI is most of the time idle, with low CPU usage, I’ve installed Pi_hole to filter internet data on advertorials on web-pages etc. Details can be read here Pi-Hole
You can install Pi_hole using SSH and the following command:
curl -sSL https://install.pi-hole.net | bash
From 4:36 you can see the steps to follow in this youtube movie:
Optional: RPI Monitor
I’ve found it very useful to monitor the RPi on temperatures (using BOINC, stressing the cores full time), but also hard drive space.
Installation of RPI monitor is easy using this manual
As you can see, the RPI is versatile in performing tasks with a small power consumption. I’m not explaning installation of BOINC, as this CPU-intensive program really asks for more preparations (such as a fan for cooling used in combination of a heat sink). It’s possible, even assigning 1-2 cores helps.
We’ve used the RPI with account ‘pi’ and a default password. Do not forget to change the password, just to prevent unauthorised access (certainly when using SSH).
When logged in as user ‘pi’ enter the following:
and enter the current (valid) password, and twice a new password.
Since a few months I’m running a RaspberryPi for Pi-hole. This low-power computer system has sufficient power to support also the bitcoin network as a full node. As a very new beginner to Bitcoin and it’s technology, I discovered how easy it is to show support to the Bitcoin by operating the full node, and the UASF BIP148.
If you want to read more about this (UASF, BIP148, SegWit etc.) I can recommend this english source .