How to install the Gridcoin crypto-currency wallet on a Raspberry Pi 2 or 3steemCreated with Sketch.

in #gridcoin8 years ago (edited)

How to read this guide:
You will need to be able to open the command line Terminal either using a screen on the HDMI port with a keyboard and mouse, or via SSH. The guide will compile a version of GridCoin that can only be controlled via the command line.
When you see a line preceded with 'pi@raspberrypi:~ $', this signifies a command to be entered into the Pi, only enter what follows the $ symbol.
If you get a Permission denied message, try adding 'sudo ' to the start of the command.

1-The distribution version we need to flash on the SD card is the latest Stable Raspbian Image from: https://www.raspberrypi.org/downloads/raspbian/

2- Setup Raspbian in the Pi

a) Insert the flashed SD with Raspbian in the Raspberry Pi 2/3.

b) Plug in the USB mouse, the USB keyboard, the HDMI screen, the network cable, and the power cable. You may also SSH to the Raspberry Pi.

The Raspberry Pi will boot for the first time, login with user 'pi' and password 'raspberry'.

pi@raspberrypi:~ $ sudo raspi-config

You will be presented with the Raspberry Pi Software Configuration Tool (raspi-config). To navigate in this tool, the useful keys are: The up/down arrow, the Enter key, and the Tab key whenever the up/down arrow keys don’t do the job. Here, we will do next things:

b.1) Expand the Filesystem by choosing Option 1, TAB to Finish, and Reboot. You will get a message Root partition has been resized. If you are on SSH your terminal may abort, if this occurs just close the session and login to the Pi again.

b.2) Select your Proper Time Zone and Change the User Password by choosing option 2. Enter your new password twice. When entering the password, the characters won’t be displayed as a security feature. You will get a message Password changed successfully.
After reboot check the time is correct with:
pi@raspberrypi:~ $ date

b.3) OPTIONAL If you don’t intend to use a display (ie you are on SSH), or output any video media we can free up additional RAM by reducing the amount dedicated to the GPU

pi@raspberrypi:~ $ sudo raspi-config

Select Advanced Options > Memory Split

Change the entry from 64 to 16

TAB to FINISH and Reboot

b.4) OPTIONAL: If you have a Pi3 with internal Wi-Fi and would prefer to connect to the Pi via Wi-Fi; then edit the wpa_supplicant.conf file

pi@raspberrypi:~ $ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Add the following lines

network={
ssid="YOURWIFISSID"
psk="YOURWIFIPSK"
}
CTRL+X to save, Y to confirm and then hit Enter

pi@raspberrypi:~ $ sudo reboot

Disconnect the Ethernet cable and find your new IP address in your Wi-Fi router.

3- Update the Raspberry Pi device.

Run the following commands:

pi@raspberrypi:~ $ sudo apt-get update -y

pi@raspberrypi:~ $ sudo apt-get upgrade -y

4- Setting up the Raspberry Pi for compiling GridCoin.

a) Change Swap Size.

Use the following command to change the default swap size:

pi@raspberrypi:~ $ sudo nano /etc/dphys-swapfile

Make sure it reads CONF_SWAPSIZE=1024 Use the left/right arrow keys to navigate the file. After change is done, press Ctrl+X followed by Y then Enter key to save the file. Then, press Ctrl+X to exit the editor.

Use the following commands to enable the swap file with its new size:

pi@raspberrypi:~ $ sudo dphys-swapfile setup ** this may take a few minutes **

pi@raspberrypi:~ $ sudo dphys-swapfile swapon

You can check the new active swap size with next command:

pi@raspberrypi:~ $ free -m

b) Install Required Dependencies with next commands:

pi@raspberrypi:~ $ sudo apt-get install autoconf libevent-dev libtool libssl-dev libboost-all-dev libminiupnpc-dev libdb-dev libdb4.8++ libdb5.3++-dev git ntp build-essential libdb++-dev libqrencode-dev libcurl4-openssl-dev curl libzip-dev libzip2 libboost1.55-all-dev -y

c) Compile and Install BerkeleyDB 4.8.30 by running the following commands:

pi@raspberrypi:~ $ wget http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz

pi@raspberrypi:~ $ sudo tar -xzvf db-4.8.30.NC.tar.gz

