Machu Picchu: Persistent IPFS node on Raspberry Pi3 — Part 2a

Raspberry Pi3 Model B+ configured as IPFS node

version of September 6, 2021

The following is an explanation of how I installed a Raspberry Pi 3 Model B+ to serve as a persistent IPFS node in Machu Picchu. My Vision: Machu Picchu, Tech4Good

This document is composed of 3 parts, and a bonus:

  • Part 1 explains the Raspberry Pi and why it interests Machu Picchu. You may want to read it to get acquainted with this Single Board Computer and its very helpful community. It might also give you ideas how to use it for your own project.

Although I’m doing my best to explain each step, at some point I needed to make assumptions about your knowledge of Linux. If you need more explanations, you might want to do a Google search for more details. Your lifesaver, whenever you are puzzled by an error message in the installation, is to paste in Google the text of the error message followed by “stackexchange”.

Machu Picchu Tech4Good, IPFS & blockchain

Machu Picchu is why I’m installing this IPFS node. Here is a quick description of concepts used in Machu Picchu if you are new to it.

  • IPFS is an Internet protocol to decentralize storage of data.
Vision of Machu Picchu Services and Technologies

Raspberry Pi kit as delivered by LABISTS(Tm)

All Raspberry Pi starter kits are more or less the same. The one that I ordered from Labists is composed of:

  • A Raspberry Pi3 Model B+ board (“Model B” means “with Ethernet” while “Model A” means “without Ethernet”).

Build the kit

Peel off the protective layer of the double side adhesive tape on the heat sinks and glue them on the Broadcom CPU (top side) and on the DRAM (bottom side). Press gently.

Raspberry Pi3 Model B+ Heat Sinks

Assembling the rest of the case is straightforward. Slide the circuit board on the bottom layer of the case. Don’t assemble the rest of the case until the software is installed. It will be more practical for your installation steps below.

Advantages of doing so: First it’s easier to see the green flashing LED that signals any access to the micro-SD. Second you may often need to remove the micro-SD card to try flashing several kinds of OS.

List of installation steps

  1. Burn the boot micro-SD card and configure it for wi-fi access.

My description assumes that you use MacOS. The following blog articles will be very helpful if you are using Windows: https://desertbot.io/blog/headless-raspberry-pi-3-bplus-ssh-wifi-setup,
https://desertbot.io/blog/headless-raspberry-pi-4-external-ssd. The steps described here below have been checked one by one in the same time this article is being written.

Let’s start with the first steps to install a headless Raspbian accessible via ssh.

1. Burn the boot micro-SD card and configure it for wi-fi access

  • Insert the micro-SD card into the USD adapter and insert the adapter on your Mac laptop.
Raspberry Mass memory Micro-SD card
  • Launch Raspberry Pi Imager on your laptop to select which OS to flash in the micro-SD card. The video showing how to use the Imager is at https://www.youtube.com/watch?v=ntaXWS8Lk34. Unlike step 2.5 of the video, don’t specify any option. Choose “Raspberry Pi OS (other)” followed by “Raspberry Pi OS Lite (32 bit)”. Choose the storage “Mass Storage Device Media — 31.9 GB” (exact value depends on your specific micro-SD card) and flash the card. On MacOS, you need to give your administrator password.
Dialogs to select the OS to flash on the micro-SD card
  • Once the micro-SD card is flashed and verified, it will be “ejected” by MacOS. Remove the micro-SD card USB adapter and reinsert it back in your laptop. It appears on the Finder Desktop as a volume named boot. Place an empty file named ssh (no extension) in the root of this boot volume. It serves to signal at first boot that ssh should be enabled. It will be deleted after first boot.
Content of the micro-SD card with the 2 additional files for Wi-Fi
  • To create this file on MacOS, in Terminal, type touch /Volumes/boot/ssh
  • Quit the MacOS editor. Eject the USB adapter. Remove the micro-SD card. Now we can work on the Raspberry Pi.

2. Boot and open ssh session

  • Insert the micro-SD card in the RPi3, connect it to its power supply and switch power on. Wait for the green LED to stop blinking. It will take more or less 5 minutes. Check in the list of terminals on your wi-fi router that a host machine named raspberrypi has appeared.
