How to setup your Raspberry Pi for staking multiple wallets

MonkaS
6 min readJun 3, 2018

--

Here, you’ll learn how to setup your Raspberry Pi for staking any PoS coin, using Phore as example.

This setup allows you to stake 2–4 PoS coins at the same time, depending on how memory optimized their wallets are.

You need:

  • Raspberry Pi (Model B / Model 2 or newer)
  • microSD Card (8 GB or larger)
  • USB Stick (8 GB for 1–2 blockchains, 16 GB+ for more)
  • SD Card Reader & Raspbian installation
  • Computer with PuTTY
  • Wallet installed & synced on your computer

Please note, this tutorial does not include compiling the wallet on Raspberry, or installing Raspbian on your microSD card. For compiling the Phore wallet, please refer to this guide. If you want to run a masternode, use this guide.

If you are a first time Phore user, this guide is not recommended for you!
This guide assumes you are familiar with using the wallet on your Computer/Mac and you want to use the Raspberry as secondary device to stake on 24/7 instead of running your computer.
Please familiarize yourself with the graphical interface of your wallet on your computer and always make a backup of wallet.dat on multiple backup devices!

1. Setting up Raspberry Remote

Connect your Raspberry to Monitor/Keyboard and start Raspbian.

Click on Start icon and under Preferences -> Raspberry Pi Configuration -> Interfaces enable SSH. For using the remote desktop, enable VNC as well.

Shutdown the Raspberry and connect it to your home network (WIFI if Model3 or LAN Model2), replug your peripherals to your computer. Find out the IP address of your Raspberry through your network router.

Start PuTTY on computer and enter the IP address to Raspberry as default:

Now open the connection remotely to your Raspberry, the default username&password is pi (for both). If you get a SSH connection question, just confirm with ‘yes’. To change the password use:

sudo passwd pi YOURNEWPASSWORD

2. Setting up the swap file

Increase the swap file size to 1500 MB:

sudo nano /etc/dphys-swapfile

Save the highlighted changes with ctrl+x and confirm with (y). Reboot your raspberry with sudo reboot Reconnect with PuTTY after a minute.

3. Installing dependencies

Note: this step may change/be different over time and depend on which wallets you are installing. To find out which dependencies you have to install, refer to the respective github.

You can copy the content of the boxes and paste it into PuTTY with a right click of your mouse.

sudo apt-get install build-essential libtool autotools-dev autoconf pkg-config libssl1.0-dev libboost-all-dev libevent-dev libminiupnpc-dev libqrencode-dev

Confirm with yes, then install Berkeley DB.

wget 'http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz'
tar -xzvf db-4.8.30.NC.tar.gz
cd db-4.8.30.NC/build_unix/
../dist/configure --enable-cxx
make
sudo make install

4. Installing the Wallet

This is based on the Phore wallet v1.2.2. If the version changes, you can find the latest ARM (Raspberry) version here. Or you will have to search the github of your coin for the releases page and then alter the file names:

wget 'https://github.com/phoreproject/Phore/releases/download/v1.2.2/phore-1.2.2-arm-linux-gnueabihf.tar.gz'tar -xzvf phore-1.2.2-arm-linux-gnueabihf.tar.gz
mv -v phore-1.2.2/bin phore

Do not start the wallet yet.

5. Creating the Symlink

This step is important. PoS wallets have a high write activity, and microSD cards/USB sticks don’t have many write cycles. To preserve your system drive (SD Card) from corruption, let’s outsource it to a USB stick with a symlink.

Find out how your USB stick is named

cd /
cd media/pi
dir

Dir should list you one folder. It could be Toshiba/SAMSUNG/KiNgSton. Remember the spelling, because capitalization is important — if your USB stick is named KiNgSton, Linux won’t find it when you enter kingston.

Let’s go back to our /home/pi directory, create new folders on the USB stick and create the symlink. You need to edit the bold part.

cd /
cd home/pi
mkdir /media/pi/EDITTHISUSBNAME/blockchain
mkdir /media/pi/EDITTHISUSBNAME/blockchain/phore
ln -s -v /media/pi/EDITTHISUSBNAME/blockchain/phore /home/pi/.phore

It takes 1–3 days to sync on raspberry, but only a few hours on your computer. If you want to save sync time, you can copy the entire blockchain folder, including your wallet (and perhaps Masternode configuration) from your computer onto your USB stick. On Windows, the folder is located in
%appdata%/Phore
You can copy the contents of the Phore folder from your computer into the phore folder of your USB drive. The USB stick should not have this folder structure: /blockchain/phore/phore - every files need to be in the main phore folder on your USB stick.

Note: if you stake on your Raspberry and run a Masternode, make sure you update the masternode configuration or copy it from your computer. Else, the Raspberry will stake your MN collateral and your MN will stop working.

Obligatory part for other coins

In case you need to find out what the blockchain folder of your PoS coin is called, you can start the wallet first, then immediately stop it and run:

ls -all

It will show a blue colored folder named .coinname (whatever your coin is called). To create the symlink, will have to remove the folder first and then create the symlink. rm -rf removes files and folders without confirmation request, so be careful. This step is only intended if you run the wallet the first time and have no wallet.dat stored in there.

rm -rf .coinname
mkdir /media/pi/EDITTHISUSBNAME/blockchain/coinname
ln -s -v /media/pi/EDITTHISUSBNAME/blockchain/coinname .coinname

6. Start the wallet

./phore/phored -daemon -staking=1

It takes ~5–10 Minutes to load, you can check if it is running via

./phore/phore-cli getinfo

Once it is running/if your wallet is password protected, you can unlock it with

./phore/phore-cli walletpassphrase "yourpassword" 9999999999999 true

If you don’t have a password setup, your wallet starts staking automatically. This is not recommended on devices you leave unattended — anyone able to access your Raspberry can transfer your funds out!

If you get an error starting the wallet the first time run nano, then add rpcuser/password into the file. You can use any username/password.

nano ~/.phore/phore.conf
rpcuser=rpcuser
rpcpassword=rpcpassword

Save the file with ctrl+x and (y), start the wallet.

7. Creating a bootstrap / blockchain backup

In case your USB drive corrupts, it is good to have a backup ready on another USB drive. Once a month should be enough to save you a lot of syncing time. You can write down your folder names on the computer to save you time from writing everything.

Stop the Phore client

./phore/phore-cli stop

Here is my example folder for my backup plan (again, depends on your USB drive name, see above)

cp -v -r /media/pi/USB/blockchain/phore /media/pi/USB2/blockbackup

When I notice my wallet gets corrupted, I delete these folders and copy them from my backup

rm -rf ~/.phore/chainstate
rm -rf ~/.phore/blocks
cp -v -r /media/pi/BACKUPUSBDRIVENAME/blockbackup/phore/chainstate ~/.phore/chainstate
cp -v -r /media/pi/BACKUPUSBDRIVENAME/blockbackup/phore/blocks ~/.phore/blocks

8. Final tips + Rinse & Repeat

Repeat onwards from Step 4, for every new coin you want to stake on your Raspberry. Change the folder names to respective directories for installing or backing up.

I’ve run 4 wallets simultaneously on a single Raspberry Model 2, but found 3 wallets to be the most stable. You will not be able to run more wallets on a Model 3, as it also has only 1 GB memory. With 4 wallets you may run into memory issues and one wallet will crash randomly after a day, resulting in a corrupted blockchain folder. You can see which wallets are running using the command topexit it with q. uptime shows you how long your Raspberry has been running.

Do not start all wallets at once, but wait until every wallet has finished loading the blockchain data. You can see the loading status with ./phore/phore-cli getinfo and check if your wallet is staking with ./phore/phore-cli getstakingstatus “stakingstatus: true”

To reboot your Raspberry, shutdown all wallets first with (see 7. bulletpoint), then sudo reboot

You can backup your Raspberry with all configurations using this guide. Once your microSD card fails, restore it onto a new SD card within minutes.

Advanced security guides (Warning, only if you know what you’re doing. You can lock yourself out from your Raspberry)
Secure your Raspberry Pi from attackers
Using IPtables

If you have any questions or issues let me know in the comments. In case you found this guide helpful, PHR donations are welcome ;)
PA3aumaXM6hxXhk37k9JwwTSEebBTH5UDk

--

--