pi@raspberrypi:~ $ cd db-4.8.30.NC/build_unix

pi@raspberrypi:~ $ sudo ../dist/configure --enable-cxx

pi@raspberrypi:~ $ sudo make

pi@raspberrypi:~ $ sudo make install

pi@raspberrypi:~ $ export CPATH="/usr/local/BerkeleyDB.4.8/include"

pi@raspberrypi:~ $ export LIBRARY_PATH="/usr/local/BerkeleyDB.4.8/lib"

Note: the export commands are only valid in the current Terminal session. To avoid errors, don't close the Terminal until you fully completed with GridCoin compilation.

5- Clone the GridCoin Github, compile and install the client / node with following commands:

pi@raspberrypi:~ $ cd

pi@raspberrypi:~ $ git clone https://github.com/gridcoin/Gridcoin-Research
NOTE: ** This will create a new directory /home/pi/Gridcoin-Research **

pi@raspberrypi:~ $ cd db-4.8.30.NC/build_unix

pi@raspberrypi:~ $ sudo ../dist/configure --prefix=/usr/local --enable-cxx

pi@raspberrypi:~ $ cd

pi@raspberrypi:~ $ cd Gridcoin-Research/src

pi@raspberrypi:~ $ sudo mkdir ~/Gridcoin-Research/src/obj && cd ~/Gridcoin-Research/src && chmod 755 leveldb/build_detect_platform && make -f makefile.unix
NOTE: ** This is going to take a long time, go and make a cup of tea **

pi@raspberrypi:~ $ sudo strip gridcoinresearchd

pi@raspberrypi:~ $ sudo install -m 755 gridcoinresearchd /usr/bin/gridcoinresearchd

pi@raspberrypi:~ $ mkdir ~/.GridcoinResearch

pi@raspberrypi:~ $ ~/

pi@raspberrypi:~ $ chmod 700 .GridcoinResearch

pi@raspberrypi:~ $ cd

6- Start the GridCoin daemon with:

pi@raspberrypi:~ $ gridcoinresearchd

7- You may get a warning and need to create a gridcoinresearch.conf file, don’t worry

pi@raspberrypi:~ $ cd .GridcoinResearch

pi@raspberrypi:~ $ cat > gridcoinresearch.conf

Enter the following
email=your email, must match your BOINC projects
server=1
daemon=1
rpcallowip=127.0.0.1
rpcuser=<username (anything you want, does not need to match BOINC)>
rpcpassword=<password (anything you want, does not need to match BOINC)>
addnode=node.gridcoin.us
listen=1 ** if you want a full node **
PrimaryCPID= your pre-existing CPID
privatekey your pre-existing CPID= your pre-existing private key
publickey your pre-existing CPID= your pre-existing public key

Hit CTRL+D to save the file

pi@raspberrypi:~ $ cd

pi@raspberrypi:~ $ gridcoinresearchd

8- To check if GridCoin is running
pi@raspberrypi:~ $ gridcoinresearchd getinfo
NOTE ** If you see error: couldn't connect to server, don’t worry, it just means the program is still starting up, keep trying every 30 seconds until it works **
For a list of more commands to control your GridCoin Daemon:
pi@raspberrypi:~ $ gridcoinresearchd help

9- OPTIONAL: Move the blockchain/wallet to a USB drive, recommended to reduce wear on the SD card
pi@raspberrypi:~ $ gridcoinresearchd stop

pi@raspberrypi:~ $ mkdir /disk1

pi@raspberrypi:~ $ sudo fdisk -l (find an entry like /dev/sda1, could be different on your device)

pi@raspberrypi:~ $ sudo mount /dev/sda1 /disk1

pi@raspberrypi:~ $ sudo nano /etc/fstab

Add the following underneath the rows already present:
/dev/sda1 /disk1 auto defaults 1 2

Hit CTRL+X to save, Y to confirm and Enter

pi@raspberrypi:~ $ mv .Gridcoin-Research /home/pi/disk1

pi@raspberrypi:~ $ ln -s /home/pi/disk1/.Gridcoin-Research .Gridcoin-Research

pi@raspberrypi:~ $ gridcoinresearchd

10- IMPORTANT: Encrypt and back up your wallet and keep it on at least one other device!

