Internet Defense League script

Monday, October 13, 2014

Compile Bitcoin Core on Raspberry Pi (Raspbian)

If you want to run a full node on the Bitcoin network, you might want to do so on a computer that doesn't use so much power and is very inexpensive. The Raspberry Pi is an obvious choice for that. Here's a tutorial on how to install the newest version of Bitcoin Core on the Raspbian OS, which is based on the Debian GNU/Linux distribution. If you have used Debian or Ubuntu Linux, you'll find many things familiar about Raspbian.

The Raspbian repositories currently contain a very old version of the original Bitcoin client, Bitcoin Core. And in fact, only the text based back-end, bitcoind, not the graphical front-end bitcoinqt. It is, however, possible to compile the newest version of Bitcoin Core yourself. This process takes a while, but most of the time the system spends on its own while you needn't intervene. To follow this tutorial, basic Linux/Unix command line experience is recommended, but probably not a requirement.

Here be dragons! Note that Bitcoin technology is generally experimental, and so is this tutorial, so don't use any significant amount of BTC with any system that you setup while following this tutorial. Also note that the relatively weak system that forms a Raspberry Pi, may or may not be able to handle the task of acting as a Bitcoin node satisfactorily.


  • A Raspberry Pi, model B, rev 2 or model B+. Unfortunately the compiling process needs the 512 MB RAM that these models have, but it may be possible to compile on a 512 MB model, and then move the SD card to a model with 256 MB RAM afterwards.
  • SD card of at least 32 GB (it must be large enough to hold the entire block chain).
  • A clean install of the Raspbian OS on the SD card. Raspbian is a version of Debian Linux for the Pi. For instructions on this, please refer to the guide on
  • Network cable, and possibly a case for the Pi, and a keyboard and mouse, unless you plan to ssh into the Pi from another computer.

Initial steps

In order to compile and run, Bitcoin Core depends on some other tools which must be installed prior to compiling. Most are available from the Raspbian repositories and are easily installable via apt-get.

  1. Install Raspbian on your SD card, if you haven't done so already.
  2. Log into a command line on your Raspberry Pi, either via attached keyboard or make an ssh connection to it.
  3. Run the Pi configuration tool:
    sudo raspi-config
    In the menu, choose to expand the file system. Then, in "Internationalisation options", choose "Change locale", then in the list make sure that at least "en_US.UTF-8 UTF-8" is checked ("en_GB.UTF-8 UTF-8" should be checked already). Choose "OK" to build the locales. Change your timezone. Exit the Pi configuration tool and select yes when it asks to reboot. Otherwise, reboot from the command line with sudo reboot
  4. Change the password for your user from the default into a strong password. The is especially important if you want to run a full node and thereby run a computer connected to the Internet 24/7. But it's advised to change it anyway:
  5. Update your Raspbian system by issuing the two commands:
    sudo apt-get update
    sudo apt-get upgrade
  6. Install some dependencies:
    sudo apt-get install build-essential autoconf libssl-dev libboost-dev \
    libboost-chrono-dev libboost-filesystem-dev libboost-program-options-dev \
    libboost-system-dev libboost-test-dev libboost-thread-dev
  7. If you want the graphical frontend, also install the following dependencies. If you just want bitcoind, you can skip this step.
    sudo apt-get install libqt4-dev libprotobuf-dev protobuf-compiler \
  8. Create a directory which we will use for downloading and compiling various stuff, then enter it:
    mkdir ~/bin
    cd ~/bin

Compiling and installing Berkeley DB 4.8

Compiling Bitcoin Core requires the Berkeley DB version 4.8 which is not available in the Raspbian repositories, so we must compile and install it manually. Note that if you don't need a wallet (i.e. if you want to run a headless Bitcoin node and keep your wallet elsewhere) you can completely skip this section and jump directly to downloading and compiling Bitcoin Core.

  1. Download the Berkeley DB, uncompress it, and cd into the uncompressed directory:
    tar -xzvf db-4.8.30.NC.tar.gz
    cd db-4.8.30.NC/build_unix/
  2. Then, configure the system for compiling, do the actual compile job with make (will take a good while), and then install Berkeley DB:
    ../dist/configure --enable-cxx
    sudo make install

