How to Setup an IPFS Node on a Raspberry Pi


Article Outline
  1. 1. System Configuration
  2. 2. Download & Installation [1]
    1. 2.1. Locate the URL for the current go-ipfs binary
    2. 2.2. Download the go-ipfs tar.gz file on the target machine
    3. 2.3. Extract & Install go-ipfs
    4. 2.4. Remove files after installation
  3. 3. IPFS Node Initial Configuration [1:1]
    1. 3.1. Initialize the IPFS node
    2. 3.2. Add an IPFS Daemon Service
    3. 3.3. Configure Bandwidth Related Settings [2]
    4. 3.4. Start the IPFS Daemon Service [1:2]
    5. 3.5. Configure access to the WebUI Portal [3]
  4. 4. Administrative Tools [1:3]
Keywords: ,

System Configuration

This setup should work on the following system configuration(s):

  • Hardware: Raspberry Pi 4
    • OS: Raspberry Pi OS Lite (ARM-64)

Download & Installation [1]

Locate the URL for the current go-ipfs binary

Linux Binary – ARM-64: https://dist.ipfs.io/go-ipfs/v0.8.0/go-ipfs_v0.8.0_linux-arm64.tar.gz

Download the go-ipfs tar.gz file on the target machine

Open a terminal on the device and type,

  • $ wget -q https://dist.ipfs.io/go-ipfs/v0.8.0/go-ipfs_v0.8.0_linux-arm64.tar.gz

Extract & Install go-ipfs

  • $ tar xf go-ipfs_v0.4.21_linux-amd64.tar.gz
  • $ sudo mv go-ipfs/ipfs /usr/local/bin

Remove files after installation

  • $ rm -rf go-ipfs go-ipfs_v0.4.21_linux-amd64.tar.gz

IPFS Node Initial Configuration [1:1]

Initialize the IPFS node

  • $ ipfs init

Add an IPFS Daemon Service

  • Create a new file in the system folder for the IPFS Daemon Service,
    • $ sudo nano /etc/systemd/system/ipfs.service
  • Add the following contents to the file,
1
2
3
4
5
6
7
8
9
10
11
[Unit]
Description=IPFS Daemon

[Service]
ExecStart=/usr/local/bin/ipfs daemon
User=root
Restart=always
LimitNOFILE=10240

[Install]
WantedBy=multi-user.target

(Change the line “User=root” if you’re not running the daemon as root)

  • Change the reprovider strategy to “pinned” or “roots”

    • “pinned” only re-provides objects that are currently pinned, the default is every local block.
    • “roots” only provides the pins themselves, and not their child blocks.
    • “roots” has much lower bandwidth cost, but may harm the reachability of node content.
  • $ ipfs config Reprovider.Strategy pinned

Start the IPFS Daemon Service [1:2]

Run the following commands to tell systemd about the new service:

  • $ sudo systemctl daemon-reload
  • $ sudo systemctl enable ipfs
  • $ sudo systemctl start ipfs

Configure access to the WebUI Portal [3]

To allow other devices on the network to access the IPFS node’s webui via the host’s IP address, we must first edit the ipfs config file.

  • Open the ipfs config file for editing,
    • $ sudo nano .ipfs/config
  • At the top of the file you should see the following block of code:
1
2
3
4
5
6
7
8
9
10
"Addresses": {
"API": "/ip4/127.0.0.1/tcp/5001",
"Announce": [],
"Gateway": "/ip4/127.0.0.1/tcp/8080",
"NoAnnounce": [],
"Swarm": [
"/ip4/0.0.0.0/tcp/4001",
"/ip6/::/tcp/4001"
]
},
  • On Line 2, replace, ‘127.0.0.1’ with the device’s local IP address (i.e. 192.168.0.xxx).

Example:

1
"API": "/ip4/192.168.0.xxx/tcp/5001",

Now run the following command in the console to allow clients from any origin to access the webui resource on this IPFS node:

$ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin "[\"*\"]"

Finally, open a browser using a machine on the same network to test that you are able to access the WebUI. Using the local IP address of the IPFS node that was specified in the steps above, attempt to open the following URL:

http://<Local IP Address>/webui/

Administrative Tools [1:3]

  • See high-level information on how the IPFS daemon is doing:

$ systemctl status ipfs

  • Stop the daemon:

$ systemctl stop ipfs

  • Start the daemon:

$ systemctl start ipfs

  • See all logs from the daemon:

$ journalctl -u ipfs

  • See only most recent logs, and show new logs as they’re written:

$ journalctl -f -u ipfs


  1. Title: Setting Up a Server
    Publication: Cloudflare Docs ↩︎ ↩︎ ↩︎ ↩︎

  2. Title: ipfs/go-ipfs: Issues: Excessive bandwidth use: #3429
    Publication: https://github.com/ipfs/go-ipfs ↩︎

  3. Title: ipfs/go-ipfs: Issues: Reconsider silly “security” practicies #594
    Publication: https://github.com/ipfs/go-ipfs ↩︎