Mount (another) USB drive

pi@raspberrypi:~ $ mkdir /media/usb

pi@raspberrypi:~ $ sudo fdisk -l (find an entry like /dev/sdb1, could be different on your device)

pi@raspberrypi:~ $ sudo mount /dev/sdb1 /media/usb

pi@raspberrypi:~ $ gridcoinresearchd stop

pi@raspberrypi:~ $ cd .Gridcoin-Research

pi@raspberrypi:~ $ sudo cp wallet.dat /media/usb

pi@raspberrypi:~ $ sudo umount /dev/sdb1
Remove the USB drive
pi@raspberrypi:~ $ gridcoinresearchd

11- Run Gridcoin as a service, this will ensure proper shutdown and startup, and will restart Gridcoin in case of failure
pi@raspberrypi:~ $ gridcoinresearchd stop
pi@raspberrypi:~ $ sudo nano /lib/systemd/system/gridcoinresearchd.service

Enter the following in the file:
[Unit]
Description=Gridcoin daemon services
After=tlp-init.service
[Service]
Type=simple
RemainAfterExit=yes
ExecStart=/usr/bin/gridcoinresearchd
Restart=always
RestartSec=60
User=pi

[Install]
WantedBy=multi-user.target
CTRL X, Y and Enter to save

pi@raspberrypi:~ $ systemctl enable gridcoinresearchd.service

pi@raspberrypi:~ $ systemctl start gridcoinresearchd.service

pi@raspberrypi:~ $ systemctl status gridcoinresearchd.service

Should output something like:

gridcoinresearchd.service - Gridcoin daemon services
Loaded: loaded (/lib/systemd/system/gridcoinresearchd.service; enabled)
Active: active (exited) since Sat 2016-12-10 16:22:58 GMT; 20h ago
Process: 409 ExecStart=/usr/bin/gridcoinresearchd (code=exited, status=0/SUCCESS)
Main PID: 409 (code=exited, status=0/SUCCESS)
CGroup: /system.slice/gridcoinresearchd.service
+-613 /usr/bin/gridcoinresearchd

Process ID 613 in my output is also seen if you run:

pi@raspberrypi:~ $ top ** to exit top type q
If you ever want to stop the Gridcoin service you can do:

pi@raspberrypi:~ $ systemctl stop gridcoinresearchd.service

That is it; you now have a GridCoin node on your Raspberry Pi. If you forget a command gridcoinresearchd help is your best friend!

Sort:  

Thanks for this post!

I'm following along but stuck on the

wget http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz

It says, "Cannot write to ‘db-4.8.30.NC.tar.gz’ (Permission denied)." Any idea how to get past this?

You could try putting sudo in front but that does seem odd. This guide is a bit old now, if you are looking for an easier method I believe there is a PPA for Ubuntu that has ARM support https://launchpad.net/~gridcoin/+archive/ubuntu/gridcoin-stable

sudo in front worked!

Got further but now got an error when performing this command

sudo mkdir ~/Gridcoin-Research/src/obj && cd ~/Gridcoin-Research/src && chmod 755 leveldb/build_detect_platform && make -f makefile.unix

This is what it gave me

alert.cpp:273:1: fatal error: opening dependency file obj/alert.d: Permission denied
}
^
compilation terminated.
makefile.unix:173: recipe for target 'obj/alert.o' failed
make: *** [obj/alert.o] Error 1

I've looked into the launchpad method too but I'm unable to run the

sudo add-apt-repository ppa:gridcoin/gridcoin-stable

I get this error

sudo: add-apt-repository: command not found

This is on a Raspberry Pi 3 running Raspbian.

You will need to flash your SD card with Ubuntu for the launchpad to work I think, I never used it myself.

Re the error, Im not sure whats causing you to get a permission denied, all I can think of is trying:
'sudo mkdir ~/Gridcoin-Research/src/obj && cd ~/Gridcoin-Research/src && chmod 755 leveldb/build_detect_platform && sudo make -f makefile.unix' but if that doesnt work Im not sure how to resolve, sorry

Coin Marketplace

STEEM 0.17
TRX 0.13
JST 0.027
BTC 60970.82
ETH 2602.36
USDT 1.00
SBD 2.65