Skip to content

Instantly share code, notes, and snippets.

@ilyaigpetrov
Last active October 20, 2023 16:16
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ilyaigpetrov/557d1da8c89bda294a30b778a2b397df to your computer and use it in GitHub Desktop.
Save ilyaigpetrov/557d1da8c89bda294a30b778a2b397df to your computer and use it in GitHub Desktop.
Running IPFS Node On A Raspberry Pi Zero | https://git.io/rpi0-ipfs | by https://git.io/ilyaigpetrov

Running IPFS Node On A Raspberry Pi Zero

This guide is a part of RPI0 review: https://git.io/ilyaigpetrov-rpi0.

Guide

  1. Buy rPi Zero WH.
  2. Downlaod and dd Raspbian Lite to the SD Card.
  3. Boot into the pi with pi:raspberry, run sudo raspi-config, set password, network, enable ssh.
  4. Ssh into your pi, wget the latest ipfs-update binary for arm from https://dist.ipfs.io/#ipfs-update, unpack with tar xf ./the-downloaded-file.tar.gz, ./install.sh.
  5. ipfs-update versions, sudo ipfs-update install v<the-latest-ipfs-version>.
  6. ipfs init and launch the daemon with ipfs daemon.
  7. On your non-pi machine add some files: sudo ipfs add Он\ вам\ не\ Димон\ 720p.mp4, note the hash in output: QmUpt66k9cmcJPfHbtxsBCp4V4nu99pSwwMFobkkFUUruV.
  8. On the pi: ipfs pin add --progress /ipfs/QmUpt66k9cmcJPfHbtxsBCp4V4nu99pSwwMFobkkFUUruV (make sure this file is served by an active ipfs daemon, you may check a public gateway at http://ipfs.io/ipfs/QmUpt66k9cmcJPfHbtxsBCp4V4nu99pSwwMFobkkFUUruV).

Memory Consumption

In my cases while pinning some videos IPFS daemon's memory appetites could grow much. Though I never witnessed OOM killler I enlarged swap up to 2gb and noted ipfs repo gc and ipfs daemon --enable-gc (is it true by default?) for myself.

Viewing The Stats On The Pi

Now you may want to see some stats on the pi. ipfs stats helps a little but for more forward a webui: ssh -L 5001:localhost:5001 -L 8080:localhost:8080 ip@static-ip-of-your-pi. Now open http://localhost:5001/webui on the non-pi machine to view the stats.

After such redirect you won't be able to use ipfs on the non-pi machine because the same required ports are already in use. To change ports on the non-pi machine:

ipfs config Addresses.Gateway /ip4/127.0.0.1/tcp/8082
ipfs config Addresses.API /ip4/127.0.0.1/tcp/5002

Adding Flags

Important document: https://github.com/ipfs/go-ipfs/blob/master/docs/experimental-features.md

ipfs config Pubsub.Router gossipsub
ipfs config --json Experimental.FilestoreEnabled true
ipfs config --json Experimental.QUIC true
ipfs daemon --enable-pubsub-experiment --routing=dhtclient --enable-namesys-pubsub

Less Memory For The Pi

export LIBP2P_MUX_PREFS="/mplex/6.7.0 /yamux/1.0.0 /spdy/3.1.0"

This Experiment Failed

Unfortunately I had no success with sharing one video file over ipfs. Whatever I tried (configuring DMZ, Nat Full Cone on the router) I wasn't able to access a shared video file on public ipfs gateways or other PCs at acceptable speeds (>22m for 190mb). This is due to poor Wi-Fi connectivity of the rpi0, see https://git.io/rpi0-wifi because, I belive, I burnt my rpi0 while overclocking it.

export LIBP2P_MUX_PREFS="/mplex/6.7.0 /yamux/1.0.0 /spdy/3.1.0"
ipfs config Pubsub.Router gossipsub
ipfs config --json Experimental.FilestoreEnabled true
ipfs config --json Experimental.QUIC true
ipfs daemon --enable-pubsub-experiment --routing=dhtclient --enable-namesys-pubsub
@neillp
Copy link

neillp commented Jan 3, 2023

Viewing Stats:
I changed the port on the Pi machine to 5002 instead, ran the configs on the Pi, and opened 5002 on the non-Pi machine. That solves the non-PI machine port problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment