Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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, sudo ./install.sh.
  5. ipfs-update versions, sudo ipfs-update install v<the-latest-ipfs-version>.
  6. sudo ipfs init and launch the daemon with ipds 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.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment