For a long time the Raspberry Pi has seemed tempting for people who dreamed to run a utter knot on the Bitcoin network because of its petite size, low power use and cheap price-tag. With their relatively low spectacle specs, the very first generations of the Pi were indeed not fairly up to the task, tho’. Some people were able to compile and run Bitcoin Core (this very blog, for example), but only slightly, and others didn’t succeed ter making it work at all.
This has switched to the better with the newer generations of the Pi. The Raspberry Pi Two and especially the Raspberry Pi Trio have more RAM and multi-core processors. While wij’re still far from modern desktop computers, of course, you’re much better off with the current specs than before. That being said, syncing the blockchain can still be fairly painful on a Pi Three.
With the blockchain growing larger and larger, you basically have two options. One option is to have enough storage space to contain the entire blockchain (and then some), be it by means of a indeed large Micro SD card, a Western Digital PiDrive like explained here, or a large USB pen-drive. The other option is pruning the blockchain, which became available te the Bitcoin Core software recently. Pruning is basically storing only the most latest part of the blockchain, and cutting away everything else.
Also, for Ubuntu, pre-compiled binaries of Bitcoin Core and its dependencies have bot made available for the Raspberry Pi, which has made the process much lighter since you no longer have to compile yourself if you don’t wish to go through the trouble.
This guide will demonstrate how to set up a accomplish headless total knot system with a Pi Three, either spil a pruned knot, or using a Western Digital PiDrive (or another USB harddisk) to store the blockchain. A Raspberry Pi Trio with a connected PiDrive will consume around 3-4 watt of power. A pruned knot on just the Pi Trio is just above Two watt. Compare that to the 100-200 watt that is consumed by a typical desktop rekentuig running Bitcoin software with the screen turned off.
It will be a bit technical, but my purpose wasgoed to make it fairly comprehensive and explaining, so even if you have little to no practice with using Linux/Unix systems, you should be able to go after along, spil long spil you’re not afraid of attempting out fresh things.
THE HARDWARE REQUIREMENTS
Raspberry Pi Trio: This guide will be using the Raspberry Pi Trio prototype B, but the process should be the same on the Pi Two, if you have that laying around. If you’re going to buy a fresh Pi for this project, I recommend going for the Pi Trio, since its price-tag is the same, and the specs are higher.
Micro SD card, minus 4-8 GB (minus 16 GB without PiDrive), class Ten or better: The Pi boots off an SD card. For that you’ll need one that’s fairly prompt, so get a class Ten or better. Four or 8 GB should be more than enough for setups with the PiDrive. This one is fine, but be aware that PiDrives often come with a Four GB MicroSD card included, so you may not have to buy one separately.
If you’re programma on a pruned knot without a harddisk, choose a fairly larger SD card, depending on how much of the blockchain you want to prune (also take into account the space taken up by the system plus a swapfile). 16 GB is most likely the ondergrens without a PiDrive. Warning: Don’t buy cheap SD cards off Ebay and elsewhere from China, spil thesis are often puny cards technically disguised spil larger cards.
SD card reader: You’ll need an SD card reader and a MicroSD card adapter or some other way to butt-plug your Micro SD card into your ordinary pc during installation of the Pi’s operating system.
WD PiDrive (optional if you’re going to run a pruned knot): Since SD cards of the required size to store the entire blockchain are fairly expensive still, wij will be using a harddisk to store the space greedy blockchain files. Western Digital’s PiDrive is very gezond for the purpose, it comes ter sizes of 250 GB, 314 GB and even 1 TB.
Ter the spirit of Pi, I used the 314 GB version ( Trio.14, get it?), a storage capacity that at the time of writing can hold the blockchain three times, so there’s slew of space left for the rapid growth the blockchain. At the same time, it comes with a USB butt-plug that fits right into one of the Pi’s USB slots, instead of a SATA connector spil usual, and a nice lead that permits you to power both the Pi and the PiDrive from the same power supply.
Alternatively, you could use an outer USB-harddisk of any make and monster, or an internal harddisk with a powered USB adapter. Also, if you want to save on power, an SSD or a USB pendrive instead of a physical harddrive will be a good option. And of course, if you project on running a pruned knot or on getting a hefty MicroSD card, you won’t need an toegevoegd drive at all.
Micro USB power adapter, zoogmoeder Two.Five A: Spil the Pi models grow fatter te specs, so do their power requirements. Traditionally, Pi owners have used old phone chargers spil a power supply. While you can still do that, you should be very cautious that the supply supplies enough power for the newer Pi models. A ondergrens of Two.Five A is the official recommendation. The effortless route (and the safe bet) is to just get the official Pi Three power supply which can power both the Pi Trio and the PiDrive at the same time.
Ethernet cable (optional): Even however the Pi Three has built-in wifi support, I recommend using a cabled network for a Bitcoin knot. For that you’ll need a chunk of Ethernet cable from your network router/switch to your Pi. The Raspberry Pi supports only Ten/100 Mbit/s, so any category 5e or better is fine. If you vereiste, you can of course use wifi instead, but te my practice, cabled network is just much more reliable.
Raspberry Pi case (optional): Ter order not to risk hurting the electronics parts of your Pi, I recommend to get a case for it. This might be anything from one of the many different cases that are available, or you might make a case yourself that fits both the Pi and your PiDrive.
Heatsink and/or fan for the Pi (optional): Either an inactive aluminium heatsink, a cooling fan (comes with some cases), or maybe both. The Raspberry Pi Foundation says cooling is not necessary on a Pi, and the Pi does throttle down voorstelling when it gets too hot to prevent harm. However, especially when syncing with the blockchain, the Pi’s CPU runs fairly hot to a degree that I can’t hold my finger on it for more than a duo of seconds.
Also, I see the “thermometer” symbol on the screen (meaning spectacle is being throttled) fairly often. After adding a heatsink and a fan I toevluchthaven’t noticed spectacle being throttled. It should be noted that after synchronisation is done, flow on the CPU decreases drastically, and you will most likely have no problems running without cooling day-to-day.
A spare HDMI screen, USB keyboard and mouse: Thesis will only be used during setup, so don’t go out buying thesis.
Several of thesis hardware items are available from online store Pi Supply. I am not affiliated with them ter any way, other than I’m a glad customer there, they send worldwide, they have excellent customer service, and they take Bitcoin.
For this project, I have chosen to let the Pi run Ubuntu Linux instead of the otherwise very nice Raspbian, since that makes the installation of Bitcoin Core a bit lighter.
Installing Ubuntu on the SD card is not too hard. It’s a matter of downloading an pic opstopping, and writing that pic verkeersopstopping onto the MicroSD card that the Pi will boot off. Download the latest LTS (long term support) picture verkeersopstopping. The listig here is actually Ubuntu Mate, which is normal Ubuntu with the Mate graphical desktop system, but since wij won’t be using the desktop system with the finished headless Bitcoin knot, it doesn’t truly matter which flavour of Ubuntu it is. I also attempted with the unofficial Ubuntu Server pic without a desktop system, but I had boot problems after updating it, so I went for Ubuntu Mate instead.
After downloading the pic opstopping, it needs to be written to the MicroSD card. How this is done differs depending on whether you’re on Windows, Linux, Mac, etc., but the Raspberry Pi Foundation has a very nice guide to doing that.
After writing the pic opstopping to the MicroSD card, insert it into the Pi, and also connect the PiDrive (unless you’re going for the pruned knot), Ethernet cable, keyboard, mouse, and screen.
UPDATING AND CONFIGURING THE SYSTEM
Butt-plug te the power cable, and the Pi will boot up and you will be introduced with a few dialogue boxes where you should set up your time zone, user account and password for the system and a few other things. The remainder of this guide will assume user name pinode, but you can of course use which everzwijn user name you wish. You are encouraged to use a strong password, especially if you project to be able to loom te from the Internet. Once finished, you will be able to login to the Mate desktop.
Commence up a Terminal (sort of a guideline line window, opened through the Applications menukaart, System Devices, MATE Terminal), and give the following directive to let the Pi boot up into text mode te the future, since there is no need for a headless Bitcoin knot to spend precious RAM on loading a total graphical desktop:
sudo systemctl set-default multi-user.target
Now, reboot the Raspberry Pi and make sure that you are logged ter to the text based directive line interface (all black screen with white text).
The next six instructions will: 1: Tell the system from where it should fetch the Bitcoin software. Two: Update the system’s information about which packages are available to download and install. Three: Download and install the text based version of Bitcoin Core, plus another device that will be used next. Four+Five: Liquidate the entire graphical desktop environment so that it doesn’t take up space on the SD card.
Run the last of thesis two eliminate directions repeatedly (maybe 4-5 times) until it doesn’t eliminate any more packages. 6: Download and install all available updates to the entire system. Type them te one instruction at a time, spil each guideline will ask you a question or two (typically just press Inject or Y to proceed). The last guideline will most likely take fairly some time to finish.
sudo add-apt-repository ppa:bitcoin/bitcoin
sudo apt update
sudo apt install bitcoind deborphan
sudo apt eliminate –auto-remove –purge libx11-.*
sudo apt eliminate –purge $(deborphan) #Repeat until no more is eliminated
sudo apt upgrade
After that wij will write a very brief and elementary configuration text verkeersopstopping for Bitcoin Core. Wij will use the text based editor “nano” since it’s very plain to use. Feel free to use any other text editor if you have another favourite, just spil long spil it writes plain txt files. Thesis two directives create a .bitcoin directory (which is where Bitcoin Core will straks waterput all the blockchain files) ter your huis directory, and then commence up nano and open a fresh opstopping for editing:
Te the nano editor, write the four following lines. Omit the last line (prune) if you are connecting the PiDrive and want to keep the utter blockchain. Otherwise switch 1000 into however many megabytes of the blockchain that your want to store at all times (at least 550). Keep te mind, however, that this number only controls the space that the block files themselves (the
/.bitcoin/blocks directory) take up.
Other than those, expect a duo of gigabytes or more for other gegevens ter
/.bitcoin. Also keep thought of the space that the Ubuntu system itself takes up. And ultimately you will most likely be creating a swapfile that will take up around 2-3 GB. See how much free space you have on the partition that will keep the blockchain with the directive “df -h
./bitcoin” and then subtract at least 5-8 GB from that. The following should work on a 16 GB SD card.
Succesnummer Ctrl-X to uitgang nano, and then press the Y key and Inject to save the verkeersopstopping.
Te the Mate flavour of Ubuntu Linux, 64 MB of the collective memory is reserved for the GPU (graphics chip) by default. Wij can securely lower that to the ondergrens of 16 MB, thereby gaining 48 MB of extra RAM. Open the opstopping /boot/config.txt:
sudo nano /boot/config.txt
Then scroll down to the bottom of this (rather long) text opstopping and add the following line:
Again, Ctrl-X and then Y + Inject saves and exits.
GETTING THE PIDRIVE READY
The PiDrive comes preformatted for running on a Linux system on a Pi. Mine contained just one large “ext4” partition which is exactly what is needed.
However, you might also want to use another kleintje of drive (outward USB harddrive, an SSD, a USB pendrive, etc.), and those usually come formatted for Windows, or maybe not formatted at all. So assuming you already connected your drive to the Pi, what wij need to do is eliminate any existing partition(s) and add one large “ext4” partition that fills out the entire drive.
Te the end I will of course use my PiDrive, but for the sake of demonstration here, I connected a drive from an old Windows machine that wasgoed given to mij, through a cheap externally powered SATA to USB adapter (significant to get an externally powered one, spil the Pi will not be able to supply enough power for a harddrive). This drive contains several Windows partitions that I needed to liquidate.
Very first, to get an overview of the drives that are linked to the Pi, run the following instruction. Notice that the system also treats the SD card spil a drive:
This gives mij the following on my system with the old Windows drive connected:
The very first disk, named /dev/mmcblk0 is the SD card, so don’t do anything to that, or you will lose the Ubuntu system that you just set up. On my system, the next disk is /dev/sda, and you can see that it has four partitions named /dev/sda1, Two, Five and 6 that need to be liquidated. Maybe you want to write down the names of the existing partitions on your harddisk, if any.
Notice that ALL Gegevens that might already be on the harddisk will be lost, so don’t use a drive containing anything you don’t want to lose. Write the following guideline to come in the fdisk utility, switching /dev/sda into your harddisk’s name if it is different:
sudo fdisk /dev/sda
Here, you will be met with a instruction prompt. To delete the existing partitions, type d and succesnummer Inject, whereafter the prompt will ask you which partition number to delete, along with a list of the existing partitions numbers. Press a corresponding number and then Come in to delete the partition. Repeat until there are no partitions left.
Now, succesnummer n to create a fresh partition. Then p to make it a primary partition, and 1 to give it partition number 1 (and hence the partition name /dev/sda1, if your disk name is /dev/sda). At the questions about very first and last sector, just press Inject to make the partition pack out the entire harddisk.
Last, press w + Inject to save the switches to the disk and uitgang the fdisk device.
To format your fresh partition, type te the following guideline (making sure to switch the partition name approately, if your disk wasgoed not /dev/sda):
sudo mkfs.ext4 /dev/sda1
After a brief while, you are ready to climb on the partition. Ter the Linux world, drives don’t climb on to drive letters like ter Windows. Instead you can climb on a drive/partition to any place te the opstopping tree. Wij will take advantage of this fact by mounting the harddisk partition to the
/.bitcoin directory, which is exactly the place where Bitcoin Core will save its settings and store the blockchain. This way, the entire system is stored on the SD card (including Bitcoin Core itself), except for Bitcoin Core’s gegevens files.
To do this, you vereiste very first budge the existing directory out of the way and create a fresh empty directory that the drive partition will be mounted to:
Now, to tell the system to climb on the drive to the freshly created directory on every boot, you need to edit a brief text verkeersopstopping. Again, the text editor nano will come te handy:
sudo nano /etc/fstab
Ter the bottom of the opstopping, write the following line (recall to switch “sda1” if your harddrive partition wasgoed named differently, and also switch “pinode” into your username):
/dev/sda1 /huis/pinode/.bitcoin ext4 defaults 0 0
Then, press Ctrl-x followed by y and Inject to save the opstopping and uitgang nano.
Test it out by typing sudo reboot to reboot the system. When the Pi has rebooted, loom te and type df -h to see all mounted partitions. Your freshly created harddisk partition should be ter the list along with information that it is mounted to your .bitcoin directory:
Ultimately, make sure that the pinode user account (which will be running Bitcoin Core) has utter access to the harddrive, and then stir the bitcoin.conf verkeersopstopping to the harddrive:
sudo chown pinode /huis/pinode/.bitcoin
sudo chgrp pinode /huis/pinode/.bitcoin
ADDING A SWAPFILE
Now for an optional, but very recommended step, namely adding a swapfile. The Pi Trio has 1 GB of RAM, which is an improvement to earlier Pi’s, but still fairly low for running Bitcoin Core spil a utter knot, especially during synchronisation with the blockchain. A swapfile (or a exchange partition) is a part of the harddrive (or ter this case, the SD card) that acts spil an addition to the RAM.
The Ubuntu Mate system does not use a swapfile or exchange partition by default. The reason that the step is optional is that swapfiles (and interchange partitions) can be fairly hard on an SD card due to the many read/write operations being performed, and SD cards only last for a certain amount of read/write operations.
It’s not like it will wear out te a few days or weeks or anything like that, just be ready to only use your SD card for this project. The reason that adding a swapfile is very recommended anyway is that chances are you will not be able to synchronise with the blockchain without it, since 1 GB RAM may simply be too little. However, wij will set up the system to only use the swapfile if stringently necessary.
If you will be connecting a PiDrive, it is very recommended to waterput the swapfile there instead of on the SD card. Just use /huis/pinode/.bitcoin/swapfile instead of /swapfile te the surplus of the directions ter this section.
To set up a swapfile, perform the following guidelines. Four GB RAM for a Bitcoin knot should be more than fine, so given the Pi’s 1 GB RAM, you can set up the swapfile to Trio GB:
sudo fallocate -l 3G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo nano /etc/fstab
The last instruction will open the settings opstopping for partitions to be mounted at boot. Scroll down to the end and add the following line, then Ctrl-X, then Inject to save and uitgang the editor:
/swapfile none interchange sw 0 0
Also, to let the system only use the swapfile if truly necessary, open the following verkeersopstopping ter nano by performing:
sudo nano /etc/sysctl.conf
Te the end of the opstopping, add the following line:
Permitting SSH ACCESS FROM ANOTHER Rekentuig ON THE NETWORK
Wij want to make the setup headless. This means that there are no monitors, keyboards, mice, etc. plugged into the Pi when it’s running. So if wij want to loom te to the Pi anyway, wij will make an SSH connection to it from an ordinary pc and get access to the Pi’s directive line this way. To permit for this, wij need to get the local IP address of the Pi. Maybe you can see it te your router’s user interface—otherwise embark the Terminal on the Pi and run ifconfig. With a cabled connection, your IP address is te the eth0 section, with a wi-fi connection, it is te the wlan0 section.
Wij’ll also make sure that the SSH server on the Pi is installed and commenced at boot:
sudo apt install openssh-server
sudo systemctl enable ssh
Now you can power down the Pi (if you are te text mode by now, you can do so using the instruction “sudo halt”), and you may eliminate keyboard, mouse, and screen. The only cables you need from now is the power and Ethernet cables, and of course the PiDrive if you’re using that. If you want to loom ter to the Pi through SSH from another rekentuig on the network, you may do so with (switch “192.168.1.199” into your Pi’s IP address, and “pinode” into the username you created on the Pi):
This is assuming your other pc also runs some sort of Linux/Unix (maybe including MacOS?). If you’re on Windows, you can use the PuTTY SSH client.
LETTING BITCOIN CORE Begin AUTOMATICALLY ON BOOT
Also, wij want Bitcoin Core to commence whenever the Raspberry Pi has bot began up. And ter addition to that, wij will attempt to commence it every five minutes te case it stopped for some reason. An effortless way of doing that is through “crontab” which is a mechanism te any Unix/Linux system that can embark programs and scripts at certain times and occasions. There may be other, more onberispelijk ways of doing this, but crontab seems to do the job. To edit the crontab settings, run:
If this wasgoed the very first time you ran that guideline (it most likely wasgoed), you will be introduced with a menukaart where you can choose a text editor to use. Again, if you have no other preferences, select “nano”. Scroll all the way down te the opstopping that nano opened for you, and add the following spil the last two lines:
@reboot bitcoind -daemon
*/Five * * * * bitcoind -daemon
OPEN PORT Te YOUR ROUTER
Te addition to your knot making connections to other knots, you will want other knots to also be able to connect to your knot. This is done by forwarding incoming traffic on port 8333 to the Raspberry Pi. How to do this varies from network to network, but typically involves injecting 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 (which you found above, e.g. 192.168.1.199) 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.
You can verify that it works by using Bitnodes’ “Join the network” feature. If it comes back a line that includes the word “Satoshi”, you have successfully forwarded traffic on port 8333 to your Pi. Notice that while your Pi is still synchronising the blockchain, it might be lagging so much that Bitnodes will report it spil unreachable. Attempt again after synchronising is done.
Commence YOUR Fresh Total Knot
Now it’s time to butt-plug your knot ter, and let it synchronise with the network. This will most likely take several days. You can keep track of the progress by logging ter (remotely or with a keyboard) and running the directive:
Compare “blocks” line with the most latest block number at your favourite block explorer (such spil Blockchain.informatie).
Some have reported that their knot stops synchronising at around block 300,000. If this is the case for you, you might want to substitute your
/.bitcoin directory with my (at the time of writing) fully synchronised directory, or even my accomplish SD card picture opstopping that you can download below.
DOWNLOAD AND USE MY ALMOST READY-TO-GO Picture INSTEAD
I’ve already done the work, so why should you? Well, because you might not trust mij to not suggest a malicious Bitcoin knot that will pauze into your private network and steal all your Bitcoins and private gegevens. And why should you, after all you don’t know mij.
Anyway, for the plucky few, I’ve ended this guide for you, let the knot synchronise with the Bitcoin network, and made an pic verkeersopstopping of my SD card available to download.
Download accomplish Pi Trio pic
The pic opstopping is for a pruned knot without any outward drive (such spil the PiDrive) affixed, ready to be used on a Raspberry Pi Trio with an SD card of at least 16 GB:
Download my (almost) ready-to-go pruned Bitcoin knot SD card pic
After transferring the pic to your SD card, you are urged to loom ter (username pinode and password pinode) and switch the password (you will be asked to switch it when logging te for the very first time) and then run the system update directives below (this will also ensure that Bitcoin Core is updated, te case a fresh version has bot released since this guide wasgoed written):
sudo apt update
sudo apt upgrade
You also still will need to open a port ter your router spil described above.
Download only the blockchain for your knot
You might also want to set up the system yourself and only download my (at the time of writing) fully synchronised
/.bitcoin directory to save on sync time (which can be long). Transfer the compressed verkeersopstopping to your Pi through SCP (verkeersopstopping transfer overheen SSH), copy the directory on to your SD card through your SD card reader on your normal pc, or download it directly from the Pi:
With the compressed verkeersopstopping te your huis directory (
) on your Pi, liquidate your old bitcoin directory (backup your bitcoin.conf verkeersopstopping very first if you made switches to it other than described ter this guide) and samenvatting the verkeersopstopping to the right place (might take some time) with:
tar -zxvf bitcoindirectoryfilename.tar.gz
If wij’re to conclude anything from this, it vereiste be that while installing and setting up a Raspberry Pi Three system to act spil a Bitcoin knot is a fairly sleek proces, the relatively low spec’ed hardware makes it fairly painful to actually synchronise with the blockchain. Possible yes, but still painful. Especially the last duo of hundred blocks seem to take forever and then some. When the knot is synced up, however, it seems to run without any problems.
I hope you liked this guide spil much spil I liked writing it. If anything is unclear, or you have any tips to share, please feel free to do so te the comments below. Also feel free (but not obliged) to donate an amount of your choice.