Run a full Bitcoin node on Raspberry Pi from scratch
without Umbrel ☂️ or RaspiBlitz ⚡️
1. Setup Raspberry Pi
It was so much that I had to do another post for it. Follow these instructions to set up a new Raspberry Pi.
2. Install Tor
Install tor from the official binaries following these instructions.
3. Setup the external hard drive
Format the external drive to ext4 and set up auto-mount following these instructions.
4. Install Bitcoin
I used the below instructions to install and set up a full Bitcoin node.
Don’t use apt
to install Bitcoin because it downloads an older version.
Switch to a user without root permissions; in my case, its sandbox
:
$ sudo su - sandbox
Download bitcoin
I use the official site to download the arm64 binaries.
# update the links to the latest, the below is at time of the writing.
$ mkdir /mnt/sda/downloads
$ pushd /mnt/sda/downloads
$ wget https://bitcoincore.org/bin/bitcoin-core-25.0/bitcoin-25.0-aarch64-linux-gnu.tar.gz
$ wget https://bitcoincore.org/bin/bitcoin-core-25.0/SHA256SUMS
Before you unzip it, check the integrity
$ sha256sum --ignore-missing --check SHA256SUMS
bitcoin-25.0-arm-linux-gnueabihf.tar.gz: OK
Uncompress
$ tar -xvzf bitcoin-25.0-aarch64-linux-gnu.tar.gz
Copy executables to /usr/local/bin
, or any path that’s in $PATH
# exit from sandbox user to return to a user with root privileges
$ exit
$ pushd /mnt/sda/downloads/bitcoin-25.0/bin/
$ sudo cp bitcoin* /usr/local/bin/
Configure bitcoin
Switch back to the sandbox
user
$ sudo su - sandbox
Instead of having bitcoind create the ~/.bitcoin folder in the SCard, we’re going to trick it by creating the folder in the external drive and creating a link in the home directory as follows:
$ mkdir /mnt/sda/bitcoin
$ ln -s /mnt/sda/bitcoin /home/sandbox/.bitcoin
Create the bitcoin.conf
configuration file
$ vi /mnt/sda/bitcoin/bitcoin.conf
and paste the following config
# Route traffic only thru Tor
onlynet=onion
# use as daemon
daemon=1
# Store and retrieve block filters, hashes, and headers for a range of
# blocks by height
blockfilterindex=1
# Lightning will run faster if the blockchain is indexed
txindex = 1
# For initial sync, switch back to default after a full sync
# dbcache=4096
# Defatul cache size
# dbcache=100
# enable replace by fee transactions
walletrbf=1
alertnotify=echo %s | mail -a "From: SENDER <SENDER@MAIL.com>" -s "Bitcoin Alert" RECEIVER@MAIL.com
Create a service so it auto-starts
Switch back to a user with root privileges
$ exit
Create a new service file and paste the content below
$ sudo vi /etc/systemd/system/bitcoind.service
[Unit]
Description=Bitcoin daemon
After=network.target
[Service]
ExecStart=/usr/local/bin/bitcoind -conf=/home/sandbox/.bitcoin/bitcoin.conf -pid=/home/sandbox/.bitcoin/bitcoind.pid
# Creates /run/bitcoind owned by sandbox
RuntimeDirectory=bitcoind
User=sandbox
Type=forking
PIDFile=/home/sandbox/.bitcoin/bitcoind.pid
Restart=on-failure
# Hardening measures
####################
# Provide a private /tmp and /var/tmp.
PrivateTmp=true
# Mount /usr, /boot/ and /etc read-only for the process.
ProtectSystem=full
# Disallow the process and all of its children to gain
# new privileges through execve().
NoNewPrivileges=true
# Use a new /dev namespace only populated with API pseudo devices
# such as /dev/null, /dev/zero and /dev/random.
PrivateDevices=true
# Deny the creation of writable and executable memory mappings.
MemoryDenyWriteExecute=true
[Install]
WantedBy=multi-user.target
Enable the service
$ sudo systemctl enable bitcoind
Start the service
$ sudo systemctl start bitcoind
See the activity
$ sudo tail -f /mnt/sda/bitcoin/debug.log
If you see log lines with Pre-synchronizing
, you’re done 🎉
Because synchronization will happen over Tor, it will be prolonged. ☕️
Monitoring
If you would like to monitor bitcoind
, and any other tool or state of your Raspberry Pi, follow the instructions below:
Restore previously downloaded blockchain data (Optional)
I decided to reuse previously downloaded data; if you want to do the same, follow the instructions here.