Example how a Raspberry Pi appears on the Wi-Fi network
  • On your MacOS Terminal, connect by a ssh session to the RPi3. First, make sure to reset (with the command ssh-keygen) any previous parameters of ssh sessions made to raspberrypi.local. If you have never connected to such a host, MacOS will say failed. It's normal.
MBP18VTK:~ kvutien$ ssh-keygen -R raspberrypi.local     do_known_hosts: hostkeys_foreach failed: No such file or directory
  • If like me you have already connected by ssh to a host with that name (raspberrypi.local) in previous attempts, your MacOS will tell you that it has updated its system file named .ssh/known_hosts.
MBP18VTK:~ kvutien$ ssh-keygen -R raspberrypi.local
# Host raspberrypi.local found: line 1
/Users/kvutien/.ssh/known_hosts updated.
Original contents retained as /Users/kvutien/.ssh/known_hosts.old
  • Now you can ssh to the RPi3. Your Mac will tell you that it cannot establish the authenticity of this host and ask you to confirm that you still want to establish this session
MBP18VTK:~ kvutien$ ssh pi@raspberrypi.local
The authenticity of host 'raspberrypi.local (2001:7e8:ccdd:e000:f124:2430:a6d:c314)' can't be established.
ECDSA key fingerprint is SHA256:AagTtr9Bcb3VZBsWK2tWFd8CxRfWmCbGyPsA8gsPX4w.
Are you sure you want to continue connecting (yes/no)?
  • Answer yes and give the default password of all RPi, which is "raspberry". If you have never connected to a host with this name, here is what you will see.
pi@raspberrypi.local's password: 
Warning: Permanently added 'raspberrypi.local,2001:7e8:ccdd:e000:f124:2430:a6d:c314' (ECDSA) to the list of known hosts.
  • If like me you have previously connected to a host with that name, after the password is accepted you’ll have a routine ssh session feedback.
pi@raspberrypi.local's password: 
Linux raspberrypi 5.10.17-v7+ #1414 SMP Fri Apr 30 13:18:35 BST 2021 armv7l
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law.SSH is enabled and the default password for the 'pi' user has not been changed.
This is a security risk - please login as the 'pi' user and type 'passwd' to set a new password.

3. In ssh session, change hostname and password

  • Cross-check the IP address of the RPi3, as viewed from the RPi3, with the command ifconfig. We can see the IP address of the RPi3 in wlan0. In this example, we see that it's the same as seen by the wi-fi router above, 192.168.178.43. Incidentally we have confirmation, from the MAC address of the form b8:27:eb:xx:xx:xx, that it's indeed the Raspberry Pi (https://macaddress.webwat.ch/hwaddr/B8:27:EB)
pi@raspberrypi:~ $ ifconfig
eth0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether b8:27:eb:7b:f1:b6 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.178.43 netmask 255.255.255.0 broadcast 192.168.178.255
inet6 fe80::d168:288d:80ee:e23c prefixlen 64 scopeid 0x20<link>
inet6 2001:7e8:ccdd:e000:f124:2430:a6d:c314 prefixlen 64 scopeid 0x0<global>
ether b8:27:eb:2e:a4:e3 txqueuelen 1000 (Ethernet)
RX packets 2359 bytes 222393 (217.1 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 110 bytes 16815 (16.4 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
  • We have to change the hostname and the password. We use the command passwd to change password.
pi@raspberrypi:~ $ passwd
Changing password for pi.
Current password:
New password:
Retype new password:
passwd: password updated successfully
  • We use sudo raspi-config to change the hostname from the default value raspberrypi to ipfs-pi, or any name of your choice. In the menu, use "Carriage Return" to select an option, or use the arrow keys to move to another option of the list. Once this done, select Finish and Reboot.
  • When rebooting the RPi3, the ssh session with raspberrypi.local is closed. We are back to the MacOS console.
pi@raspberrypi:~ $ sudo raspi-config
Connection to raspberrypi.local closed by remote host.
Connection to raspberrypi.local closed.
MBP18VTK:~ kvutien$

What have we achieved?

We have gone through steps 1 to 3 inclusive. At this point we have the Raspberri Pi visible on Wi-Fi as a distinct host on Internet.

  1. We burned the boot micro-SD card and configured it for wi-fi access.

What remains to do now is to make it recognize the SSD (Solid State Disk) on startup and install it as an IPFS node. For this, continue with steps 4, 5, 6 and 7 in Part 2b of this article.

Machu Picchu — Data as a Public Service