How to set up a Bitcoin Unlimited full node
There’s a lot of interest at the moment in the Bitcoin Unlimited project and people have been asking how they can help. A great way to help out with the project is to run a Bitcoin Unlimited full node. This article will show you how to set up a full node on a cheap virtual server.
1. Log in to your preferred VPS provider.
I’m using Digital Ocean here so some of the specifics will relate to them but other VPS providers will have similar features. Choose a provider to suit your preferences and budget. The emphasis in this article will be to do things as cheaply as possible so you should be able to pick up a small VPS for around US$10 per month.
2. Create a small “droplet” / VPS.
I suggest a 1GB RAM, 20GB disk “droplet” server or something similar. If you’re really on a budget you can go as low as 512MB RAM but it may swap a fair bit. When you create your VPS I recommend you choose Ubuntu 16.04 as the operating system — it’ll make things easier later on since bitcoin unlimited is easy to install on Ubuntu.
3. Secure your new server.
Log in to your new virtual server as root. The way to do this varies depending on your VPS provider. It’s usually possible to login via ssh or from a remote console window.
Once you’re at the command line the first thing to do is secure it. We’ll start by setting up some firewall rules.
# ufw allow ssh
# ufw allow 8333
# ufw default deny incoming
# ufw default allow outgoing
# ufw enable
These rules tell your machine to ignore any incoming network traffic except bitcoin and remote logins.
4. Install the bitcoin unlimited software.
If you’re using Ubuntu it’s easy:
# apt-get install software-properties-common
# add-apt-repository ppa:bitcoin-unlimited/bu-ppa
# apt-get update
# apt-get install bitcoind
If you’re not using Ubuntu take a look at the installation instructions on this page instead.
5. Create a bitcoin user.
We’ll make a bitcoin user account and give it the ability to use “sudo” so you can do some system administration from the bitcoin user if you want to.
# adduser bitcoin
# usermod -a -G sudo bitcoin
6. Set up log rotation for your bitcoin logs.
This will ensure that your logs don’t grow too big and use up all your disk space.
Create a new log rotation file:
# nano /etc/logrotate.d/bitcoin-debug
Enter into it:
/home/bitcoin/.bitcoin/debug.log
{
rotate 5
copytruncate
daily
missingok
notifempty
compress
delaycompress
sharedscripts
}
7. Configure bitcoin.
We’re going to set up your node as a ‘pruning’ node. This means it doesn’t need to have all 100GB of the blockchain — it’ll only keep the most recent parts of it.
# su - bitcoin
$ mkdir .bitcoin
$ cd .bitcoin
$ nano bitcoin.conf
Add to the file:
prune=15000
Save the file and press control-D to log out of the bitcoin user and become root again.
8. Configure swap space.
Running a full bitcoin node uses a little over 1GB of memory. The node we created only has 1GB so we’ll make some spare “virtual memory” using swap space.
# fallocate -l 1g /swap1.swap
# chmod 0600 /swap1.swap
# mkswap /swap1.swap
# swapon /swap1.swap
# nano /etc/fstab
Add this line at the end of the file:
/swap1.swap none swap sw 0 0
9. Set up the bitcoin daemon to auto-run.
Create a startup file:
# nano /etc/systemd/system/multi-user.target.wants/bitcoind.service
Enter into it:
[Unit]
Description=Bitcoin Server
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
Alias=bitcoind.service
[Service]
User=bitcoin
Group=bitcoin
# Start main service
ExecStart=/usr/bin/bitcoind
ExecStop=/usr/bin/bitcoin-cli stopRestart=always
PrivateTmp=false
Reload systemd and start bitcoind:
# systemctl daemon-reload
# systemctl restart bitcoind
# systemctl status bitcoind
10. (optional) Set up user logins with ssh
If you want to log directly in to your new server using ssh you may want to set up ssh public key authentication. This guide from Digital Ocean is quite good.