Setup Ethereum Mining in Linux

Brandon Harris
4 min readDec 23, 2017

This guide is for people looking to get setup mining ethereum on Linux. You can use ethOS, but it is my opinion that you should not have to pay for free software. With a little bit of your time, you can save money and get a rock solid setup. If you are looking for a hassle-free way to mine on linux with overclocked GPU’s, this guide is for you.

Assumptions

The first step in the process is to obtain all of your hardware. Here is a list of the hardware that I have used several times to get setup.

This list is not the only configuration, just the one that I have used and recommended. For instance you can choose a SATA ssd, or even use a USB stick. On this particular motherboard, you can add 2 more cards using M.2 risers.

Now lets get started.

Install Ubuntu Server

There are several guides that should help you if you are new to this. It is my assumption that you are comfortable following the guided install.

  • Tip: Pick Open SSH server to preinstall the secure shell if you will be using Putty or shelling in from another computer

Update your installation

sudo apt update
sudo apt upgrade
sudo apt dist-upgrade
sudo reboot

Installing the AMD GPU drivers

wget --referer=http://support.amd.com https://www2.ati.com/drivers/linux/ubuntu/amdgpu-pro-17.40-492261.tar.xztar -Jxvf amdgpu-pro-17.40-492261.tar.xzcd amdgpu-pro-17.40-492261./amdgpu-pro-install -ysudo usermod -a -G video $LOGNAME

This will compile and install the modules needed to run your cards correctly at the best hashrates possible. On Ubuntu 16.04 there is an additional step required to enable the full virtual memory page size and get the highest hashrate.

Editing GRUB for AMD GPU’s

sudo vim /etc/default/grub

Add the following line:

GRUB_CMDLINE_LINUX="amdgpu.vm_fragment_size=9"

Now update grub and reboot

sudo update-grub
sudo reboot

When the system restarts you should see several startup lines where the amdgpu drivers are initializing.

Setting up Claymore

wget https://github.com/nanopool/Claymore-Dual-Miner/releases/download/v11.8/Claymore.s.Dual.Ethereum.Decred_Siacoin_Lbry_Pascal_Blake2s_Keccak.AMD.NVIDIA.GPU.Miner.v11.8.-.LINUX.tar.gztar -xzvf Claymore.s.Dual.Ethereum.Decred_Siacoin_Lbry_Pascal_Blake2s_Keccak.AMD.NVIDIA.GPU.Miner.v11.8.-.LINUX.tar.gz -C /usr/local/claymore11/cd /usr/local/claymore11

As of dag epoch 200, Claymore v10 is deprecated. You will need to run v11.8 or later.

Now let’s create a mining executable script so we can easily stop and start mining.

sudo vim mine.sh

Add the following to this file:

#!/bin/bashexport GPU_MAX_HEAP_SIZE=100
export GPU_USE_SYNC_OBJECTS=1
export GPU_MAX_ALLOC_PERCENT=100
export GPU_SINGLE_ALLOC_PERCENT=100
export MINING_POOL="PASTE YOUR POOL"
export WALLET="PASTE YOUR WALLET"
./ethdcrminer64 -epool $MINING_POOL -ewal $WALLET -epsw x -mode 1 -tt 70 -allpools 1

Be sure to paste the url to your mining pool above and the wallet address. Now make this file executable

sudo chmod +x mine.sh

Simply running ./mine.sh will start your miner!

Make your miner a daemon

Things will happen, you will need to reboot your system, your power may go out and you are not around to manually start your miner. Lets set up a systemd process to automatically start your miner when on bootup.

sudo vim /lib/systemd/system/ethminer.service

Put the following in this file:

[Unit]
Description=Ethereum Mining Daemon
After=network.target
[Service]
User=root
Group=root
WorkingDirectory=/usr/local/claymore10
Type=simple
ExecStart=/usr/local/claymore10/mine.sh
GuessMainPID=no
[Install]
WantedBy=multi-user.target

Now lets run a few commands to enable and run this service. Be sure you are not running ./mine.sh manually

sudo systemctl daemon-reload
sudo systemctl enable ethminer
sudo systemctl start ethminer

Great! You have now daemonized your miner! Your logs are now going into the system logger. To view them you would run this:

journalctl -fa -u ethminer

Now on reboot or power cycle you can be sure that your miner is always running. I have the following aliases in my ~/.bashrc file:

alias watchminer='journalctl -fa -u ethminer'
alias startminer='sudo systemctl start ethminer'
alias stopminer='sudo systemctl stop ethminer'

This makes life a little easier. If I want to view the claymore output, I just run watchminer . If I need to make adjustments stopminer and when I’m ready to start the miner again, startminer .

Overclocking and Undervolting

My personal advice is that you overclock and undervolt to stable levels and don’t overdo it. If you overdo it, you will run into problems on bootup, get incorrect shares and cause general instability. Mining is a long term approach to increasing your crypto position.

On linux your options to overclock and undervolt are limited. What I have found the easiest is to use the atiflash utility in linux, and modify the GPU bios on a windows VM.

This guide lays out the general process:

A modification that I would add is to use this Editor and the one click straps:

The only edit to make in the editor is the one click timing patch and change the 1750 / 1000 memory speed. I have found that on most cards I can get a stable system and a hashrate of 28–29 Mh/s using: 2000/975.

You can be more aggressive, but remember that my goal is a stable and consistent mining rig.

If you find this guide helpful, please consider a small token of gratitude:

Ethereum:

0x15a14E8393B9c492196Dd431CF5023f6F0ccB142

BTC:

179QCkz3xsgbb72Fq2taQ1NuG7Km59N3BF

Raiblocks:

xrb_1zkzjmj9toa8qfag6pq47yoruui749dby7phghg74mhf6z36qen13x4i6d4x

--

--