Downloading and Compiling Bitcoin Core

We're now ready to download and compile Bitcoin Core itself.

  1. Go to the branches list on the Bitcoin Core project site, locate the latest version number, and substitute "0.9.3" in the command below with that. This tutorial is known to work with version 0.9.3, but a newer version is recommended if there is one.
    cd ~/bin/
    git clone -b 0.9.3
    cd bitcoin/
  2. The following three commands will configure the system for compilation, then do the actual compile job. The last command make will probably take several hours to complete.
    ./configure CPPFLAGS="-I/usr/local/BerkeleyDB.4.8/include -O2" \
    Note: If you skipped the Berkeley DB 4.8 dependency above because you don't need a wallet, you must add "--disable-wallet" (without the quotation marks) to the end of the line that starts with ./configure above.

Installing and Running Bitcoin Core

  1. To install the compiled Bitcoin Core on the system, perform the following command:
    sudo make install
    After that, you will be able to run Bitcoin Core from anywhere on the system by simply typing: bitcoind (the text based backend) or bitcoin-qt (the graphical frontend).
  2. If you want to automatically start bitcoind on startup, e.g. if you want to set up a headless Bitcoin node, add the following line to the file /etc/rc.local:
    su pi -c '/usr/local/bin/bitcoind &'
    Add the line anywhere before the already existing exit 0 line. You can run a text based editor by typing "sudo nano /etc/rc.local", or a graphical text editor (if you're working in a graphical environment) by typing "sudo gedit /etc/rc.local", then pasting the script above and saving (in Nano, save and exit with Ctrl-X, then Y, then Enter).

    Now the bitcoind daemon will start when the system boots.

Open the port for Bitcoin traffic

If you followed this tutorial to run a full Bitcoin node, don't forget to forward traffic on port 8333 to the Raspberry Pi. How to do this varies from network to network, but typically involves entering the web interface of your network router or modem, and setting up "Port Forwarding" there. Typically this is done by simply adding the local IP address of the Raspberry Pi along with port number 8333 to a list of forwarded ports. Refer to the documentation from your router/modem's manufacturer on how to do this exactly. Some routers even do this automatically so you don't need to do anything.

In order to find your Raspberry Pi's local IP address (assuming you're not connecting to it via SSH in which case you already have the IP address), log in to it and run the command:

ip addr show eth0
Look for the line that starts with the word inet. So if the line starts with "inet", your IP address is "". You can verify that it works by checking the amount of connections after having run Bitcoin Core for a while. If it goes above 8 connections, you have successfully forwarded traffic on port 8333 to your Pi.


This concludes this tutorial on how to set up a recent version of Bitcoin Core on a Raspberry Pi. You should now be able to "sudo reboot" your Pi, whereafter it starts bitcoind and begins to download the blockchain. You can always check the status of bitcoind by logging in and typing "bitcoind getinfo".

In the future I might offer an almost ready-to-run .img file that you can just transfer to an SD card, make a few easy adjustments, and then you're ready to go, without the need for compiling any software. Although this will make it much easier to set up a Raspberry Pi Bitcoin node, it has the disadvantage that you will have to trust me not to have altered the software to do bad things. Suggestions and comments are welcome.

If you liked the tutorial, please consider donating an amount of your choice to the address or QR code to the right.

Disclaimer: Use this guide at your own risk. The author of this guide is in no way responsible for any loss, even when following the guide to the last comma. You're responsible for your own money. Don't do anything with it that you don't feel 100% comfortable with, and only test things out using small amounts.


  1. Excellent work, but I think I'll wait for that image file. Bricked my Pogoplug trying to run stuff via Linux command line...

  2. Thank you for taking the time to spell this out! I just got a RP and was looking for something just like this. Sent you $1.00 in BTC just now for your efforts!

  3. Yeah, but does it *actually work*? What is your CPU load? What is your network load? What is your storage load? Isn't a pi just too weak a hardware to run a bitcoind node?

    1. Of course, don't expect too much from your Pi. After all it is just a 700 MHz CPU and 512 MB RAM. bitcoind will naturally run better on stronger hardware. You may have trouble getting it to run on your Pi because of its specs. Perhaps I should add a comment to the tutorial about that.

  4. Thanks.
    What Are Bitcoin Nodes and Why Do We Need Them? via @coindesk

    1. Thanks for the link to a very informative article.

  5. What sort of hashrate could one expect from this setup?

    1. None. This is not bitcoin mining. You will need specialized mining hardware (and lots and lots of it!) to actually mine bitcoin. Not feasible for most people.

  6. Fantastic way to get kids into computing and learning how to program well done thank you

  7. I have followed the tutorial step by step and when I try to start either the bitcoind or the bitcoin-qt I get an error that reads, "error while loading shared libraries: cannot open shared object file: No such file or directory"

    1. It seems that your system cannot find the Berkeley DB 4.8 installation. Did you notice any errors while compiling and/or installing Berkeley DB 4.8? What does this command give:
      ls -l /usr/local/BerkeleyDB.4.8/lib/
      If it does not give you a list of .so files (including the one from the error message), I'd suggest that you repeat the part about compiling and installing Berkeley DB.

    2. Ok, now after having started from scratch, following my own guide, I get the same error as you. For some reason bitcoind can't find this lib, even though it was configured to know where to look. Anyway, I solved it by creating a symbolic link like this:
      sudo ln -s /usr/local/BerkeleyDB.4.8/lib/ /usr/lib/

    3. Yeah, I actually found the symbolic link command on a Peercoin mining tutorial; go figure. Afterwards, I ran into another problem with the script to automatically run bitcoind on startup, but I see you changed the command in your tutorial. Everything works fine now! Thanks all you have done!

      I'll send some btc your way, but I cannot see the QR code you posted. Can you paste your address here for me?



    4. It seems to be something common, then, maybe even a bug in bitcoind? Anyway, I'll add the symbolic link command to the tutorial. Thanks!

      And yes, the command that automatically runs bitcoind on startup first attempted to run it as root. Since the tutorial assumes you're logged in as user "pi" instead, it's better to also run bitcoind as "pi" which is what it does now.

      My address + QR for donations should be in the sidebar to the right, but I'll paste it here too, in case it doesn't show up for you: 17UW3o9sPSTb4NmBN4zgPbW1jvXQe6gGHA (thanks in advance!)

  8. when it comes to "Downloading and Compiling Bitcoin Core" step 2
    i get autoreconf: not found, - any quidence here? i isnstalled the
    ~/bin/bitcoin $ ./
    **./ 5: ./ autoreconf: not found**

    1. That's strange. It should be installed along with the other dependencies in the beginning of the tutorial. Anyway, you can install the missing autoreconf through this command:
      sudo apt-get install autoconf
      If, after this, you keep getting error messages about missing tools, I would repeat the step "Install some dependencies" just to make sure everything really got installed.

  9. Got it thanks, I cut and past the command line for installing dependencies, something went wrong, i installed them all again and everything is working, I'm just copying the Blockchain now (@23% and counting)

    prior to that I had to get my 256GB card running on my pi, all went smooth, amazing support around Linux, so impressed.

  10. thank you, great work. we used it to put up a node in the tel aviv bitcoin embassy [ ].
    it all went smooth apart for the /usr/local/BerkeleyDB.4.8/lib/ issue.
    sent a donation.
    keep it up.

  11. so no luck downloading and importing the block chain.
    first attempt was using my windows blockchain - after 2 days getinfo had not moved off difficulty 1 and blocks negative 1

    started again - fresh setup.

    This time downloading the block chain, all works well until around block 20,500 - started crashing - (aborting)

    Started again - this time a fresh image (clean install)

    i tried importing the all goes well until block 20,402 or near there and hangs then aborts.
    error below:

    $ bitcoind -loadblock=~/.bitcoin/bootstrap.dat
    bitcoind: main.cpp:1761: bool ConnectBlock(CBlock&, CValidationState&, CBlockIndex*, CCoinsViewCache&, bool): Assertion `hashPrevBlock == view.GetBestBlock()' failed.

    any suggestions? (i have a 256 GB SD card so dont think it's a space issue)

  12. no need to publish this, but in referance to my previous post the block count is in the 200,000 not the 20,000 as write.

  13. Just ordered a Raspberry Pi and 64GB micro sd card. Any image file or updated information would be greatly appreciated.

  14. So close ... after executing the ./configure string I get the following error.
    ./configure: line 2848: syntax error near unexpected token 'disable shared'
    ./configure: line 2848: syntax error 'LT_INIT(disable shared)'

    Any thoughts

  15. thanks for the tut,
    is it then possible to use the raspi with this to solo mine using a Antminer S1, or is it to slow for

    doing that?

    1. Honestly, I don't know. I've never played much around with mining. Anyone?

  16. Hello
    Any advice why bitcoind crash after a half an hour? I create 1g swap and i have already 1g ram in the system

  17. can anyone have any idea why i have this errors when i try to Libtool library used but `LIBTOOL' is undefined The usual way to define `LIBTOOL' is to add `LT_INIT' to `' and run `aclocal' and `autoconf' again. If `LT_INIT' is in `', make sure its definition is in aclocal's search path.
    autoreconf: automake failed with exit status: 1

    1. sudo apt-get install libtool

      Fixes Problem (Y)

    2. I had this problem too, after research i found this helped!

      sudo apt-get install libtool

      Fixes Problem (Y)

  18. Sent $1 in BTC. Thanks for the awesome writeup!

  19. Everything went fine, with one diffrence: I needed to use the 0.10 version of bitcoind, because 0.9.3 is no more available anymoe. Unfortunately there is an error when I try to run bitcoind: Error: To use bitcoind, or the -server option to bitcoin-qt, you must set password in the configuration file[...] I created the config file /home/pi/.bitcoin/bitcoin.conf with the suggested (from bitcoind) user and password, but it still won't run.
    Is there anybody who can solve this? I think there is much more to learn about Linux for me...

    1. Actually bitcoind 0.9.3 is indeed still available, as is every earlier version. Every single change made to the bitcoin core code base through time is visible from the Github repository. The method of downloading bitcoind which is described in this tutorial will therefore work no matter which version you want to download:
      git clone -b 0.9.3
      Unfortunately, I have not yet had the time to adjust the tutorial for 0.10.0, so if it's very important for you to run something newer than 0.9.3 you might find some help in some of the other comments here.

  20. Where I would can to have bought bitcoin sd card?

    Unfortunetly compiler halt... not work.

  21. FYI, on pi2, you can add a '-j4' option to the make like this 'make -j4' to use all four cores.

    1. Cool, thanks! Haven't received my Pi 2 yet, unfortunately.

  22. Also, need to add this (for 0.10.0)
    sudo apt-get install libtool

    1. Thanks for this - now got 0.10.0 up and running on a pi2 :)

  23. And to make use of USB Storage, located at /mnt/data?

  24. And to make use of external USB storage, USB HDD for example for a future proof solution.
    example perhaps to make the blockchain download to /mnt/data

    1. in the conf file......datadir=/new/path/to/.bitcoin


    2. which conf file? I'm new to this :D

  25. I just thought I'd point out you don't actually need to compile for use on RaspPi2 or similar arm platforms, eg. Cubieboard 2, which I use. Debian Sid (unstable) has a package for bitcoind 0.10.0. If you add debian sid to your sources.list then it can be installed with apt-get.

  26. Any web interface that can be run on the raspberry pi to give some stats of the node?

  27. Just as a comment: I had to "sudo apt-get install libtool" in order to get "./" to complete it's job. It seems that is missing from the beginning mass apt-get syntax.

    (i am running bitcoind 0.10)

  28. after running "bitcoind" i get "Segmentation fault"

    any ideas?

  29. Thanks for this awesome post. Would suggest the following:

    1. Update the post to support bitcoin v.0.10. This would only entail changing 3 things:
    a) add libtool to the dependencies on initial steps (apt-get install)
    b) change to git clone -b 0.9.3 (on downloading and compiling bitcoin core)
    c) on the conclusion sectio, change bitcoind getinfo to bitcoin-cli getinfo

    2. Warn about the amount of time to compile bitcoin core on different versions of the Pi. I have the first model B version and i estimate it took me 5 hours to finish compiling. A lot of time commitment especially if you're just SSH'ing into the Pi. I would have used screen to background the process.

  30. Full Image with Bitcoin core

  31. HI, I keep getting an error when doing the following command:
    ./configure CPPFLAGS="-I/usr/local/BerkeleyDB.4.8/include -O2" LDFLAGS="-L/usr/local/BerkeleyDB.4.8/lib"
    I get a "No such file or directory"

    1. Are you sure that both /usr/local/BerkeleyDB.4.8/include and /usr/local/BerkeleyDB.4.8/lib exist on your system? It not, it seems like something went wron with your BerkeleyDB installation.

  32. I managed to get it right. I think copying the code gave it the wrong inverted commas. When I first pasted it to a text file, changed it and then entered it, it worked. My Pi is up and running and should complete the task of downloading the blockchains tonight!

  33. I could use some advice on this make error. It happens with version 0.10.0 and 0.11.0 and I'm running Raspberry Pi 2 (linux version 4.1.9-v7+):

    test/util_tests.cpp:322:5: warning: this decimal constant is unsigned only in ISO C90
    BOOST_CHECK(ParseInt32("-2147483648", &n) && n == -2147483648);
    In file included from /usr/include/boost/test/unit_test.hpp:19:0,
    from test/util_tests.cpp:18:
    test/util_tests.cpp: In member function ‘void util_tests::test_ParseInt32::test_method()’:
    test/util_tests.cpp:322:52: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    BOOST_CHECK(ParseInt32("-2147483648", &n) && n == -2147483648);
    CXX test/test_test_bitcoin-accounting_tests.o
    CXX wallet/test/test_test_bitcoin-wallet_tests.o
    CXX test/test_test_bitcoin-rpc_wallet_tests.o
    CXXLD test/test_bitcoin
    ./leveldb/libleveldb.a: error adding symbols: File format not recognized
    collect2: error: ld returned 1 exit status
    Makefile:2746: recipe for target 'test/test_bitcoin' failed
    make[2]: *** [test/test_bitcoin] Error 1
    make[2]: Leaving directory '/media/pripi/BTC/work/bitcoin-0.11/src'
    Makefile:6459: recipe for target 'all-recursive' failed
    make[1]: *** [all-recursive] Error 1
    make[1]: Leaving directory '/media/pripi/BTC/work/bitcoin-0.11/src'
    Makefile:622: recipe for target 'all-recursive' failed
    make: *** [all-recursive] Error 1

  34. Nice tutorial !
    A reminder for the Raspberry Pi 2 users : do not use the "make -j4" function for the Bitcoin Core compilation part, your device will run out of memory.

    Keep it in this way :
    ./configure CPPFLAGS="-I/usr/local/BerkeleyDB.4.8/include -O2" LDFLAGS="-L/usr/local/BerkeleyDB.4.8/lib"

  35. I follow the instructions and when I get to: ./configure CPPFLAGS="-I/usr/local/BerkeleyDB.4.8/include -O2" LDFLAGS="-L/usr/local/BerkeleyDB.4.8/lib"
    it goes down to checking for
    configure: WARNING:QT dependencies not found; bitcoin-qt frontend will not be built
    checking whether to build Bitcoin Core GUI... no(Qt5)
    then it gets to checking for event... no
    configure: error: libevent not found.
    is there something different i should be doing

  36. While wasI running this command ./configure CPPFLAGS="-I/usr/local/BerkeleyDB.4.8/include -O2" LDFLAGS="-L/usr/local/BerkeleyDB.4.8/lib"
    I am getting checking whether the c++ compiler
    Configure error: in /home/pi/bin/bitcoin':
    C++ compiler cannot create executable

    What should I do?

  37. From this post only I came to know more about that using bitcoin they are making projects.