CPU Mining on a Raspberry Pi | xmrig

CPU Mining on a Raspberry Pi  (XMRig)

Originally published at blog.ijasoneverett.com on  

Monero is one of the most profitable cryptocurrencies that can still be mined using a CPU. Unlike other cryptocurrencies that rely on specialized hardware, you can mine XMR (RandomX) using your computer or, in this case, a raspberry pi. With that said if you’re going to use your raspberry pi to mine Monero don’t expect to get rich doing so. This is more of a learning experience if you have a spare raspberry pi lying around or if you simply want to support the coin.

To get started, you should already have Raspian running on your pi. If you haven’t done so already I suggest you follow one of the many tutorials out there. Its your choice whether you choose to have a monitor, keyboard and mouse attached to your pi or if you prefer to go headless and utilize SSH. I prefer the latter but this tutorial can be done either way. We’re going to be using XMRig to mine Monero with a mining pool. XMRig only runs on 64-bit so we’ll be using a 64-bit container called raspbian-nspawn-64

First let’s make sure you’re raspberry pi is up to date. Using terminal lets run the following commands:

sudo apt update
sudo apt full-upgrade

For good measure, lets run clean up to free up some space:

sudo apt-get clean

Reboot if necessary:

sudo shutdown -r now

Once you’re pi is up to date, we can get started installing raspbian-nspawn-64 using the following command: **Note!! Inorder for you to be able to perform the below commands you will need to be on 64-bit

sudo apt-get install -y raspbian-nspawn-64

If you’re not currently using the official 64-bit kernel, you’ll be prompted to enable it during installation. Select Yes and you should be prompted to reboot afterwards. If you were already using the 64-bit kernel then a reboot isn’t necessary. Once everything is installed and you’ve rebooted if necessary, you can start using the 64-bit container with the following command:

ds64-shell


.

To return to 32-bit simply type exit. You can toggle between 32-bit and 64-bit with these commands.

Now let’s install XMRig from within your 64-bit shell. First you’ll need to install all the dependencies.


    sudo apt-get install git build-essential cmake libuv1-dev libssl-dev
    libhwloc-dev
 

Once thats finished with hopefully no errors run the following commands: **Note!! Inorder for you to be able to perform the below commands you will need to be on 64-bit

git clone https://github.com/xmrig/xmrig.git
cd xmrig
mkdir build
cd build
cmake ..
make

The build process can take some time to complete so be patient. After installation the next step is to choose a mining pool and start mining. I choose supportxmr because of their low pool fee but feel free to choose what best works for you. 

To start mining type: 

./xmrig --donate-level 1 -o pool.supportxmr.com:3333 -u 41nQCM9dLAH5NYycB46pfcUc85UpHkXY11gRDeSfh3rJQ5bKGXjtTrxiwyZfKJehjKeoyBRKpYo6gWqF1Jrsp17dFbMq9B3 -p YourWorkerName
 

Make sure you run this from the build folder. If you aren’t already there then type

 

cd xmrig/build

–donate-level can be set to whatever you feel like donating to the pool.
-o is the URL of your pool.
-u should be your Monero wallet address. Make sure to change that to your address or else you’ll be giving to me free XMR!
-p stands for password but since SupportXMR doesn't require a password, this is used to identify your worker so give it a unique name.

That's all you need to get started mining Monero on your Raspberry Pi.

For other XMRig options use 

./xmrig -h

Below is the outcome screenshot to show you that it has started mining


















Install on Ubuntu Platform

  1. Install dependencies: sudo apt install git build-essential cmake libuv1-dev uuid-dev libssl-dev
  2. Clone source code from github: git clone https://github.com/xmrig/xmrig-proxy.git
  3. Create build directory: mkdir xmrig-proxy/build
To update exist (already cloned) source, goto to the build directory and run git pull.

Build

cd xmrig-proxy/build
cmake ..
make -j$(nproc)

Post a Comment

4 Comments

  1. -- WITH_MSR=OFF
    -- Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY OPENSSL_INCLUDE_DIR)
    CMake Error at cmake/OpenSSL.cmake:47 (message):
    OpenSSL NOT found: use `-DWITH_TLS=OFF` to build without TLS support
    Call Stack (most recent call first):
    CMakeLists.txt:185 (include)

    ReplyDelete
  2. If narrowing error:

    make CXX_FLAGS="-Wno-narrowing"

    ReplyDelete
  3. I needed to adjust two things:

    1) The default option for apt-get is to download using IPv6, so I used the procedure in "https://www.vultr.com/docs/force-apt-get-to-ipv4-or-ipv6-on-ubuntu-or-debian" to force it to use IPv4.

    2) I needed to clone the dev branch of xmrig to get around a "narrowing conversion" error in DaemonClient.cpp (https://github.com/xmrig/xmrig/issues/2527) using the command:

    git clone --branch dev https://github.com/xmrig/xmrig.git

    Thanks for the outline - hope this helps out others.

    ReplyDelete