Setting up a Chia plotter on an Intel NUC
9 min read

Setting up a Chia plotter on an Intel NUC

This guide builds on top of the ChiaDecentral guide for plotting Chia on an Intel NUC.

It's currently a work in progress, so proceed at your own risk.

Also, please hit me up if you have questions or need any help/support.

Purchasing Equipment

In addition to the equipment listed in the ChiaDecentral guide, you'll need:

  • an HDMI cable
  • an ethernet cable
  • a USB keyboard
  • a Phillips screwdriver (3/16 size worked for me – just kind of "regular household size" should work)
  • a small Phillips screwdriver for working inside the NUC (bonus if it's magnetic)
  • a USB flash-drive (mine is 64gb and worked just fine)

Setting up the NUC

Install the BIOS update

Install the BIOS update on the NUC by following the steps in the guide. Note that you'll need a flash-drive to do this.

You'll need to format the drive into the FAT format. To do this:

  • plug the drive into your macbook
  • open Disk Utility
  • right click on the drive and click "erase"
  • select "MS-DOS" as the format

Note: You will lose all data on the drive, so make sure you're cool with that.

Once you've formatted the drive an put the BIOS update on it, you're ready to install the BIOS update on the NUC.

Make sure the NUC is turned off. Plug the flash drive into it, then turn on the NUC and press and hold F7 while it boots get to the BIOS update menu.

Install Ubuntu server on the NUC

The big thing to keep in mind here is that you want to install Ubuntu server on your boot drive, not your NVME SSD or your HDD.

The easiest way to make sure you don't mess this up is to disconnect the NVME SSD and the HDD from the NUC while you're installing Ubuntu server.

Get Ubuntu server onto a flash drive

Here are the basic steps to get Ubuntu server onto a flash drive:

  • Download Balena Etcher onto your macbook
  • Download Ubuntu server from https://ubuntu.com/download/server (the version I'm seeing is 20.04.2)
  • In Balena Etcher, click "Flash from file" and select the file you just downloaded (probably from your Downloads folder)
  • Next, select the target. Choose your flash drive.
  • Click "flash". This will copy the file to your flash drive. It should be quick. For me it took about 30 seconds.
  • Unplug your flash drive from your macbook
  • You're all set!

Installing Ubuntu server on the NUC from a flash drive

Make sure the NUC is turned off.

Plug the flash drive into the NUC, then turn it on. You should see a prompt for installing Ubuntu server from the flash drive.

Note: If you don't see this, you may need to change the "boot from drive" configurations for your NUC. To do this, turn off the NUC and turn it back on while holding F2. You'll be able to update the preferences for which drive gets priority when you can boot from several. However, the best strategy here is to remove all hardware that isn't necessary. In other words: don't plug in your HDD and NVME SSD until the Ubuntu server installation is complete.

While going through the installation, you can go with all of the default options.

Ubuntu server housekeeping

Make sure that all the packages on the NUC are up to date.

sudo apt-get update && sudo apt-get dist-upgrade -y
To learn more about what these commands are doing, see this StackOverflow answer.

To ensure that you can ssh into the NUC from your laptop, you'll need to ensure that openssh-server is installed.

sudo apt-get install openssh-server -y

Now you can edit the configurations for openssh-server:

sudo vim /etc/ssh/sshd_config

Find the part of the configuration that says:

# Port 22

Uncomment that line and, optionally, change the port number. (This is recommended for security. Just make sure to remember the number you set it to.)

Port 1234

Save and quit with :wq.

Allow traffic on this port with:

sudo ufw allow 1234

Then restart the ssh service:

sudo service ssh restart

Now you should be able to SSH into the NUC.

The last thing you'll need is the IP address of the NUC, which you can get by running:

ip address

The output for this command is broken into various sections, which are numbered along the left hand side. Section 1 is for the loopback address, which we don't care about.

Section 2 is the one you're looking for. Look for the line that says inet (not inet6) and your IP address will be the first thing after the word inet.

The address will look something like this: 123.123.0.123/24

The number after the slash is the subnet mask, and you don't need it.

SSH into the NUC

From your laptop, run the following command:

ssh <username>@<IP Address> -p<PORT>

Substitute in your username on the NUC and the IP address that you got above; the port will be whatever you chose when editing the sshd_config file.

Once you hit Enter, you should be prompted for your password before being connected to the NUC.

You're in! πŸŽ‰

Restrict ssh access (public key authentication)

On your laptop, generate a new keypair for yourself, if needed:

ssh-keygen -t ed25519 -C "your_email@example.com"
Source: Github help docs

You'll be asked to specify a directory in which to save your keypair.

Run this command on your laptop to send your public key to your NUC:

ssh-copy-id -i <path to your public key> <username>@<IP Address>

Check that it worked by ssh-ing into the chia plotter without your password:

ssh -p <PORT> -i "<path to your public key>" <username>@<IP Address>
Note that the path to the public key needs to be in quotes

Once you've confirmed that this works, you may want to save it as an alias on your machine. You can do this by adding the following line to your .bash_profile or equivalent configuration file (e.g. .zshrc).

alias ssh-chia-plotter='<command shown above>'
Again, note the quotes here. Make sure to use single quotes, rather than double quotes.

Now you can reload your bash profile and check that the alias works.

source ~/.bash_profile  # πŸ‘ˆ or your shell config file of choice
ssh-chia-plotter
You should be ssh'd into the NUC without needing a password.

Finally, let's turn off password-based authentication for SSH, to increase the security of your NUC.

SSH into the NUC and edit the sshd_config file, as we did before. This time, though, you'll set PasswordAuthentication to no.

sudo vim /etc/ssh/sshd_config

Find this line:

#PasswordAuthentication yes

And change it to this:

PasswordAuthentication no
Note that we removed the comment (by removing the # character) and switched yes to no

And, last but not least, restart the ssh service with:

sudo service ssh restart

Install the Chia CLI

I've reproduced the steps from the Chia CLI installation instructions for Ubuntu below for convenience. Please reference the original steps if you're having trouble.

# Checkout the source and install
git clone https://github.com/Chia-Network/chia-blockchain.git -b latest --recurse-submodules
cd chia-blockchain

chmod +x ./install.sh
./install.sh

. ./activate

# Check that it worked by running the "help" command
chia -h
You should see the output of the help command, confirming that the installation worked.

Follow the steps from JM's NUC plotting guide on ChiaDecentral, starting with the commands below:

sudo fdisk -l
sudo mkfs.ext4 -m 0 -T largefile4 -L <drivename> /dev/sda
sudo mkdir /mnt/hdd
sudo mount /dev/sda /mnt/hdd
sudo mkfs.xfs /dev/nvme0n1
sudo mkdir /mnt/ssd
sudo mount -t xfs -o discard /dev/nvme0n1 /mnt/ssd
mkdir ~/chialogs
sudo chmod 777 /mnt/hdd
sudo chmod 777 /mnt/ssd
chmod 777 ~/chialogs
sudo vim chia6.sh
(Please see the security disclaimer from the ChiaDecentral guide – this may not be best for all use-cases)

In the chia6.sh script, you're going to paste something like the commands below.

⚠️ Warning ⚠️
Don't just copy and paste the script below. You need to do some math based on your specific setup to make sure you pick the right values for the script. If you don't pick the right values, it could lead to annoying errors and wasted time.

Here are the specific things you'll need to change about the script below:

  • Make sure to change user to whatever your username is on the NUC.
  • Change the number of plots for each line in the script. You can do this by updating the value passed in for the -n parameter. (Instructions for this below.)

If you want more details on the command that creates chia plots, go to the help menu by running chia plots create --help.

Picking the right number of plots (i.e. -n value)

  • Open up the optimal size spreadsheet, which is linked to in the original guide
  • Identify the column that corresponds to your HDD's capacity by looking at the top two rows of the spreadsheet.
  • Within that column, look at the value in row 10. (This row corresponds to a plot size of k=32, which is the recommended plot size according to both ChiaDecentral and the creators of Chia.)
  • Divide the number from the spreadsheet by five, since you'll be running the chia plots create command five times.
  • Round your result down to the nearest whole number, to make sure you don't run out of space on your hardware.

The script

#!/bin/bash
screen -d -m -S chia1 bash -c 'cd /home/user/chia-blockchain && . ./activate && sleep 0h && chia plots create -k 32 -b 4000 -r 4 -u 128 -n 13 -t /mnt/ssd/temp1 -2 /mnt/ssd -d /mnt/hdd |tee /home/user/chialogs/chia1_1_.log'
screen -d -m -S chia2 bash -c 'cd /home/user/chia-blockchain && . ./activate && sleep 1h && chia plots create -k 32 -b 4000 -r 4 -u 128 -n 13 -t /mnt/ssd/temp2 -2 /mnt/ssd -d /mnt/hdd |tee /home/user/chialogs/chia2_1_.log'
screen -d -m -S chia3 bash -c 'cd /home/user/chia-blockchain && . ./activate && sleep 2h && chia plots create -k 32 -b 4000 -r 4 -u 128 -n 13 -t /mnt/ssd/temp3 -2 /mnt/ssd -d /mnt/hdd |tee /home/user/chialogs/chia3_1_.log'
screen -d -m -S chia4 bash -c 'cd /home/user/chia-blockchain && . ./activate && sleep 3h && chia plots create -k 32 -b 4000 -r 4 -u 128 -n 13 -t /mnt/ssd/temp4 -2 /mnt/ssd -d /mnt/hdd |tee /home/user/chialogs/chia4_1_.log'
screen -d -m -S chia5 bash -c 'cd /home/user/chia-blockchain && . ./activate && sleep 4h && chia plots create -k 32 -b 4000 -r 4 -u 128 -n 13 -t /mnt/ssd/temp5 -2 /mnt/ssd -d /mnt/hdd |tee /home/user/chialogs/chia5_1_.log'
Watch out! JM's original guide has a typo on the last line. The first part of the last line was cut off, so I've filled it in here.

What is the script doing?

Each line of the script creates a new screen session that runs the plotting command.

The plotting commands are staggered by one hour to ensure that you don't overload your CPU. (This is better than waiting for the entire first batch of plots to finish before kicking off the next batch.)

To my understanding, staggering by an hour is advisable because that's about how long phase 1 of plotting takes, which is the most CPU-hungry.

Here are some helpful commands for new screen users:

screen -ls  # lists out all screen sessions, with PIDs and aliases
screen -r <PID> # connect to a screen session
screen -r <alias> # connect to a screen session
Note that the script gives our screen sessions the aliases chia1, chia2, and so on.

Detaching from a screen session:

While connected to a screen session:

  • Press and hold the ctrl key
  • Tap the a key
  • Release all keys
  • Tap the d key (for "detach")

Killing a screen session:

While connected to a screen session:

  • Press and hold the ctrl key
  • Tap the a key
  • Release all keys
  • Tap the k key (for "kill")

Before you run the script

Let's make sure that we have the Chia CLI set up properly.

At risk of repeating myself here: make sure that the Chia CLI is installed and activate it:

cd ~/chia-blockchain
. ./activate
chia -h  # You should see the help output

Set up your keys

I'm going to assume you already have existing keys. If you don't, you can generate them via CLI. Otherwise, you can add your keys to the NUC using your mnemonic.

chia keys add

This will prompt you for your mnemonic, which is the 24 word phrase that you got when you first generated your wallet.

Enter the words on a single line, with a space between each word.

chia keys add
-> Enter the mnemonic you want to use: this is my mnemonic etc etc etc

You should see this in the output:

Setting the xch destination address for coinbase fees reward to <ADDRESS>
Setting the xch destination address for coinbase reward to: <ADDRESS>

Make sure that the wallet address matches your previous wallet.

You can do this by running the following command on your laptop. (assuming that's where you generated the keys)

chia keys show

This will output a bunch of stuff, including this line:

First wallet address: <ADDRESS>

Make sure that the addresses match between the NUC and your laptop. If they don't, do not move forward until you can get them matching. This part is critical.

Important security note:
I'm not a security professional, and you should definitely do your own research on how to keep your keys safe. Depending on your goals, it may be advisable to have a dedicated set of keys for plotting, farming, and long-term storage, respectively.

Troubleshooting

Here's a grab-bag of helpful commands for troubleshoting:

Checking resource utilization on the NUC:

df  # check the amount of free disk space on various devices
dstat  # check system resource statistics
htop  # check CPU core utilization (kind of like Activity Monitor on Mac OS)
tail -f /var/log/kern.log  # view OS kernel logs

Check whether plotting is going as expected

tail -f -n 250 chialogs/chia1_1_.log

(more coming soon!)

Enjoying these posts? Subscribe for more


  
    

Comments

    
    
          

        Sign in or become a member to join the conversation.