Installing a Headless Bitcoin #Fullnode to turn it in to a Freedom Machine on Raspberry Pi 2 Model B
Raspnode & Tutorials & Technicalities - Compile Bitcoin Core on Raspberry Pi
- 8Gb Micro SD card (preferably Class 10 or above with wear protection)
- Download Raspian Jessie https://www.raspberrypi.org/downloads/raspbian / or your favourite distro
You may need a micro SD Card Adapter as many computers come with traditional SD Memory Card Slots. Insert the card & open up Terminal, do this by going to Spotlight and begin typing "Terminal".
List all the dists on your computer with this command:
diskutil list
This should give you a list of disks. The SD Card you inserted is likely to be the last one on the list.
If your SD Card is /dev/disk3 for example then type:
diskutil umountDisk /dev/disk3
Be very carefull with the next step. What we are about to do can destroy data, it is recommended you detach any hard drives or memory cards that you don't need so that it is impossible to overwrite them.
sudo dd if=2015-11-21-raspbian-jessie-lite.img of=/dev/disk3 bs=4096 conv=noerror,sync
This will copy the img file to the SD Card. This usually only take a few mins with Jessie Lite as it is a lightweight operating system.
Take the micro SD out of its adapter and your computer and put it in to the Raspberry Pi 2 and connect it up to monitor and screen
On first boot it will load up the raspi-config console. If this is not your first time then load it using the commmand:
sudo raspi-config
Select:
- Expand File System - click OK
- Enable SSH
- Change hostname to eg "fullnode" (without quotes)
- Click Finish by using Tab Key and Reboot
Make sure the install is up to date like so:
sudo apt-get update
sudo apt-get upgrade -y
The -y flag tells the OS to answer "yes" to any prompts warning you of extra disk space required, we use this for convenience but it is not essential.
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 libevent-dev git -y
To make sure you don't run out of memory increase Swap file size, you can return this back to default after install.
sudo nano /etc/dphys-swapfile
Change the default size to:
CONF_SWAPSIZE=1024
To exit cntr+X
then Y
sudo service dphys-swapfile restart
mkdir ~/bin
cd ~/bin
git clone -b 0.12 https://github.com/bitcoin/bitcoin
cd bitcoin/
./autogen.sh
./configure --enable-upnp-default --disable-wallet
make
sudo make install
You can delete ~/bin folder after the compiling.
Once Bitcoin is installed you will need to create a .bitcoin folder inside of your home directory. This is really on necessary if you want to use Bitcoin Command Line Interface or run it headlessly. If you do simply enter:
Remember earlier we increased the swap file size. Some people choose to disable Swapfile altogether by setting CONF_SWAPSIZE=0
sudo nano /etc/dphys-swapfile
Change the default size to:
CONF_SWAPSIZE=100
To exit cntr+X
then Y
sudo service dphys-swapfile restart
By default on Linux the data folder is in ~/.bitcoin. You bitcoin.conf file must be in this location for bitcoind to run.
mkdir /home/pi/.bitcoin/
cd /home/pi/.bitcoin
nano bitcoin.conf
This will open a blank text editor. Enter the following text as a minimum:
listen=1
server=1
dbcache=50
daemon=1
testnet=0
Press cntr+X
followed by Y
then Enter
to save changes and return back to the command line.
sudo blkid
Make a note of the UUID
sudo nano /etc/fstab
Enter the following:
UUID=8736-1215 /home/pi/.bitcoin vfat uid=pi,gid=pi,umask=0022,sync,auto,nosuid,rw,nouser 0 0
sudo reboot
To start Bitcoind simply run the following command:
bitcoind -daemon
It will take a long while to sync the blockchain from scratch but you can either copy it from another computer if you have another node running.