The Easy Guide to Solo Baking Tezos on a Raspberry Pi
– or ‘How I combined a bunch of guides, but still had to figure out stuff on my own, so now I’m making a new guide’.
(Updated April, 2022)
So, here’s how I got a Tezos baker up and running on a Raspberry Pi.
There are a number of ways to do it. I tried some clever and developer-aesthetically pleasing setups, but I kept running into problems.
This guide is crude, but it works. The setup shown above has been endorsing and baking without issues for a year (not counting the network-wide Granada-upgrade troubles).
I tried to keep it as simple as possible, leaving out many details and alternative routes. If something is unclear, needs updating, or you just want to get in touch, catch me on twitter.com/imthemule.
About the guide
I am a complete beginner when it comes to working with Linux.
Mostly, if I mess something up, I don’t spend time debugging because I likely won’t be able to fix it. I tend to just start over.
So this guide is optimized for wiping everything and getting up and running from zero fairly quickly. You also don’t need to backup/save anything, because all important info is on your Ledger.
IMPORTANT: This guide assumes you use a Ledger (Nano S)! Do NOT use this guide with the built-in wallet in the tezos-client. The Ledger protects you from losing funds through own mistakes, hacks and double baking/endorsing.
If you need this guide to make things work, you should not be baking without a Ledger.
I kind of expect this guide to be obsolete relatively soon, as things change quickly and hopefully easier options come along. It is also possible that a Raspberry Pi won’t be able to keep up, as the network grows. But for now…
- A PC/Mac
- Raspberry Pi (v4) with monitor/keyboard/mouse connected
- External SSD w/USB3.0 (100+ GB)
- Ledger Nano S
I recommend getting the highest spec Raspberry Pi possible, as hardware requirements will likely increase with future Tezos upgrades. This guide is based on a Pi 4 Model B w/ 8 GB RAM. I’m not sure this will work on Pi 3 or earlier.
It’s recommended to not run the baker from the Pi’s SD card due to a lot of read/write activity. Plus it’s slower. Just run the whole thing from the SSD.
The Pi is sensitive about which external drives it will boot from. I tried a hard drive enclosure with an old laptop SSD, but no luck. I recommend a Samsung T5 SSD, which worked for me.
- Setting up the OS
- Setting up the Tezos node
- Setting up the Ledger Nano S
- Running the baker
- Monitoring and maintenance
Part 1 — Setting up the OS
I’m going to assume you are already familiar with the basics of managing a Raspberry Pi.
1.1 Enabling boot from USB
Set up the Pi with the standard Raspberry Pi OS (32-bit) on the SD-card.
Run the following command in Terminal to change boot settings:
In the menu select:
Advanced options -> Boot order -> USB Boot
Reboot the Pi.
1.2 Installing OS on the SSD
For running the Tezos node and baker you’ll need a 64-bit OS, as the Tezos node doesn’t like 32-bit.
I’m not a dev and don’t feel too confident with pure command line, so I prefer a desktop version.
Ubuntu 20.10 Desktop felt heavy and took ages reconfiguring every time I flashed the Pi, which I ended up doing a number of times.
Hence, I use Raspberry Pi OS 64-bit.
- In Raspberry Pi Imager, select [Raspberry Pi OS (other)] and choose [Raspberry Pi OS (64-bit)].
- Flash the SSD and unplug it
- Plug it into the Pi (using a blue USB 3.0-port!) and reboot the Pi
- Setup the OS — for the purposes of this guide, I recommend keeping the user ‘Pi’
- Reboot again
You should now be running the Raspberry Pi OS 64-bit from the USB-connected SSD-drive.
Part 2 — Setting up the Tezos node
One headache with the Pi is the ARM-processor with its arm/arm64 architecture. Software is often only made for x86/x64 (Intel) architecture and won’t run on the Pi.
Fx. you can’t use the Kiln GUI baker, which was my original plan, until I learned this to my great frustration. It’s a bit resource heavy anyway and might be pushing the Pi’s limits.
So, command line it is…
Now, here I’m going to save you a lot of time. Most guides have you compile the Tezos node/baker yourself.
I tried it. You need to install a bunch of stuff and the actual compiling takes ages, even if there are no errors.
But you don’t have to compile. You can just download it.
2.1 Getting the binaries
There are pre-compiled binaries (executable files) available for every release. Download them directly from the Tezos GitLab: https://gitlab.com/tezos/tezos/-/releases
Find the latest release and make sure you download the arm64-versions. The naming varies a little bit with releases, but you are generally looking for files with “arm64” in the name, fx. “tezos-node (arm64 Linux)”.
To run a baker you only need need tezos-node, tezos-client, tezos-baker, and tezos-accuser. Other binaries can be downloaded later if you need them.
If there are two protocol-versions, make sure to get the ones that match current Tezos protocol version.
2.2 Installing the binaries
Create the folder ‘tezos’ in your user’s home folder (for me, it’s ‘home/pi/tezos’) and move the downloaded binaries there.
The files may have ‘arm64’ and more in the name, fx. ‘arm64-tezos-baker-012-Psithaca’ and it’s annoying to type out every time when running commands later.
To keep things simple — and for following this guide with future protocol names — rename these files so they’re called just tezos-node, tezos-baker, tezos-client etc.
Next, change permissions, so that the files can be run.
chmod a+x tezos-node tezos-client tezos-baker tezos-accuser
Cool! You’ve now installed the node and baker software. Almost there!
Lol, no. Plenty of stuff to do.
2.3 Installing Zcash parameters
Since the Edo upgrade added Zcash’s privacy tech to Tezos, you need some ‘Zcash parameter files’ to run a Tezos node. No, I don’t know what that is, but here’s what you need to do:
In Terminal, download the script that installs the parameters.
(Yes, the link looks kinda fishy, but you can verify it by comparing with the one from the official Tezos documentation)
Change permissions to make the file executable.
chmod a+x fetch-params.sh
Run the script (do NOT run with sudo privileges, as the installed files will end up in folders belonging to user ‘root’, and not the folders belonging to user ‘pi’. This will cause problems.)
The script will the install Zcash parameters.
2.4 Importing a snapshot
To function properly, the node also needs to be up to date with the blockchain. But you don’t want to have the node download all history from other nodes, which could take days.
Instead, download a snapshot and import it. There are a few options, but I use https://mainnet.xtz-shots.io/. They are updated daily, and your node will only have to catch up a little bit.
You will want to use the ROLLING version. Check this blog for an explanation of the differences.
Copy the link to the latest ‘ROLLING’ snapshot from https://mainnet.xtz-shots.io/.
Then go to the ‘tezos’ folder in Terminal and download it using this command:
wget [copied link ending with .rolling]
Copy the filename (not the whole link) which will look something like ‘mainnet-2312989.rolling’
Import the snapshot in Terminal (make sure you’re in the ‘tezos’ folder) by pasting the filename into this command and running it:
./tezos-node snapshot import [copied filename ending with .rolling]
It will import the snapshot and automatically set the node storage mode to ‘rolling’, which means you won’t end up with a huge amount of blockchain data stored.
This can take 30 minutes or more. Make yourself a nice cup of tea or go for walk.
2.5 Running the node
Once the snapshot is imported, run the node in Terminal (these are standard settings, don’t ask me).
./tezos-node run --rpc-addr 127.0.0.1:8732
First it will generate an identity which won’t take long.
Then it will catch up to the latest block by downloading from other nodes on the network. This can take more than an hour if the imported snapshot is close to 24 hours old.
You can check the status by opening another tab in Terminal with Ctrl+Shift+T and running the tezos client with this command:
The timestamp shows you what time (latest block) the node is currently at. You can press Ctrl+C to stop monitoring it.
When it says “Node is bootstrapped’ you’re ready to move on.
Part 3 — Setting up the Ledger Nano S
Baking requires a dedicated app, Tezos Baking, on the Ledger that’s different from the wallet app.
This is for security reasons, because the Tezos Baking app can only sign endorsements and bake blocks. It cannot sign transactions, so it’s impossible move your funds with the Ledger while in baking mode. Clever!
3.1 Installing the Tezos Baking app
I’m going to assume you’re familiar with operating a Ledger and installing apps in Ledger Live.
To install the Tezos Baking app:
- On your PC/Mac, open Ledger Live and go to Settings
- Under ‘Experimental features’ enable ‘Developer mode’
- You will now see 2 apps in the manager if you search for ‘Tezos’
- Install both Tezos Wallet and Tezos Baking
3.2 Enabling access to the Ledger
To interact with the Ledger in a Linux environment, you need to run the script from the Ledger devs below.
(Yes, another fishy looking link, but you can verify it by comparing with the one shown on ledger.com, under ‘Linux’)
Go to the ‘tezos’ folder in Terminal and download the script.
Change permissions to make it executable.
chmod a+x add_udev_rules.sh
Run the script as root user.
3.3 Importing your Ledger’s secret key and alias
Now you need to ‘pair’ the Tezos node and the Ledger.
Plug the Ledger into the Pi, and open the Tezos Wallet app on the Ledger.
On the Pi, run this command in Terminal while in the ‘tezos’ folder:
./tezos-client list connected ledgers
You’ll see 4 possible commands looking something like ‘tezos-client import secret key ledger_pi “ledger://weird-words-and-animals/ed25519/0h/0h”’
Copy the command with ‘ed25519’ in it, and add ‘./’ in front of it before pasting into the command line.
Note that it has automatically proposed an alias for your ledger, which is ‘ledger_’ followed by your OS user. Hence ‘ledger_pi’ above.
You can change it to any alias you like in the command, but I just keep ‘ledger_pi’.
Run the command — it should look like this, but with your own ‘weird-words-and-animals’.
./tezos-client import secret key ledger_pi “ledger://weird-words-and-animals/ed25519/0h/0h”
You will need to confirm this on the Ledger. Check that the public key hash (tz-address) matches the one you are expecting to bake from.
3.4 Registering your baking address
With the node up to date and running, and the Ledger connected and set up, you need to register the address you imported to be a baker on the Tezos blockchain.
Keep the Tezos Wallet app open on the Ledger, and run the following command in Terminal on the Pi (replace ‘ledger_pi’ if you chose a different alias above).
./tezos-client register key ledger_pi as delegate
Go to tzstats.com/[your-baker-tz-address] and look under “Delegations” to see if it has been done correctly. It should say something like “Registered as baker with 0.00035 XTZ fee”.
3.5 Setting up the Ledger for baking
Quit the Tezos Wallet app and open the Tezos Baking app.
Find the chain ID and number of latest block on tzstats.com/protocols.
In Terminal, run the command below.
Again, change ‘ledger_pi’ if you gave it another alias. Insert the chain ID and blocknumber (without commas) in the relevant places.
./tezos-client setup ledger to bake for ledger_pi --main-chain-id [CHAIN ID] --main-hwm [BLOCK NUMBER]
Confirm on the Ledger.
Part 4 — Running the baker
Make sure the Tezos Baking app is open on the Ledger.
Make sure the node is running or start it with the command from before:
./tezos-node run --rpc-addr 127.0.0.1:8732
I like to keep every process open in its own tab to have a nice overview of what’s going on.
Open 3 extra tabs in Terminal with Ctrl+Shift+T, so that you have at least 4 open including the node tab.
Ideally rename (Ctrl+Shift+I) the first 3 tabs, so they’re called ‘Node’, ‘Baker’, and ‘Accuser’. The last one is for various tasks.
Run the following (remember to change ‘ledger_pi’ if you chose another alias).
./tezos-baker run with local node ~/.tezos-node ledger_pi
… and there you are. Congratulations, you are now baking on a Raspberry Pi with your Ledger, using around 5 watts. How about that.
You can stop any of the processes by selecting the tab and pressing Ctrl+C.
Part 5 — Monitoring and maintenance
5.1 Monitoring the baker
Go to tzstats.com/[you-baker-tz-address] to check future baking/endorsing rights, income, reliability etc. It’s a good one to have bookmarked.
Also, I recommend using the Tezos Notifier Bot (Telegram) to get notified if you miss a baking or endorsement slot.
5.2 Updating the node/baker
Download the latest binaries from Tezos GitLab. If possible, try to proceed during longer gap in between baking/endorsing slots, so you don’t miss your slot if something goes wrong.
The rest is simple:
- Stop the node/baker/accuser with Ctrl+C in each tab
- Delete the existing binaries in the ‘tezos’ folder
- Install the new binaries (see Part 2.2)
- Run the new binaries (see Part 4)
5.3 Documentation and support
This guide draws on a number of other guides.
Note that they might be outdated, have minor mistakes or aren’t fully relevant for the Pi, and this is simply to acknowledge that I lifted certain ideas and approaches from them.