Setup a Chia farmer

I had laying around an HPE Server. Together with an JBOD shelf containing 12 4TB disks. Thats something to start with.

I setup Ubuntu Server and this is where i want to start.

Installing Chia

Installing Chia is easy. Just follow the instructions from their github wiki. Of course i did not install the GUI.

After activating the venv in the install instructions, i ran chia init.

Now you need to know if you had a wallet before or if you want to add a new one. If you had a wallet before, you want to import it. do that by running chia keys add. It will ask you for your mnemonic (the 24 words). If you did not have a wallet before, just run chia keys generate and it will create a wallet for you. It will also print the mnemonic which you should document somewhere save.

When having a wallet configured, you can start the Chia services. Run chia start -r.

Now Chia will sync the blockchain to your computer. To check the sync status run chia show -s. When your node is up to date, it will show Current Blockchain Status: Full Node Synced.

Setup the HDDs

First I needed to make a strategy on how i want to setup my disk. RAID or no RAID? Since my disks are used and not the newest ones, there is a chance that one or another will die sooner or later. If I make a RAID with one or two parity disks, I will have to replace them, otherwise all of my plots will be lost. On the other hand if I do not RAID them and a disk fails, all of the plots on that disk will be lost. The disks are not too big so if a full disks is lost, 36 plots will be gone. I decided not to RAID them, as I want to have maximum capacity and its just hardware laying around. I don't want to have stress buying a new disk.

As said, I have 12 HDDs with each 4TB. I will format them with ext4. To be able to let my plotter automatically sync the plots to these HDDs, I will mount them at /mnt/plots/hdd1, /mnt/plots/hdd2, etc.

To make them accessible I set the permissions to allow everything to everybody sudo chmod -R 777 /mnt/plots/. You can make more strict permissions, but for me that works as I am the only one working on that machine.

Lastly You want to add those mounts to chia so it will look for plots there with chia plots add -d /mnt/plots/hdd1, chia plots add -d /mnt/plots/hdd2, etc.

Setup the farmer to receive plots from the plotter

I will use plotman to plot on the plotter, so I setup rsyncd according to their documentation. This is how my configuration looks like:

lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid

# don't change the port, plotman (as of version 0.2) has the port hard coded
port = 12000

# rsync module name
[chia]
    # Path with your mounted drives
    path = /mnt/plots
    comment = Chia
    # Use the username that you log into Ubuntu with or create a new one
    uid = username
    # User group (by default same as username)
    gid = username
    read only = no
    list = yes
    # dont uncomment this, 
    #auth users = none
    # plotman does not work with authentication
    #secrets file = none
    # since we dont use auth only accept connections from plotter's ip
    hosts allow = plotter.ip.address

Last thing to do is to setup a cron to look for new plots received. You can do this manually by running chia plots check -n 5. This will issue five checks on each plot in the directories we added with chia plots add -d /mnt/plots/hddN. The more plots you have, the longer it will take. Therefore you might want to check only plots that were plotted today with chia plots check -g $(printf "%(%Y-%m-%d)T %s\n") -n 5.

Lets put these two commands in a file so we can easily run them from cron. I created checktodaysplots.sh with this content:

. ./chia-blockchain/activate && chia plots check -g $(printf "%(%Y-%m-%d)T %s\n") -n 5 && deactivate

and checkallplots.sh:

. ./chia-blockchain/activate && chia plots check -n 5 && deactivate

To create a cronjob that will check todays plots every five minutes run crontab -e and add the following line:

*/5 * * * * checktodaysplots.sh

and check all plots at 2am:

* 2 * * * checkallplots.sh

Thats it. Now we can setup a plotter!