How to Build a Zcash Miner on Ubuntu Linux 16.04 with Optiminer 1.5 with AMD GPU’s
By: Rolf Versluis
Tags: Zcash, Optiminer, Mining

A few weeks ago I posted a how-to on building a Linux GPU miner for Claymore. Well, at least as of right now, the Optiminer 1.5 Zcash miner is faster than Claymore. I have set up my mining rigs to run both Claymore and Optiminer now. I recommend you run Optiminer 1.5 on Ubuntu Linux.

It’s much easier to SSH into a remote linux miner and change what it is running than to do the same thing with Windows. No VPN connection required, just SSH to my $10/month VPS box running Linux, SSH from there to the Linux box at my small office that my firewall forwards TCP port 22 to, and from there SSH to my GPU-miners.

Copy the files from one miner to another with SCP, reboot remotely if the mining application hangs, and otherwise do complete management remotely. Linux is great for system administration!

Here’s the speed of Optiminer 1.5 on a six GPU mining rig running Sapphire Nitro R9 Fury cards — about 2620 H/s:

And on a miner with six XFX RX480–8G GPU’s. It’s around 1730 H/s

The improvement over the Claymore application is enough to make the switch. By the way, this is with stock, unmodified BIOS on the GPU’s.

Bill of Materials

Equipment list — Links are to Newegg or Amazon or Parallel Mining product page

PCI-E Risers — ELEGIANT PCI-E USB 3.0 Cable Express 1X to 16X Extension Cable — Mining Dedicated Graphics Card Extension Cable Adapter with SATA Cable for PC Desktop Laptop — qty 6 at $11 — $66 GPU’s — SAPPHIRE NITRO Radeon R9 Fury 100379NTOC+SR 4GB 4096-Bit HBM TRI-X OC+ (UEFI) Video Card — qty 6 at $260 — $1550 ATX power switch — PC Case Red Green LED Lamp ATX Power Supply Reset HDD Switch Lead 20" — $10

Total Cost for Bill of Materials — $2270

Build Notes:

I used an MSI board in the video, and the Biostar on a different build. I like the Biostar better because it does not require any messing around with BIOS. It just works. And it costs less.

Buy twice as many PCI-E risers as you think you will need. I’ve tried 3 different brands, and usually half of the risers will be bad and won’t work. Most of the time the GPU card will stop working due to a bad risers after a few hours or a day. This latest batch had some that had electric shorts that prevented the PC from starting!

You may want to buy two of the HP power supplies also.

Build Instructions

I always forget something when I build the machine. Here’s some basic instructions for the most efficient order of operations. The idea is to get a basic computer built, troubleshoot any potential issues, install the operating system and application, then build the rest of the machine.

Hardware Build — Part One

Assemble the Case Put the CPU, CPU fan, and memory on the motherboard. Plug in the fan. Attach the ATX switches and LED’s to the power header. Plug the SATA cable into the motherboard. Put the motherboard in the case on the already attached rubber offsets. Attach the Antec power supply to the right side of the case. Use the screws that came in the box. Attach power cables from the Antec power supply to the Motherboard, CPU power, SSD. Attach the HP power supply and X5 board to the left side of the case. Use the bottom two fan screws from the HP power supply. Screw in one of the PCI-X Riser cards, plug it into the PCI-E slot closest to the processor, and plug in power from the power supply. Attach a keyboard, mouse, and HDMI monitor to the machine. Plug the power cord into the Antec power supply, turn on the power switch. Press the ATX power button. The machine should boot.

If it doesn’t boot, this is the time to do basic troubleshooting. Don’t add any more graphics cards until later after the operating system is installed. The motherboard has a VGA connector if you want to connect a monitor directly to it. Just make sure there are no graphics cards plugged in if you use the onboard video.

Software Installation and Configuration

Initial Operating System Setup

Install Ubuntu 16.04 LTS Server

Do a standard install using all the defaults , include OpenSSH on installation

After install, login with your username and password

Get ip address with

ifconfig

Go to your PC, ssh to the Ubuntu machine, and do the rest of the setup from your PC so you can copy and paste the commands. I prefer to SSH from Bash shell, but Putty is a good client also.

