Jeff Flowers / 02 May 2015 / Bitcoin/Blockchain / 13470

One of the earliest reasons to originally stir my interests in Bitcoin, was the notion of an immutable database or the Block Chain. A single source of shared truth, distributed and available to all to see; secured within a protocol really got my mind spinning. And although there are many novel methods being developed to fully harness the power and potential of Bitcoin, one cannot fully live and work within the Block Chain. The shear number of data structures and services that we depend upon in order to make up our Internet today simply cannot fit, presently.

Then I saw IPFS – and it made total sense.

Data, or content, cannot be lost. Content is parsed out on the network in a distributed fashion, as the Internet was originally envisioned and meant to be.

I suspect if you are reading this blog, you too see the value in this incredible protocol: IPFS. So why a Raspberry Pi (RPi)?

My earliest memories online were with computers that have only a fraction of the computational horsepower contained within a RPi. So I wanted to see if IPFS, which is attempting to re-invent the Internet, could I use this protocol with only a modest computer. Oftentimes, software is made to work by throwing fistfuls of clock cycles until it is made to work. To me, this represents terribly wasteful programming practices.

I’m very happy to report, that this is not the case with IPFS. The code that makes up this protocol is tight and right. It just works.

Another reason for the RPi, IPFS is aiming towards getting the Internet back on track at being truly distributed. Distributed in my mind implies access to all, not just those that can afford a powerful computer. At $35, a RPi can be put into a lot more hands than a computer costing an order of magnitude more.

Ok, lets roll up our sleeves and have some fun.

Table of Content

Materials Needed

  • Raspberry Pi 2  (Why the 2?)
    • This is the latest edition of this computer
    • No need to worry about reworking memory configuration
  • Ethernet Cable or WiFi USB dongle
  • 4 GB micro SD card
    • The entire OS, IPFS, and software dependencies can all fit on a standard 4 GB card
  • Another computer to perform the initial setup of the Raspberry Pi 2 (RPi2)
  • Raspbian OS - Debian Wheezy

Overview of Steps:

  1. Preparing the Raspberry Pi’s OS
  2. Software Installations
    1. Node.js
    2. GO Language
    3. IPFS – Protocol
    4. IPFS – WebUI

Getting Your Raspberry Pi Ready

  1. Visit https://www.raspberrypi.org/ in order to procure a copy of the Raspbian OS image file.
  2. Whilst you are downloading the image file, read through the install guides to learn how to get the image onto your micro SD card.
  3. You will need another computer in order to perform these steps of installing the downloaded image file onto the micro SD card.
  4. Once the card has had the OS installed, remove and install into your RPi2.
  5. Make sure that your Pi is connected to the Internet, for this tutorial we will assume that the computer is directly connected to a router via an Ethernet cable.
  6. Upon booting up for the first time, there are a number of configurations and localizations necessary to make your RPi2 work as your expect it.  For the remainder of this tutorial, I will be assuming a RPi2 that will be used in the USA.  Please, where needed, make changes to your location.
  7. You will be presented on initial startup a window containing various configurations/localizations.  Before continuing, select the option to “Expand Filesystem”.  This may take some time until you are told that, “Root partition has been resized”.
  8. Next comes localization of your RPi2 or “Internationalisation Options”.   The RPi2 is configured to UK options that may or may not ideally suit your needs.  Under “Internationalisation Options
    1. Change Locale
      1. De-select the default using the spacebar.
      2. Select your option, assuming that you are in the USA – that would most likely be “en_US.UTF_8 UTF_8”.  Select using your space bar and then TAB ENTER to save.
      3. When presented with “Default locale for the system environment”, select your previous choice.
    2. Change Timezone
      1. The RPi does not have an internal clock, rather it grabs the time off of a server after reading from a configuration file what is the appropriate timezone.  Hence, this needs to be set in order for your Pi to operate correctly.
    3. Change Keyboard Layout
      1. This is by far the most important setting; failure to set this correctly may result in improper key mappings.
      2. Under “Keyboard layout” -> “Other”; again we want to de-select the default UK settings.
      3. Select “English (US)” and defaults are most likely ok.  Again, if you are not USA, select the most appropriate settings.
    4. Overclock
      1. Though not needed, I do think that some overclocking is perfectly fine.
      2. “Modest” to “Medium” can be, typically, safely applied without stressing the Pi too greatly.
    5. Advanced Options
      1. Enabling of “A4 SSH” will allow for remote log in at a later time.
      2. This may be useful if you wish to run a headless system, i.e. a Pi without a monitor/keyboard, using a different computer.
    6. To save these configurations TAB to Finish and allow the system to reboot.
  9. The Pi will reboot in the command line.  We did not configure it to boot into the graphic user interface (GUI), as next steps of updating the system does not require the overhead associated with running the GUI or gooey.  The default credentials will be login – “pi” and password – “raspberry”.
  10. Within the terminal window enter the following commands and allow for each to fully run:

    >sudo apt-get update <enter>

    >sudo apt-get upgrade <enter>

    >sudo apt-get autoremove <enter>

    >sudo ldconfig <enter>

    >sudo reboot <enter>

  11. Each of these commands will result in the Pi performing various housekeeping activities.
  12. After the computer restarts, you may now want to start in the GUI environment, instead of the command line. To change this setting, enter:

    >sudo raspi-config

  13. The configuration window again appears and you can “Boot into the Desktop”.
  14. It is also a great idea at this point to change the default password at this time.
  15. Again reboot the computer and you should now have started up in the graphical user interface.

