How to mine Bitcoin with Raspberry Pi?

Ever since the emergence of Bitcoin in 2008, people worldwide have been closely following the developments in the world of cryptocurrency. As Bitcoin’s reputation soared, going from being worth just two pizzas to a staggering $60,000 per coin, its journey has been nothing short of astonishing. Currently, there are two widely recognized ways to acquire Bitcoin: Trading and Mining.

Bitcoin mining, however, is a complex and energy-intensive process that demands specialized hardware and substantial investments. For enthusiasts and DIYers looking for a cost-effective entry into cryptocurrency mining, there’s a pathway – Raspberry Pi. The purpose of this article is to guide you through the process of mining Bitcoin using a Raspberry Pi, offering an accessible way to start mining. It’s essential to note that this is not a get-rich-quick scheme but rather a project for hobbyists.

raspberry pi bitcoin miner

Table of Contents

Configuring Raspberry Pi

Basic Configuration

  1. First, go to the official Raspberry Pi website and select and download the operating system image that matches your Raspberry Pi model.
  2. Once the operating system is installed, the next steps include configuring your Raspberry Pi, which involves connecting hardware, booting up the Raspberry Pi, and completing the initial setup.
  3. After the configuration is complete, you can interact with it through remote connections such as SSH, VNC, and SCP.

Software Updates

To ensure that your system remains up-to-date with the latest security patches and application updates while running securely on the internet, it’s important to regularly execute the following two commands:

					$ sudo apt update
$ sudo apt full-upgrade

Install all necessary packages

					$ sudo apt install htop git curl bash-completion jq qrencode dphys-swapfile hdparm

Create Blockchain Nodes

Create New User

Create the “admin” user and add it to the “sudo” group:

					$ sudo adduser admin
$ sudo usermod -aG sudo admin

The program for Bitcoin mining needs to run in the background. To ensure security, create a “bitcoin” user without system administration privileges:

					$ sudo adduser bitcoin

The first command adds the “admin” user to the “bitcoin” group. The second command assumes that the Bitcoin configuration files are stored in /path/to/config/files and changes the ownership of this directory to the “bitcoin” user and group to ensure read-only permissions:

					$ sudo usermod -aG bitcoin admin
$ sudo chown -R bitcoin:bitcoin /path/to/config/files

Restart your computer to ensure all changes take effect:

					$ sudo rebot

Create a Bitcoin Data Directory

To set user access rights, change the ownership of the /mnt/ext/ directory and all its files and subdirectories to the “bitcoin” user and the “bitcoin” group. Now, this directory is owned by the “bitcoin” user:

					$ sudo chown -R bitcoin:bitcoin /mnt/ext/

Switch to the “bitcoin” user, navigate to the external drive, and create the Raspberry Pi Bitcoin node directory:

					$ sudo su - bitcoin
$ cd /mnt/ext
$ mkdir bitcoin
$ ls -la
> total 28
> drwxr-xr-x 4 bitcoin bitcoin  4096 Dec 12 17:43 .
> drwxr-xr-x 4 root    root     4096 Dec 12 17:38 ..
> drwxr-xr-x 2 bitcoin bitcoin  4096 Dec 12 17:43 bitcoin
> drwx------ 2 bitcoin bitcoin 16384 Dec 12 17:30 lost+found


Create a test file named “test.file” in the new “bitcoin” directory and then delete it:

					$ touch bitcoin/test.file
$ rm bitcoin/test.file

Exit the “bitcoin” user session:

					$ exit


Install Bitcoin Core

Log in as “admin” and navigate to the “tmp” directory. This is a temporary directory present in Linux systems, used for storing temporary files and directories. It is typically configured to clear its contents upon reboot to ensure that temporary files do not permanently occupy disk space:

					cd /tmp

Go to the official website to download the latest Bitcoin Core:

					# download Bitcoin Core binary
$ wget
$ wget
$ wget
# check that the reference checksum matches the real checksum
# (ignore the "lines are improperly formatted" warning)
$ sha256sum --check SHA256SUMS.asc --ignore-missing
> bitcoin-0.20.1-arm-linux-gnueabihf.tar.gz: OK
# import the public key of Wladimir van der Laan, verify the signed checksum file
# and check the fingerprint again in case of malicious keys
$ gpg --import ./laanwj-releases.asc
$ gpg --refresh-keys
$ gpg --verify SHA256SUMS.asc
> gpg: Good signature from "Wladimir J. van der Laan ..."
> Primary key fingerprint: 01EA 5486 DE18 A882 D4C2 6845 90C8 019E 36C2 E964


Unpack and install the Bitcoin Core binary files and verify the installation’s success. After the installation is complete, you can launch the Bitcoin Core node using the “bitcoind” command and verify its version with “bitcoind –version.

					$ tar -xvf bitcoin-0.20.1-arm-linux-gnueabihf.tar.gz
$ sudo install -m 0755 -o root -g root -t /usr/local/bin bitcoin-0.20.1/bin/*
$ bitcoind --version
> Bitcoin Core version v0.20.1

Set Data Directory

Switch to the “bitcoin” user and create a symbolic link. When you view files in the directory located at “/home/bitcoin/.bitcoin,” you are actually seeing the files and content from the directory “/mnt/ext/bitcoin” on the external drive. This configuration allows you to store Bitcoin node data on the external drive instead of the Raspberry Pi’s internal storage, saving space and providing greater storage capacity.

					$ sudo su - bitcoin
$ ln -s /mnt/ext/bitcoin /home/bitcoin/.bitcoin


Navigate to your home directory and check for symbolic links.

					$ ls -la


Configuration File

Create the configuration file for the Bitcoin Core node and open it using the nano text editor:

					# RaspiBolt: bitcoind configuration
# /mnt/ext/bitcoin/bitcoin.conf
# Bitcoin daemon
# Network
# Connections
rpcuser=raspibolt          # Your Raspberry Pi's root username
rpcpassword=PASSWORD_[B]   # Root password
# Raspberry Pi optimizations
# Initial block download optimizations

Auto-Start at Boot

Use systemd to configure the service unit file for the Bitcoin process. This is a standard tool in Linux systems for managing system services, allowing you to ensure that the Bitcoin process runs automatically in the background, even without a user logged in.

					$ sudo nano /etc/systemd/system/bitcoind.service
# RaspiBolt: systemd unit for bitcoind
Description=Bitcoin daemon
# Service execution
ExecStart=/usr/local/bin/bitcoind-daemon\                                  -pid=/run/bitcoind/\                                  -conf=/mnt/ext/bitcoin/bitcoin.conf\                                  -datadir=/mnt/ext/bitcoin
# Process management
# Directory creation and permissions
Run as bitcoin:bitcoin
# /run/bitcoind
# Hardening measures
# Provide a private /tmp and /var/tmp.
# Mount /usr, /boot/ and /etc read-only for the process.
# Deny access to /home, /root and /run/user
# Disallow the process and all of its children to gain
# new privileges through execve().
# Use a new /dev namespace only populated with API pseudo devices
# such as /dev/null, /dev/zero and /dev/random.PrivateDevices=true
# Deny the creation of writable and executable memory mappings.


Create a symbolic link on the Linux system to link the Bitcoin data directory to the “.bitcoin” folder in the home directory of the user “admin.”

					$ ln -s /mnt/ext/bitcoin/ /home/admin/.bitcoin


Restart the Raspberry Pi used for mining Bitcoin

					$ sudo reboot


Connect External Drive

Before connecting an external drive to the Raspberry Pi, first clear the kernel message buffer, then continuously monitor new kernel messages to ensure that you can capture any new messages related to the connection and recognition of the external drive, allowing you to stay informed about the status of the external drive’s connection.

					$ sudo dmesg -C
$ sudo dmesg -w


It is recommended to physically connect the external drive to the Raspberry Pi’s USB3 port, which is usually the blue-colored port, to ensure faster data transfer speeds. Use a high-quality USB cable that comes with the external drive to ensure a stable connection.

Once the external drive is successfully connected to the Raspberry Pi, the Linux system will automatically detect and recognize the drive. You can view detailed information about this connection by using the “dmesg” command to check kernel messages. If you want to stop continuous monitoring of kernel messages, press the Ctrl and C keys together to halt the execution of “dmesg.”

> NAME        MOUNTPOINT UUID                        FSTYPE   SIZE LABEL  MODEL
> sda                                             447.1G        SATA_III_SSD
> └─sda1           9ec0b784-d448-4757-a3b2-8abd57c544f3 ext4   447.1G
> mmcblk0                                                             14.9G
> ├─mmcblk0p1 /boot      5203-DB74                       vfat     256M boot
> └─mmcblk0p2 /      2ab3f8e1-7dc6-43f5-b0db-dd5759d51d4e ext4    14.6G rootfs


Format External Drive

Format a specific partition on the external drive using the Ext4 file system. Replace “[NAME]” with the actual partition name.

					$ sudo mkfs.ext4 /dev/[NAME]


To facilitate the recognition and selection of the correct device and partition for subsequent operations, list the block device information in the system, including device name, mount point, UUID, file system type, device capacity, device label, and device model, etc.



Added a configuration line in the /etc/fstab file to specify detailed information about the device or partition to be mounted, ensuring it’s automatically mounted during system startup.

					$ sudo nano /etc/fstab
UUID=123456/mnt/extext4rw,nosuid,dev,noexec,noatime,nodiratime,auto,nouser,async,nofail 0 2


Create a new directory in the system for users to mount external devices to, making the content of the external device available within this directory. Before mounting, ensure that the directory’s ownership and permissions are set correctly to grant users access to the data within the mount point.

					$ sudo mkdir /mnt/ext


Mount all the drives configured in the /etc/fstab file and check the mounted file systems. If the mounting is successful, you should be able to see relevant file system information in /mnt/ext.

					$ sudo mount -a
$ df -h /mnt/ext
> Filesystem      Size  Used Avail Use% Mounted on
> /dev/sda1       440G   73M  417G   1% /mnt/ext


REGTEST Test Network


					y@ubuntu:~$ bitcoind -regtest -txindex -daemon 
Bitcoin server starting


Start regtest network


  • regtest: This is used to start Bitcoin in the REGTEST testing network. It’s an isolated Bitcoin test network separate from the main network and testnet. The key distinction between these networks lies in their genesis block, which means their transaction and blockchain data are separate.
  • txindex: This flag instructs the Bitcoin node to index all transactions. By default, Bitcoin nodes only index transactions related to wallet addresses for performance reasons. If you need broader access to transaction data, you can use the -txindex parameter to enable full transaction indexing.
  • daemon: This is particularly useful when setting up a Bitcoin node as a long-running service. It tells the Bitcoin node to run in the background, without displaying output in the foreground, thus preventing the node process from occupying your terminal session.

Alternatively, you can configure Bitcoin by editing its configuration file.



As shown in the diagram below, after successfully launching the Bitcoin REGTEST test network, the system will automatically create a dedicated folder for the REGTEST network in the /home/bitcoin/.bitcoin directory:


Folder dedicated to REGTEST network

Use of basic commands

Mining Bitcoin using Raspberry Pi:

					bitcoin-cli -regtest generate 500


View block information:

					y@ubuntu:~$ bitcoin-cli -regtest getblockchaininfo
  "chain": "regtest",
  "blocks": 500,
  "headers": 500,
  "bestblockhash": "0139f2493a3d10dec105df453510b7104e8155e9a536558b2760d2563c5c0f2b",
  "difficulty": 4.656542373906925e-10,
  "mediantime": 1531385979,
  "verificationprogress": 1,
  "initialblockdownload": false,
  "chainwork": "00000000000000000000000000000000000000000000000000000000000003ea",
  "size_on_disk": 156650,
  "pruned": false,
  "softforks": [
      "id": "bip34",
      "version": 2,
      "reject": {
        "status": false
      "id": "bip66",
      "version": 3,
      "reject": {
        "status": false
      "id": "bip65",
      "version": 4,
      "reject": {
        "status": false
  "bip9_softforks": {
    "csv": {
      "status": "active",
      "startTime": 0,
      "timeout": 9223372036854775807,
      "since": 432
    "segwit": {
      "status": "active",
      "startTime": -1,
      "timeout": 9223372036854775807,
      "since": 0
  "warnings": "This is a pre-release test build - use at your own risk - do not use for mining or merchant applications"


View mining results:

					y@ubuntu:~$ bitcoin-cli -regtest getbalance


View the address of the wallet account:

					y@ubuntu:~$ bitcoin-cli -regtest getaccountaddress
error code: -32
error message:
getaccountaddress is deprecated and will be removed in V0.18. To use this command, start bitcoind with -deprecatedrpc=accounts.

Assign new address:

					y@ubuntu:~$ bitcoin-cli -regtest getnewaddress


To transfer money to a new address:

					y@ubuntu:~$ bitcoin-cli -regtest sendtoaddress 2MvZH9rH1cQN6NSR6sY1Xkdku2e4hqU9aqX 100


View the details of this transaction:

					y@ubuntu:~$ bitcoin-cli -regtest listreceivedbyaddress
    "address": "2MvZH9rH1cQN6NSR6sY1Xkdku2e4hqU9aqX",
    "account": "",
    "amount": 100.00000000,
    "confirmations": 1,
    "label": "",
    "txids": [


Generate a block so that the transaction is confirmed:

					y@ubuntu:~$ bitcoin-cli -regtest generate 1 


View the Bitcoins received:

					y@ubuntu:~$ bitcoin-cli -regtest listreceivedbyaddress
    "address": "2MvZH9rH1cQN6NSR6sY1Xkdku2e4hqU9aqX",
    "account": "",
    "amount": 100.00000000,
    "confirmations": 1,
    "label": "",
    "txids": [

Scroll to Top