If you are using a Bash shell from Windows or a Linux machine, or terminal from a Mac, make your logins easier in the future by creating a key on your own computer, then placing it on the miner. Do this on your own computer, at the shell prompt:

ssh-keygen -t rsa -b 4096 "ssh-copy-id user@server"

Type the password for the miner, and that should be it. Now you can login without using a password because your trusted key is installed.

Make things easier

Install some basics

sudo apt update

sudo apt install git screen vim nmap ncdu busybox inxi links unzip python

Change colors in the VIM editor. If you don’t like VIM, use nano instead.

vim .vimrc

Add in new file .vimrc

:color desert

Improve the bash shell

vim .bashrc

In the file .bashrc

change #force_color_prompt=yes

to

force_color_prompt=yes

add this at the end:

LS_COLORS=$LS_COLORS:'di=0;36:' ; export LS_COLORS

Upgrade the operating systems in a screen:

screen -S upgrade

sudo apt dist-upgrade

ctrl-a d to get back

Fix the network so IP address can be changed from DHCP

Not sure why Ubuntu locks one IP address into itself when it first gets an IP address. But it does. So that needs to be changed.

Step 1: Disable the default Firmware inherited names.

Edit your /etc/default/grub

sudo vim /etc/default/grub

Change the line from

GRUB_CMDLINE_LINUX_DEFAULT=””

to

GRUB_CMDLINE_LINUX_DEFAULT="text"

Change the line from

GRUB_CMDLINE_LINUX=””

to

GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"

make it take effect

sudo update-grub

Step 2: Create the persistent file /etc/udev/rules.d/70-persistent-net.rules as root and fill them.

sudo vim /etc/udev/rules.d/70-persistent-net.rules

Paste this into the new file you just created:

# This file was automatically generated by the /lib/udev/write_net_rules

# program, run by the persistent-net-generator.rules rules file.

# # You can modify it, as long as you keep each rule on a single

# line, and change only the value of the NAME= key.

# PCI device lan Device

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="XX:yy:XX:yy:XX:yy", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="ethX"

# PCI device Wlan Device

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="XX:yy:XX:yy:XX:yy", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="wlanX"

Edit the network interfaces:

sudo vim /etc/network/interfaces

Change device names to eth0 so it reads:

# The primary network interface

auto eth0

iface eth0 inet dhcp

Look up your hardware device name (MAC address) with

ifconfig

example:

HWaddr 4c:cc:6a:67:57:07

Go to your DHCP server and map your preferred IP address to the hardware address. You’re on your own for that one. Note that this is entirely optional! You can leave the IP address that was assigned and not change it if you prefer.

Check in the screen to make sure the update is finished

screen -r

When the update is finished REBOOT

sudo reboot

SSH to box using the new IP address you assigned in your DHCP server!

If you didn’t change it, then it should be at the same address as before. If you can’t find it, login to the terminal at the computer, type

ifconfig

if you only have a loopback address of 127.0.0.1 then run the DHCP client to get an ip address you can ssh to

sudo dhclient

and redo the network fix.

Install AMD video driver and SDK

Copy 2 files from PC to server somehow. I like to use scp, but sftp works also.

AMD Linux Ubuntu Driver 16.50

AMD OpenCL SDK 3.0

Install AMD driver

tar xf amdgpu-pro-16.50-362463.tar.xz

cd amdgpu-pro-16.50-362463/

sudo ./amdgpu-pro-install

Install AMD SDK (optional — some application need this, others don’t)

tar xf AMD-APP-SDKInstaller-v3.0.130.136-GA-linux64.tar.bz2

sudo ./AMD-APP-SDK-v3.0.130.136-GA-linux64.sh

Add user to video group

sudo usermod -a -G video $LOGNAME

Check amdgpu driver status

sudo apt install clinfo

sudo clinfo

sudo clinfo | grep compute

REBOOT

sudo reboot

Install X server and Display Manager

Install xorg

sudo apt install xorg xserver-xorg-legacy xserver-xorg-video-dummy

Edit the config file for xorg-legacy:

sudo vim /etc/X11/Xwrapper.config

delete the last line:

allowed_users=console

insert at end of file:

allowed_users=anybody

needs_root_rights=yes

Create a new file for operating without a monitor connected to box:

sudo vim /etc/X11/xorg.conf

create new file xorg.conf:

Section "ServerLayout"

Identifier "X.org Configured"

Screen 0 "Screen8" 0 0

EndSection



Section "Files"

ModulePath "/usr/lib/xorg/modules"

FontPath "/usr/share/fonts/X11/misc"

FontPath "/usr/share/fonts/X11/cyrillic"

FontPath "/usr/share/fonts/X11/100dpi/:unscaled"

FontPath "/usr/share/fonts/X11/75dpi/:unscaled"

FontPath "/usr/share/fonts/X11/Type1"

FontPath "/usr/share/fonts/X11/100dpi"

FontPath "/usr/share/fonts/X11/75dpi"

FontPath "built-ins"

EndSection



Section "Device"

### Available Driver options are:-

### Values: <i>: integer, <f>: float, <bool>: "True"/"False",

### <string>: "String", <freq>: "<f> Hz/kHz/MHz",

### <percent>: "<f>%"

### [arg]: arg optional

#Option "ShadowFB" # [<bool>]

#Option "DefaultRefresh" # [<bool>]

#Option "ModeSetClearScreen" # [<bool>]

Identifier "Card8"

Driver "dummy"

VideoRam 16384

EndSection



Section "Monitor"

Identifier "Monitor8"

HorizSync 15.0-100.0

VertRefresh 15.0-200.0

Modeline "1600x900" 33.92 1600 1632 1760 1792 900 921 924 946

EndSection



Section "Screen"

Identifier "Screen8"

Device "Card8"

Monitor "Monitor8"

SubSection "Display"

Viewport 0 0

Depth 24

Virtual 1600 900

EndSubSection

EndSection

Make sure X works for user on login

vim .bashrc

Add the following at end of .bashrc

export DISPLAY=:0

Change /etc/profile to make it work

sudo vim /etc/profile

# add the following at end of /etc/profile:

export XAUTHORITY=~/.Xauthority

Set variables when user calls X

vim .xinitrc

create new file .xinitrc:

#!/bin/bash

DISPLAY=:0 && xterm -geometry +1+1 -n login

Install Optiminer Zcash GPU Miner

Download the file from the webpage at https://github.com/Optiminer/OptiminerZcash by typing

extract it:

tar xf optiminer-zcash-1.5.0.tar.gz

Set it up:

cd optiminer-zcash

change the mine.sh file to make the first three lines look like this:

#!/bin/sh

xinit &

sleep 5

Change the t address you are mining to in the mine.sh file, and make sure you are connecting to your local flypool server, then start mining.

Enter a screen

screen -S mining

run the miner

./mine.sh

Watch and see if anything breaks. This could be an error code, hardware freeze, or something else.

If it goes well, great! Go on to the next step. To exit the screen and keep the miner running when you log out of your session, type a Ctrl-a, followed by just the key d.

ctrl-a d

Then exit your ssh session with

exit

If there is a problem, it is usually:

riser hardware problem

power cable or power supply problem

resource contention. If this happens, turn off unneeded service in the BIOS. First turn off sound, then serial port.

Get the entire rig Running

Add one riser and GPU at a time, boot, and make sure it works. First power 3 of the cards from the Antec power supply. Then power the other 3 cards with the HP power supply. Quick way to see if Ubuntu recognizes the board is with

lspci | grep VGA

or

sudo clinfo | grep compute

This box is going to pull 15 amps at 110 VAC. Be careful with your breakers. The power supplies run more efficiently at 200+ volts. If you have the option to supply your miner with more than 200VAC, do it.

Finally, if everything is working, turn up the intensity. In the mine.sh file, add -i 7 to the optiminer start command, so it looks like this:

./optiminer-zcash -s $POOL -u $USER -p $PASSWORD -i 7 --watchdog-timeout 30 --watchdog-cmd "./watchdog-cmd.sh"

Best of luck — let me know if you have comments or questions on this build.

Rolf Versluis