Installing Node.js

  1. Node.js is required for later installation of the IPFS WebUI components. Although this can be installed after the install of IPFS, it doesn’t hurt to perform this install right away to get it out of the way.
  2. Use the following guide to installing this software:
    1. http://weworkweplay.com/play/raspberry-pi-nodejs/
    2. You will see the initial download as:
      download node
    3. After the download, the package must be installed.  Within the terminal issue the following command:
      >sudo dpkg –i node_latest_armhf.deb
      install node
    4. This will begin the unpacking and installation of the software.
    5. Double check that node is installed properly by issuing the following terminal command: 
      >node --version
    6. You should see it return the version of node that you have running:
      node version
  3. After installation of node, it is best to reboot.  (>sudo reboot)

Installing the Go Language:

  1. The Go language is used by IPFS and its installation is required.
  2. There are a number of great tutorials explaining how to install the GO language on the Raspberry Pi, such as:
    1. http://dave.cheney.net/2012/09/25/installing-go-on-the-raspberry-pi
      1. Great tutorial
      2. Complete and useful for troubleshooting.
    2. http://blog.meinside.pe.kr/Gogs-on-Raspberry-Pi/
      1. Great resource
      2. Also a great troubleshooting tool
    3. https://xivilization.net/~marek/blog/2014/07/05/go-1-dot-3-for-raspberry-pi/
      1. This is the tutorial that we will be using for the present tutorial
      2. By far the quickest setup towards installing GO on your Raspberry Pi
  3. Launch the tutorial on your Raspberry pi, this will permit copying/pasting of commands directly into your terminal window:
    install go
  4. Using the mouse, select one line at a time from the website and then right mouse click “Copy”.
  5. In a terminal window, right mouse click and select “Paste” to enter the command.  Do this for the four lines shown.  You will see the RPi begin the process like such:
    Install Go
  6. After this process is complete, verify the install by checking its version.  Type in the terminal window:
    Go Version
    >go version <enter>

