CPU Mining on a Raspberry Pi
Tags: raspberrypi, xmr, monero, randomx
Published: 2020-08-02 21:21:09

---
title: CPU Mining on a Raspberry Pi
published: true
date: 2020-08-02 20:58:59 UTC
tags: RaspberryPi,XMR,Monero,RandomX
canonical_url: http://blog.ijasoneverett.com/2020/08/cpu-mining-on-a-raspberry-pi/
---

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](https://www.raspberrypi.org/documentation/raspbian/). 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](https://github.com/xmrig/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](https://github.com/sakaki-/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:  
`ds64-shell`  
 ![](https://i2.wp.com/blog.ijasoneverett.com/wp-content/uploads/2020/08/64bitContainer.png?resize=600%2C47).

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 ..
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](https://www.supportxmr.com/) 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`

[![](https://i2.wp.com/blog.ijasoneverett.com/wp-content/uploads/2020/08/Screen-Shot-2020-08-02-at-3.54.45-PM.png?resize=600%2C224)](https://i2.wp.com/blog.ijasoneverett.com/wp-content/uploads/2020/08/Screen-Shot-2020-08-02-at-3.54.45-PM.png)