Building Monero from Source on the Raspberry Pi 3 B+ running Fedora 28

Posted on Sat 01 September 2018 in how-to

Monero is one of the better known crypto currencies (beside Bitcoin, obviously). The project provides builds for several distributions and architectures.

But there's one big issue with the Raspberry Pi 3 Model B+: It's ARMv8 core doesn't support aes natively, but the monero builds will require them.

Let's talk about how to build Monero on the Pi when you're running Fedora 28.

Requirements

This section basically splits into two parts: packages and swap.

As for the packages simply install the builds requirements and you're good to go:

dnf install gcc cmake pkgconf boost-devel openssl-devel cppzmq-devel libsodium-devel libunwind-devel xz-devel readline-devel ldns-devel expat-devel gtest-devel doxygen graphviz pcsc-lite pcsc-lite-devel boost-static libstdc++-static libstdc++-devel

Most likely you'll have less than 2 GB of swap for your system. This will become a problem when building the binaries. You can check the current amount with free.

If so a temporary 3 GB swap file should be created as follows:

dd if=/dev/zero of=/3gbbuildswap bs=1M count=3072

chmod 600 /3gbbuildswap
mkswap /3gbbuildswap
swapon /3gbbuildswap

You can check free again to verify that the additional swap space is now available.

Building

First let's download the source:

cd /opt
git clone --recursive https://github.com/monero-project/monero
cd monero
git checkout v0.12.3.0

To make sure the aes cpu extension is not required for the ARMv8 build you can use this patch file:

git apply monero_fix_aes_arm8.patch

Afterwards you can start the build process, which may take a day. Yes, a full day.

make
make release-static-linux-armv8

If the process is being killed or your Pi reboots just re-enable the swap file trigger the last command again.

Binary foo and importing the blockchain

In the meantime you should download the current blockchain dump:

wget https://downloads.getmonero.org/blockchain.raw -O /opt/blockchain.raw 

The RAW blockchain file can be imported by monero after the build process has ended. But caution: The import process takes a lot of memory and it's likely that it will fail at some point.

First you can create a version specific dir for the build files and copy the binaries to thisdir:

mkdir /opt/monero-v0.12.3.0
cp -R /opt/monero/build/release/bin/* /opt/monero-v0.12.3.0/

To make sure monero is not running as root you may want to create a user called monero by running adduser monero.

After that start the import process as user monero:

su - monero
cd /opt/monero-v0.12.3.0/
./monero-blockchain-import --input-file /opt/blockchain.raw

systemd unit

When the process has finished (successfully or with errors) it's time to set up a systemd unit file:

echo '[Unit]
Description=Monero Full Node
After=network.target

[Service]
User=monero
Group=monero
WorkingDirectory=~

Type=forking
PIDFile=/opt/monero-v0.12.3.0/monerod.pid
ExecStart=/opt/monero-v0.12.3.0/monerod --detach --pidfile /opt/monero-v0.12.3.0/monerod.pid

[Install]
WantedBy=multi-user.target' > /etc/systemd/system/monerod.service
systemctl daemon-reload
systemctl enable monerod.service
systemctl start monerod.service

Even if the import process has finished successfully your blockchain will be behind the blockchain. To check the progress of syncing it with the network you can simply tail /opt/monero-v0.12.3.0/.bitmonero/bitmonero.log.