Installing the IPFS (Protocol)

  1. We will be installing the protocol first.
  2. Go to IPFS.io and then select the link “Install IPFS
    IPFS website
  3. Download the link for the “Linux ARM” into your Downloads folder (automatic).
  4. Once the download is complete, double click on the compressed file in order to extract.
    Extract IPFS
  5. Change the extraction path to your HOME directory:
    IPFS Extraction
  6. Once extracted into your HOME directory, open a terminal window:
  7. Inside of the terminal window type:
    >cd ipfs/dist <enter>(This is assuming that you extracted IPFS into a folder called ipfs in your home directory.)
  8. You must now move ipfs in order to be able to use it, type:
    >sudo mv ipfs /usr/local/bin/ipfs <enter>
  9. Move will only be successful if you perform it as a super user, hence the “sudo”
  10. You should now be able to use ipfs from the terminal.  To check, type:
    >ipfs version <enter>
  11. The version of IPFS installed on your system should now be displayed.
  12. To begin using ipfs, we must initialize.  Again in the terminal type:
    >ipfs init <enter>
    ipfs initialize
  13. IPFS, on initial startup, will generate a 2048 RSA keypair and may take some time to perform this function.
  14. Next we must start the daemon.  Within the terminal type:
    >ipfs daemon <enter>
    Daemon running
  15. IPFS the protocol is now running on your RPi and can be used.
  16. You can directly add files, look at peers that are connected, etc.  Refer to the manual pages to see what commands are available to you.

Installing the IPFS WebUI Front End

  1. IPFS also comes with a web frontend.  This allows you a graphical mechanism to check on the status of your copy of IPFS and interface with the protocol via a web interface.
  2. To begin, visit the github page hosting the IPFS WebUI:
    https://github.com/ipfs/webui
    IPFS WebUI
  3. If you haven’t already, launch a new terminal window and type:
    >cd <enter> (To make sure that you are in your HOME directory)
    >git clone https://github.com/protocol/ipfs-webui <enter>
    12 WebUI
  4. This will begin the cloning process of the software in your HOME directory.  Once completed change directories (cd) into by typing:
    >cd ipfs-webui <enter>
  5. Now we must install using our npm (package manager for node).  Issue the following command:
    >sudo npm install <enter>
    Installing WebUI
  6. If you forget to invoke super user status with npm install, the installation process will fail and you will see:
    Installation Fail
  7. sudo npm install though will correctly install all the necessary software.
  8. At this point it is best to reboot the Raspberry Pi to ensure that of the dependencies are properly functioning.  In a terminal window:
    >sudo reboot <enter>
  9. After the computer has rebooted, we are now ready to run IPFS.  In general we will first initialize the software, then start the daemon.
  10. Running IPFS WebUI:
    1. IPFS must first be initialized.   In a terminal window, type:
      >ipfs init <enter>
    2. Next the daemon must be started.  Again in the terminal window, type:
      >ipfs daemon <enter>
    3. Change directory into ipfs-webui, assuming that you installed this into your home directory:
      >cd ~/ipfs-webui <enter>
    4. Run WebUI by typing the following into your terminal window:
      >npm run dev <enter>
    5. A browser will launch and show the current status of IPFS:
      Running IPFS

Comments  

# Colin

2016-12-18 10:56

IPFS (go-ipfs 0.4.3) seems to regularly be killed by the OOM manager after about a day of running on the Pi 1 (which has 512 mb of ram). Is there a way to configure IPFS to use less ram?

Reply | Reply with quote | Quote

# Bill Shaw

2016-10-07 07:40

Great tutorial. Current version of IPFS now requires at least Go 1.7

Fortunately, they have a native build you can download.

I couldn't get 1.7 to load until I removed the go executable from /usr/bin and set v1.7 up in my path

Reply | Reply with quote | Quote

# whyrusleeping

2015-05-05 05:08

Hey There! Thanks for writing this article, I just wanted to point out a few things, while you will get the most up to date webui by installing nodejs and building it from the source, our latest published version of the webui is always available at 'localhost:5001 /webui' no installation required.

Reply | Reply with quote | Quote

Add comment


Security code Refresh

Talk to Us!

Get a quote, give us suggestions, or send us a hello :)

816.983.6923

San Mateo, California

PGP: 20AE A7E7 6CA8 F81B 4FB1 C942 BA34 7830 1DEB 320E