CPU Mining on a Raspberry Pi

Crypto Mining

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:
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:

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:
git clone https://github.com/xmrig/xmrig.git
cd xmrig
mkdir build
cd build
cmake ..

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 49NU9LmdsTc1KCiiRd9LE4Qm23gt1i75vWHsTGhB8agy93K4cq16KVtLKifsBy3YdzT2Zg69ggDKfDq5YdnfWshG6BZxGh3 -p YourWorkerName

Make sure you run this from the build folder. If you aren’t already there then its 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 doesnt require a password, this is used to identify your worker so give it a unique name.

Thats all you need to get started mining Monero on your Raspberry Pi.

For other XMRig options use ./xmrig -h


I got a lot of errors once in the 64 shell…
After this operation, 307 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Err:1 http://deb.debian.org/debian buster/main arm64 perl-modules-5.28 all 5.28.1-6
404 Not Found [IP: 80]
Err:2 http://deb.debian.org/debian buster/main arm64 libperl5.28 arm64 5.28.1-6
404 Not Found [IP: 80]
Err:3 http://deb.debian.org/debian buster/main arm64 linux-libc-dev arm64 4.19.98-1
404 Not Found [IP: 80]
Err:4 http://deb.debian.org/debian buster/main arm64 libcurl4 arm64 7.64.0-4
404 Not Found [IP: 80]
Err:5 http://deb.debian.org/debian buster/main arm64 git-man all 1:2.20.1-2+deb10u1
404 Not Found [IP: 80]
Err:6 http://deb.debian.org/debian buster/main arm64 git arm64 1:2.20.1-2+deb10u1
404 Not Found [IP: 80]
Err:7 http://deb.debian.org/debian buster/main arm64 libssl-dev arm64 1.1.1d-0+deb10u2
404 Not Found [IP: 80]
E: Failed to fetch http://deb.debian.org/debian/pool/main/p/perl/perl-modules-5.28_5.28.1-6_all.deb 404 Not Found [IP: 80]
E: Failed to fetch http://deb.debian.org/debian/pool/main/p/perl/libperl5.28_5.28.1-6_arm64.deb 404 Not Found [IP: 80]
E: Failed to fetch http://deb.debian.org/debian/pool/main/l/linux/linux-libc-dev_4.19.98-1_arm64.deb 404 Not Found [IP: 80]
E: Failed to fetch http://deb.debian.org/debian/pool/main/c/curl/libcurl4_7.64.0-4_arm64.deb 404 Not Found [IP: 80]
E: Failed to fetch http://deb.debian.org/debian/pool/main/g/git/git-man_2.20.1-2+deb10u1_all.deb 404 Not Found [IP: 80]
E: Failed to fetch http://deb.debian.org/debian/pool/main/g/git/git_2.20.1-2+deb10u1_arm64.deb 404 Not Found [IP: 80]
E: Failed to fetch http://deb.debian.org/debian/pool/main/o/openssl/libssl-dev_1.1.1d-0+deb10u2_arm64.deb 404 Not Found [IP: 80]
E: Unable to fetch some archives, maybe run apt-get update or try with –fix-missing?
any suggestions on how to fix it? I’m fairly new to this

Hi Jeff,

got the same problem. Following the last message of apt-get command, I ran an apt-get update inside ds64-shell:

[email protected]:~ $ sudo ds64-shell
Connected to machine debian-buster-64. Press ^] three times within 1s to exit session.
[email protected]:~# sudo apt-get update
Scaricamento di:1 http://deb.debian.org/debian buster InRelease [121 kB]
Scaricamento di:2 http://deb.debian.org/debian buster/main arm64 Packages [7.736 kB]
Scaricamento di:3 http://deb.debian.org/debian buster/main Translation-it [4.853 kB]
Scaricamento di:4 http://deb.debian.org/debian buster/main Translation-en [5.968 kB]
Recuperati 18,7 MB in 54s (344 kB/s)
Lettura elenco dei pacchetti… Fatto
N: Il repository “http://deb.debian.org/debian buster InRelease” ha modificato il valore “Version” da “10.3” a “10.6”

After that, I was able to execute

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

property, and all following commands.

Hope this helps.

Leave a Reply to Oliv Cancel reply

Your email address will not be published. Required fields are marked *

Please Do the Math      

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: