Hosting Storage On a Raspberry Pi With Sia

Bouwe Ceunen
Axons
Published in
5 min readMay 2, 2020

Hosting on Sia can be cumbersome but this post will guide you through it. I’ve heard about Sia quite some time ago and thought it was very interesting to bring our storage needs in the hands of the general public. A lot of people have unused storage space. Currently there’s a surplus of storage renters, so renting prices are low. Renting storage space is currently cheaper on Sia than for example AWS S3. Don’t expect to make large profits (yet). Also, very useful applications keep on being developed, such as siasky.net.

Raspberry Pi with SHDD
Raspberry Pi with SHDD (Image taken by Kimberly Van der Gucht)

I’ve chosen to host unused storage space with a Raspberry Pi 4 Model B and a Seagate Firecuda 1TB. I used a storage board X825 from GeekWorm to attach my disk to the Raspberry Pi. Note that the board needs a 2.5mm barrel jack and not a 2.1mm, I ordered an adapter from the PiHut. It’s not ideal, but for my needs it will do the job. You can see my host on SiaStats. I’m also using a host dashboard to visualize my renter statistics. This will be explained further in another section.

Another important thing to mention is that I use a 64GB sd-card to have ample space for the Sia blockchain which is currently 18GB in size. I also use 64bit Ubuntu Server for Raspberry Pi. I was getting weird issues with the 64bit enabled Raspbian distribution. I downloaded the 18.04 LTS version because the 20.04 was not yet released at the time of setup.

Docker Setup

I decided to do everything in Docker because it enables me to start multiple services with a dependency on each other. My docker-compose file looks like the one described below. It uses a Docker container that was built from source because at the time of writing there were no images for arm-based (aarch64) CPU architectures. I used the sia-docker repository and the host-dashboard repository to built my images. You can always build them yourself by specifying a build context in your docker-compose file and checking out those repositories. (EDIT: There are now sia images available on DockerHub for Sia https://hub.docker.com/r/siacentral/sia and for the Sia Dashboard https://hub.docker.com/r/siacentral/host-dashboard)

services:
sia:
image: siacentral/sia:1.4.7
volumes:
- ./sia-data:/sia-data
- ./renter-data:/renter-data
ports:
- "127.0.0.1:9980:9980"
- "9981:9981"
- "9982:9982"
sia-dashboard:
image: siacentral/host-dashboard:latest
depends_on:
- sia
links:
- sia
environment:
- SIA_API_ADDR=sia:9980
volumes:
- ./sia-data:/sia-data
- ./renter-data:/renter-data
ports:
- "8884:8884"
restart: on-failure
version: '2.1'

Volumes

You can see it has 2 volumes that map on the host’s directories. The sia-data directory is used for syncing the Sia blockchain and the renter-data is for the mounted hard disk. Make sure you create those directories first before they are being mounted in the docker containers with docker-compose.

/dev/sda1 916G 6.1G 864G 1% /home/ubuntu/sia-renter/renter-data

You can add a line in your /etc/fstab file to auto-mount your harddisk.

/dev/sda1 /home/ubuntu/sia-renter/renter-data ext4 defaults,user 0 0

Ports

Port 9980 is used for the Sia API. It only has to be reachable from the inside, so you only map it to 127.0.0.1. Port 9982 (TCP) has to be open to the outside so people can put their files on your free storage. I opened up a port on my firewall and mapped it to my Raspberry Pi. The sia-dashboard depends on the sia container for getting statistics. Port 8884 is the port where the dashboard service will listen. This will enable you to see live statistics of how many contracts you have, the pricings you’ve set, etc.

Domain

We also have to set the domain address that Sia will use to identify the host. It sometimes has an issue with manually detecting this while running in Docker. You can set it by directly using siac in the Docker container.

DOMAIN="sia.ceunen.io:9982"
SIA_CONT_ID=$(docker-compose ps -q sia)
docker exec $SIA_CONT_ID ./siac host config netaddress "${DOMAIN}"

Settings

Now that we have set everything up we can zoom in on the exact settings. You can see if the blockchain has been synced with the following command. I used the blockchain bootstrap from SiaStats to speed up the syncing process by already downloading the majority of the chain. The entire chain took up approximately 18GB at the time of writing.

docker exec $SIA_CONT_ID ./siac consensus

wallet
First, we’ll need to have a wallet in order to make our siacoin available. Make sure to write down your seed. This is the only thing you’ll ever need to recover your siacoin if something goes wrong. You can now deposit siacoin in your wallet. I put 42KS (42000 siacoin) on there to begin with.

./siac wallet init
./siac wallet unlock
./siac wallet address

pricing
Second, we need to set up our pricing. This includes pricing for storage, upload, download, but also to specify how many siacoin we would like to set as collateral. If you lose the data on your disk, that siacoin will be taken. This is to ensure you’ll do everything you need to do to keep hosting storage space and safeguard the data that’s on there. I determined the pricings by looking at other hosts on SiaStats and trying not to be too cheap but still within an acceptable range.

./siac host config minstorageprice 2000SC
./siac host config minuploadbandwidthprice 100SC
./siac host config mindownloadbandwidthprice 1000SC
./siac host config mincontractprice 1SC
./siac host config minbaserpcprice 0SC
./siac host config collateralbudget 40KS

storage
Third, you’ll need to specify how much storage space you would like to make available and which directory you will make available. This is the renter-data directory that was mounted in your Docker container by the docker-compose file and maps to your harddisk.

./siac host folder add renter-data 860GB

announce
The last thing to do is to announce your host to the network and start accepting contracts. The dashboard will show you if there are still any issues.

./siac host announce

You can easily stop accepting contracts with the following command.

./siac host config acceptingcontracts false

Host Dashboard

The host dashboard is fairly comprehensive and will show you anything you need to know about your hosting statistics. It will also show any issues with your host, so it’s easy to debug. It will be open on port 8884, so if you give your Raspberry Pi a hostname siahost you can view it by going to http://siahost.local:8884 in your web browser. Make sure to install avahi-daemon to make sure your .local addresses can be resolved.

Sia host dashboard
Sia host dashboard

I hope you’ll find this as interesting to read as I found it interesting to make. Don’t forget to read the Medium post from the CEO of Sia on hosting on Sia. It will clarify even further and will go deeper into what every setting means.

--

--