IPFS on a Raspberry Pi and so should you!I put
Total cost of joining the decentralized storage revolution with your own lo-fi node: $124 USD
- Raspberry Pi 3 B: $43
- Micro SD card: $11
- Raspberry Pi charger: $10 (note: needs at least 2.5A output so many phone chargers won't do)
- 2 TB USB Hard Disk: $60
- All software: FREE as in free beer!
- Home wifi: already paying for.
- Crappy laptop: already paid for.
Here's how I did it:
1. Get an OS
- Load an operating system image onto a micro SD card using Raspberry Pi Imager
- I'm using Ubuntu 20.04 Server and will run it headless to save on the already limited RAM and Wattage needed to run a desktop and GUI.
- I have the older Raspberry Pi 3 Model B which has an ARMv7 Processor so I need the 32 bit version.
2. Prepare initial boot to connect to wifi
With the SD card still inserted in your laptop, open a file manager and locate the
system-bootpartition on the card. It contains initial configuration files that will be loaded during the first boot.
We're going to edit two files so that Rapsberry Pi's onboard wifi chip will automatically connect to your wifi network.
network-configfile so that it contains only the items in the example below. Comment out with #, or remove, all other settings including the LAN ones. Enter any missing items. Be certain to maintain only the indentations shown. Use two spaces for each indentation. Remove all tab characters.
# This file contains a netplan-compatible configuration which cloud-init # will apply on first-boot. Please refer to the cloud-init documentation and # the netplan reference for full details: # # https://cloudinit.readthedocs.io/ # https://netplan.io/reference # version: 2 renderer: networkd wifis: wlan0: dhcp4: true dhcp6: true optional: true access-points: "SSID": password: "PassPhrase"
- Edit the
user-datafile appending the additional lines shown below. Again, use spaces, not tabs and mind the indentation.
# Reboot after cloud-init completes power_state: mode: reboot
3. Fire up the Pi
- Insert the micro SD card into Raspberry Pi and plug in its micro USB charger
- Allow Ubuntu to boot; DO NOT try to log into Ubuntu as soon as possible. Wait until Cloud-Init runs (although it appears to be doing nothing - in about two minutes it will show SSH info when done). If you don't wait you may not be able to logon with the default user and passwd. At the end of the cloud-init, Ubuntu will be rebooted. Wait a couple of minutes for the server to boot.
- Find Raspberry Pi's IP address on your wifi network by logging in to your router and looking for an
ubuntudevice. My router is located at "http://10.0.0.1/". Check here for help finding yours: http://whatsmyrouterip.com/
- NOTE: On my glorious wifi network, the Raspbery Pi's IP address is sometimes mysteriously different than the one reported on the router, but is connected nonetheless. Then I have to log into the Raspberry Pi board by plugging in a monitor and USB keyboard. Installing
sudo apt get net-tools(which is possible because it is now actually connected to wifi) and running
ifconfigto get its IP address.
- Open a terminal on your laptop and
ssh ubuntu@<Raspberry Pi’s IP address>
- Change the
ubuntuuser password and reconnect
4. Prepare the USB Hard Disk
Reformat your USB Hard Disk to EXFAT (GUID) format. On a Mac you can use Disk Utility.
Plug the USB drive into Raspberry Pi USB port
get disk name:
sudo fdisk -l
Get USB device info:
- Get system info:
- Get storage device info:
- See how much space is available and used:
- See hidden files
ls -ld .?*
- Get system info:
Install EXFAT packages on Ubuntu
sudo add-apt-repository universe
sudo apt update
sudo apt install exfat-fuse exfat-utils
- If you get the error "Waiting for cache lock: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 2668 (unattended-upgr)" Then:
sudo kill -9 <process#>
Mount USB drive
- Make a directory for USB device to use (e.g. "usb0")
sudo mkdir /media/usb0
- Find name of USB storage device (e.g. "/dev/sda1")
sudo fdisk -l
- mount USB drive using exfat format:
sudo mount -t exfat /dev/sda1 /media/usb0
- make ubuntu user the owner of the USB drive
sudo chown -R ubuntu:ubuntu /media/usb0
- double-check that
ubuntuuser has write permission on the USB drive, otherwise this won't work:
- assuming your test file appeared, clean it up:
rm -f /media/usb0/text.txt
5. Install IPFS
Install the go-ipfs client, see https://ipfs.io/ipns/dist.ipfs.io/#go-ipfs
If you have a Raspberry Pi 4 you can install the Linux 64-bit ARM version, otherwise use the Linux ARM version.
Linux ARM (32 bit):
sudo wget https://ipfs.io/ipns/dist.ipfs.io/go-ipfs/v0.6.0/go-ipfs_v0.6.0_linux-arm.tar.gz
sudo tar -xvzf go-ipfs_v0.6.0_linux-arm.tar.gz
sudo bash install.sh
change ipfs repo location to USB drive:
sudo nano /etc/environment
check that IPFS is going to use your USB drive as its repo (not your tiny micro SD card)
echo 'Hello IPFS!' > test.txt
ipfs add test.txt
note the Content ID (CID) it reports back, e.g "QmYWAifyw2V5dEq7c5GgdSPffeKoYXQZggnYzw5RbXpig4"
ipfs cat QmYWAifyw2V5dEq7c5GgdSPffeKoYXQZggnYzw5RbXpig4
Welcome to decentralized storage on Raspberry Pi!
Go to https://docs.ipfs.io/how-to/ and start IPFS-ing with your Raspberry Pi.