2021 Raspberry Pi 4 Mining 2GB vs 4GB
Let’s start out with the OS, use the Raspberry Pi Imager to flash Raspberry Pi OS Lite. We used both a 16 GB SD card and 32 GB SD card and saw no difference. Quality of SD card will play into lifespan, maybe.

Once you are done flashing the card go to the “windows readable” drive ( the one explorer wants to open ), and create a file called ssh, it should be blank and the file name is just the 3 letters. You may have to tell explorer to show file extensions, to make it easier.

Eject and load into the pi 4, only need wired network and power. Watch your LAN for a new address assigned, use putty or another terminal to ssh in using the default ‘pi’ / ‘raspberry’ credentials. Get ready to upgrade/update/install a bunch of stuff. If you want to save 1% on mining you would do that after extracting the code and before compiling the software. I will not teach that. Back to what to run, get ready to copy and paste. In order. Without skipping. I will talk only when there in interactions, otherwise keeping it simple.
sudo apt update
sudo apt -y full-upgrade
sudo apt-get install -y raspbian-nspawn-64
Enable 64-bit kernel? [YES] <- Just press the enter key
sudo reboot
sudo ds64-shell
apt update
apt-get -y install git build-essential cmake libuv1-dev libssl-dev libhwloc-dev
git clone https://github.com/xmrig/xmrig.git
cd xmrig
This is when you edit before compile...
mkdir build
cd build
cmake ..
make
cp xmrig /usr/local/bin
Pool Selection
Making the most profitable, even in Bitcoin. Check out https://pool-pay.com
Some days I just need a bunch of a specific coin, every day is different.
https://github.com/insidenothing/medium/blob/main/crypto/mining/startup_scripts/pool-pay.sh
If registration is closed check for updates on discord, until it is open you can pick a pool like https://keva.pool-pay.com/
https://github.com/insidenothing/medium/blob/main/crypto/mining/startup_scripts/keva.pool-pay.sh
The donations in the startup scripts go to the pool.
https://github.com/insidenothing/medium/blob/main/crypto/mining/startup_scripts/bloc.sh
Example Script
cd ~
nano bloc.sh
[copy, paste, and update to your needs]
chmod +x bloc.sh
./bloc.sh
Cleanup, Notes and Security
Change that password, do not expose to the internet, “sudo apt-get clean” on the main OS and the ds64-shell. Create a shell script miner.sh to hold your command. Have a few, one for each pool or whatever. Set Up Wi-Fi. Add a cooling fan. Make a Pi rack to hold as many as you can power. Pinch thoes pennies and recompile without donations and setup your own pool and zero out that so you get 100%. Contribute to the community.
Let’s put the 2GB against the 4GB
To start out let’s look at a hard one. https://github.com/insidenothing/medium/blob/main/crypto/mining/startup_scripts/bloc.miner.sh
2GB cn-heavy
pi@debian-buster-64:~ $ ./mine.sh
* ABOUT XMRig/6.10.0 gcc/8.3.0
* LIBS libuv/1.24.1 OpenSSL/1.1.1d hwloc/1.11.12
* HUGE PAGES supported
* 1GB PAGES unavailable
* CPU ARM Cortex-A72 (1) 64-bit -AES
L2:0.0 MB L3:0.0 MB 4C/4T NUMA:1
* MEMORY 1.0/1.8 GB (58%)
* DONATE 1%
* POOL #1 blo.pool-pay.com:3393 algo auto
* COMMANDS hashrate, pause, resume, results, connection
* OPENCL disabled
* CUDA disabled
[2021–03–31 17:58:12.011] net use pool blo.pool-pay.com:3393 144.76.173.210
[2021–03–31 17:58:12.011] net new job from blo.pool-pay.com:3393 diff 698 algo cn-heavy/xhv height 0
[2021–03–31 17:58:12.011] cpu use profile cn-heavy (4 threads) scratchpad 4096 KB
[2021–03–31 17:58:13.353] cpu READY threads 4/4 (4) huge pages 0% 0/8 memory 16384 KB (1341 ms)
[2021–03–31 17:58:29.884] cpu accepted (1/0) diff 698 (141 ms)
| CPU # | AFFINITY | 10s H/s | 60s H/s | 15m H/s |
| 0 | 0 | 2.63 | n/a | n/a |
| 1 | 1 | 2.63 | n/a | n/a |
| 2 | 2 | 2.52 | n/a | n/a |
| 3 | 3 | 2.63 | n/a | n/a |
| — | — | 10.41 | n/a | n/a |
[2021–03–31 17:59:01.448] miner speed 10s/60s/15m 10.41 n/a n/a H/s max 10.73 H/s
4GB cn-heavy
root@debian-buster-64:~# ./bloc.sh
* ABOUT XMRig/6.10.0 gcc/8.3.0
* LIBS libuv/1.24.1 OpenSSL/1.1.1d hwloc/1.11.12
* HUGE PAGES supported
* 1GB PAGES unavailable
* CPU ARM Cortex-A72 (1) 64-bit -AES
L2:0.0 MB L3:0.0 MB 4C/4T NUMA:1
* MEMORY 0.9/3.7 GB (24%)
* DONATE 1%
* POOL #1 blo.pool-pay.com:3393 algo auto
* COMMANDS hashrate, pause, resume, results, connection
* OPENCL disabled
* CUDA disabled
[2021–03–31 19:24:32.114] net use pool blo.pool-pay.com:3393 144.76.173.210
[2021–03–31 19:24:32.114] net new job from blo.pool-pay.com:3393 diff 698 algo cn-heavy/xhv heig ht 0
[2021–03–31 19:24:32.114] cpu use profile cn-heavy (4 threads) scratchpad 4096 KB
[2021–03–31 19:24:33.304] cpu READY threads 4/4 (4) huge pages 0% 0/8 memory 16384 KB (1189 ms)
[2021–03–31 19:24:47.527] cpu accepted (1/0) diff 698 (191 ms)
| CPU # | AFFINITY | 10s H/s | 60s H/s | 15m H/s |
| 0 | 0 | 3.05 | n/a | n/a |
| 1 | 1 | 2.94 | n/a | n/a |
| 2 | 2 | 3.05 | n/a | n/a |
| 3 | 3 | 3.05 | n/a | n/a |
| — | — | 12.09 | n/a | n/a |
[2021–03–31 19:25:00.569] miner speed 10s/60s/15m 12.09 n/a n/a H/s max 12.20 H/s
[2021–03–31 19:25:08.597] net new job from blo.pool-pay.com:3393 diff 698 algo cn-heavy/xhv height 0
Ok, here is a challenge for the 2 GB system where the 4GB should be ok.
Let’s try to rent to nichehash some RandomXmonero.
https://github.com/insidenothing/medium/blob/main/crypto/mining/startup_scripts/nicehash.sh
2GB rx/0
* ABOUT XMRig/6.10.0 gcc/8.3.0
* LIBS libuv/1.24.1 OpenSSL/1.1.1d hwloc/1.11.12
* HUGE PAGES supported
* 1GB PAGES unavailable
* CPU ARM Cortex-A72 (1) 64-bit -AES
L2:0.0 MB L3:0.0 MB 4C/4T NUMA:1
* MEMORY 1.0/1.8 GB (58%)
* DONATE 1%
* POOL #1 stratum+tcp://randomxmonero.usa-east.nicehash.com:3380 algo rx/0
* COMMANDS hashrate, pause, resume, results, connection
* OPENCL disabled
* CUDA disabled
[2021–03–31 19:32:16.744] net use pool randomxmonero.usa-east.nicehash.com:3380 172.65.202.202
[2021–03–31 19:32:16.744] net new job from randomxmonero.usa-east.nicehash.com:3380 diff 298863 algo rx/0 height 2329225
[2021–03–31 19:32:16.745] cpu use argon2 implementation default
[2021–03–31 19:32:17.945] randomx init dataset algo rx/0 (4 threads) seed f456ce694015a95e…
[2021–03–31 19:32:17.945] randomx not enough memory for RandomX dataset
[2021–03–31 19:32:17.945] randomx failed to allocate RandomX dataset, switching to slow mode (1 ms)
[2021–03–31 19:32:19.517] net new job from randomxmonero.usa-east.nicehash.com:3380 diff 298863 algo rx/0 height 2329225
[2021–03–31 19:32:20.619] randomx dataset ready (2673 ms)
[2021–03–31 19:32:20.619] cpu use profile rx (4 threads) scratchpad 2048 KB
[2021–03–31 19:32:20.624] cpu READY threads 4/4 (4) huge pages 0% 0/4 memory 8192 KB (5 ms)
[2021–03–31 19:32:31.835] net new job from randomxmonero.usa-east.nicehash.com:3380 diff 298863 algo rx/0 height 2329225
[2021–03–31 19:32:32.419] net new job from randomxmonero.usa-east.nicehash.com:3380 diff 298863 algo rx/0 height 2329226
| CPU # | AFFINITY | 10s H/s | 60s H/s | 15m H/s |
| 0 | 0 | 10.73 | n/a | n/a |
| 1 | 1 | 10.94 | n/a | n/a |
| 2 | 2 | 11.04 | n/a | n/a |
| 3 | 3 | 10.94 | n/a | n/a |
| — | — | 43.65 | n/a | n/a |
[2021–03–31 19:32:36.905] miner speed 10s/60s/15m 43.65 n/a n/a H/s max 43.76 H/s
4GB rx/0
* ABOUT XMRig/6.10.0 gcc/8.3.0
* LIBS libuv/1.24.1 OpenSSL/1.1.1d hwloc/1.11.12
* HUGE PAGES supported
* 1GB PAGES unavailable
* CPU ARM Cortex-A72 (1) 64-bit -AES
L2:0.0 MB L3:0.0 MB 4C/4T NUMA:1
* MEMORY 0.9/3.7 GB (24%)
* DONATE 1%
* POOL #1 stratum+tcp://randomxmonero.usa-east.nicehash.com:3380 algo rx/0
* COMMANDS hashrate, pause, resume, results, connection
* OPENCL disabled
* CUDA disabled
[2021–03–31 19:34:14.145] net use pool randomxmonero.usa-east.nicehash.com:3380 172.65.202.202
[2021–03–31 19:34:14.145] net new job from randomxmonero.usa-east.nicehash.com:3380 diff 298863 algo rx/0 height 2329226
[2021–03–31 19:34:14.145] cpu use argon2 implementation default
[2021–03–31 19:34:15.345] randomx init dataset algo rx/0 (4 threads) seed f456ce694015a95e…
[2021–03–31 19:34:15.345] randomx allocated 2336 MB (2080+256) huge pages 0% 0/1168 +JIT (1 ms)
[2021–03–31 19:34:32.849] net new job from randomxmonero.usa-east.nicehash.com:3380 diff 298863 algo rx/0 height 2329226
[2021–03–31 19:34:48.076] randomx dataset ready (32731 ms)
[2021–03–31 19:34:48.077] cpu use profile rx (4 threads) scratchpad 2048 KB
[2021–03–31 19:34:48.084] cpu READY threads 4/4 (4) huge pages 0% 0/4 memory 8192 KB (7 ms)
[2021–03–31 19:35:07.074] net new job from randomxmonero.usa-east.nicehash.com:3380 diff 298863 algo rx/0 height 2329226
| CPU # | AFFINITY | 10s H/s | 60s H/s | 15m H/s |
| 0 | 0 | 23.56 | n/a | n/a |
| 1 | 1 | 23.77 | n/a | n/a |
| 2 | 2 | 23.77 | n/a | n/a |
| 3 | 3 | 23.98 | n/a | n/a |
| — | — | 95.07 | n/a | n/a |
[2021–03–31 19:35:33.832] miner speed 10s/60s/15m 95.07 n/a n/a H/s max 95.57 H/s
Conclusions
cn-heavy: 2.63 per core to 3.05, I would go with the 2GB and buy a second.
rx/0: 10.94 per core to 23.77, Spend $20 more and double your hashing.

Hash at different places, on different coins, testing is the only way to make sure you will make what you intend, and get it to a wallet.
I really hope this helps someone decide between different versions of the Raspberry Pi for their application!!
If you hash with an 8GB version let us know how it works in the comments!!