Skip to content

Instantly share code, notes, and snippets.

@greenstevester
Created December 18, 2023 20:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save greenstevester/0c3ca75cc086f8ed642687d00bc204c6 to your computer and use it in GitHub Desktop.
Save greenstevester/0c3ca75cc086f8ed642687d00bc204c6 to your computer and use it in GitHub Desktop.
How to Build a Bitcoin Full Node on a Raspberry Pi 3.
What is a Bitcoin Full Node?
-------------------------------
A Bitcoin full node is much simpler than it sounds.
A full node is simply a computer that is running the Bitcoin Core Wallet.
The Bitcoin Core Wallet, by default, downloads a full copy of the Blockchain.
A. You'll need a 1 TB Hard Drive as of 18.12.2023, its circa 534 GB see https://www.blockchain.com/explorer/charts/blocks-size
B. Setting up the Raspberry Pi
Setting up the Raspberry Pi is simple. If you purchased a Raspberry Pi kit that already has Raspbian installed, you simply need to put in the SD card and plug it in.
For those of you that need to install linux on a blank SD card, you can follow this guide https://www.raspberrypi.com/documentation/
C. Update the the Raspbian Software
sudo apt-get update
sudo apt-get upgrade
D. Install the External Hard Drive
Now that we have Raspbian up and running, we are going to partition the hard and mount it.
First, let’s connect the external hard drive to the usb port on the Raspberry Pi.
After we have connected the external hard drive to the Raspberry Pi we are going to run a command to see if it was identified.
Mini USB drive install
-------
1. Format the disk using "disk utility" from the mac to exFat
2. plug the disk into the raspberry pi
3. View existing partition table(s)
sudo fdisk -l
4. Edit the partition table for my chosen device (in this case, "/dev/sda")
fdisk /dev/sda
5.Within FDISK, press:
d ...to delete the current partition
n ...to create a new partition
p ...to specify it as a PRIMARY partition
1 ...to set it as the 1ST primary partition
w ...to write the changes.
6. Display the new partition table:
fdisk -l
7. Format the new partition's filesystem as type ext4
mkfs -t ext4 /dev/sda
8. Get UUID
sudo ls -l /dev/disk/by-uuid/
sudo lsblk -f
9. Create the mount point
sudo mkdir /media/SSD-279.5GB
sudo vi /etc/fstab
add line:
UUID=2d7bd463-88cd-4b59-9370-143024f60789 /media/SSD-279.5GB ext4 defaults,nofail 0 0
OR
9. use usbmount
- it seems that raspberry pi 2 simply does not manage to detect the usb drive before fstab is executed. see https://github.com/raspberrypi/linux/issues/824
see https://github.com/rbrito/usbmount
1. Install the package:
Code: Select all
sudo apt-get install usbmount
2. Make sure it works in Stretch by changing MountFlags=slave to MountFlags=shared here:
Code: Select all
sudo nano /lib/systemd/system/systemd-udevd.service
3. Reboot and it works!
MOUNT AND UNMOUNT
=====================
sudo mount /dev/sda /mnt/usb1
mkdir /storage
mount /dev/sdx1 /storage
see https://phoenixnap.com/kb/docker-on-raspberry-pi
https://raspberrytips.com/mount-usb-drive-raspberry-pi/
sudo umount --force /dev/mmcblk0p7
-------
E. Increase the Swap File
A swap file allows the Micro Sd Card in the Raspberry Pi to be used as ram.
This step is important if you are going to download the whole blockchain using the Raspberry Pi.
Let’s start by editing the file “/etc/dphys-swapfile”.
sudo nano /etc/dphys-swapfile
We are going to change the default size of the swap file from 100 to 1000.
Find the line:
CONF_SWAPSIZE=100
To:
CONF_SWAPSIZE=1000
Run the commands below to initiate this new swap file.
sudo dphys-swapfile setup
sudo dphys-swapfile swapon
F. Install the Bitcoin Core Dependencies
Before we install the actual Bitcoin Core software, we need to download certain dependencies that the software relies on.
sudo apt-get update &&
sudo apt-get install -y build-essential git autoconf libminiupnpc-dev openssl libevent-dev libtool libboost-all-dev qt4-dev-tools libprotobuf-dev libqrencode-dev autoconf libdb-dev protobuf-compiler libdb4.8++ libdb5.3++-dev &&
sudo apt-get remove -y libssl-dev
After those dependencies are installed, we are going to need to install git. Git is going to be used to access download the Bitcoin Core source code from the GitHub repository. In case you don’t know what that is, it’s a commonly accepted platform that distributes source code for all types of applications.
sudo apt-get install git -y
sudo apt install sqlite3
sudo apt-get install qt5-default
sudo apt-get install qtcreator
G. Download the Bitcoin source files by git cloning the repository.
cd /media/<your-1tb-disk>
mkdir btc
git clone https://github.com/bitcoin/bitcoin.git
cd bitcoin
H. Compile from a tagged release branch, unless you wish to test a specific branch or PR.
git tag -n | sort -V to see tags and descriptions ordered by most recent last
git checkout <TAG> to use a tagged release, for example: git checkout -b v26.0
./autogen.sh
./configure --enable-suppress-external-warning --enable-upnp-default --with-gui --with-utils
make
H. create a run.sh
------------------
1. touch run.sh
2. chmod +x run.sh
3. add the following content:
bitcoind -datadir=/media/usb-drive/.blockchain
I. How to run bitcoin
--------------------
cd /media/usb-drive/install/bitcoin/
./run.sh > /dev/null 2>&1 &
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment