Mining Bitcoins with Raspberry Pi – Part 3

Continuing on from the good work we have achieved thus far in Part 1 & Part 2, we are going to complete our Bitcoin Mining journey by making our Raspberry Pi start mining as soon as it is powered on.

We previously had the following command to start the cgminer application as a background process (i.e. a service)

sudo nohup ./cgminer --compact --real-quiet --config /path/to/config.conf >/dev/null 2>&1&

Now, we are going to take that command, change it up one final time and have it run upon startup.

First, lets open up rc.local file, which contains startup commands with nano by doing the following

sudo nano /etc/rc.local

Next, create some space above this line

exit 0

In this space, we will put in our cgminer as a background process command with a few changes below

nohup /home/pi/cgminer/cgminer --compact --real-quiet --config /home/pi/path/to/config.conf >/dev/null 2>&1&

So what’s changed?

Firstly, we have removed the use of sudo which elevates us to an administrator. Anything ran from the rc.local file will be run by the root user and thus there is no need for sudo.

Secondly, we have changed the path of both cgminer and the config file so that it is the full path. Previously we made use of the ~ character which is shorthand for the current users home directory. Once again, this isn’t relevant to the root user as we git cloned cgminer to the home directory of our standard user on the Raspberry Pi which is pi. All home directories in Raspbian are located under /home/ and thus the full path to any folders or files located in our home directory is /home/pi/

Once you have successfully edited the file in nano, hit CTRL-X followed by y to exit and save the file.

Now you can restart your Raspberry Pi to test. To do so from the command line punch in

sudo shutdown -r now

After the restart, check the running processes/services with the top command


If you got your paths correct you will see cgminer ticking away.

That’s it. Thanks for following along on journey of mining the cryptocurrency Bitcoin on the humble Raspberry Pi with USB ASIC mining hardware. Not only have we covered using cgminer but also vital parts of Linux such as the nohup command, top, kill as well as using the rc.local file.

Chime in below with your results or if you have any other suggestions for a Raspberry Pi project!

James Written by:


  1. Danesh Forouhari

    Hello. Thanks ifor the great write up.
    Question: Is there any value in using a cluster of RasPis (using some cluster programming) in running copies of a bitminer? Obviously, each node in the cluster would have a USB ASIC miner attached to it.


    • 22/09/2015

      Hey Danesh. Thanks for reading through the series.

      In terms of using a clustered RaspPi setup; couple of things to remember:

      a) RasPi acts as a controller/interface for the USB ASIC, adding more Pis just adds more controllers
      b) the power of these small USB ASICs are tiny and you shouldn’t expect a Return on Investment

      If you understand the two points above, then running the Pis in a cluster would be a learning experience in itself and from that perspective would be valuable.
      There would not however be any monetary/bitcoin mining prowess gains.


      EDIT: Just to clear up any confusion, you could add more USB ASIC (via a USB Hub) to a single Pi for more mining power.

Helpful? Have a question on the above?