Build your own Ethereum Mining Rig, part 2: Linux Setup

In this second installment of our DIY Ethereum mining guide, we’ll look at how to install and configure Linux to setup your rig as an automated, remotely-manageable appliance. Don’t be dissuaded if you’ve never used Linux before—our step-by-step guide makes it simple!

Why Linux over Windows? First, it’s free—and saving ~$100 on the operating system is a big plus when you’re trying to maximize profitability. Other reasons include lesser hardware requirements (Linux is perfectly happy running from a USB stick plugged into ancient hardware!), simpler remote administration capabilities, and oftentimes better stability. The downside of running Linux is that video driver support isn’t on the same level as Windows, and things like GPU undervolting are trickier (but still possible via BIOS mods).

If you missed the hardware portion of our guide, make sure to check it out first. Otherwise, read on.

Build an Ethereum Mining Rig, part 2:  Linux Setup

The following is heavily adapted from my original 2013 Litecoin mining guide, updated for the latest Xubuntu LTS version, the new AMDGPU-PRO drivers, and necessary ethereum mining software. If you’re a bit nervous because you’ve a complete Linux newbie, don’t be. Simply follow the step-by-step instructions exactly as they’re written, and you’ll be fine. Even if you’ve never done anything like this before, you should be up and running in roughly an hour.

Step 1: Configure BIOS settings

Before we even get to Linux, let’s take a minute to make sure that your mining computer’s BIOS settings are in order. Power on your computer, and press the “delete” key a few times immediately after power on. You should end up in the BIOS configuration area. Do the following, then save & exit:

  • Change power options so that the computer automatically turns itself on whenever power is restored. The reason for this is two-fold: first, it’ll make sure that your miner automatically starts up after a power outage. Second, it makes powering the computer on much easier if you don’t happen to have a power switch connected to the motherboard.
  • Make sure that your USB stick is first in the boot-up order (you may need to have a USB stick attached).
  • Disable all components that you don’t plan to use. This may save a little bit of power, and since your miner will likely be running 24/7, it’ll add up. For me, that meant disabling onboard audio, one of the SATA controllers, the USB 3.0 ports (I only had a 2.0 USB stick), the Firewire port, and the serial port.
  • If you’re running a lot of GPUs (4+), additional tweaks might be necessary to ensure that they’re all recognized by the OS. Exact tweaks vary by motherboard, but setting the PCIe speed to Gen1 is usually a good place to start. No need to change anything now, but make a mental note that you may need to come back and play around a bit if all of your GPUs don’t show up in the OS later.

Step 2: Install Xubuntu Desktop on your miner

Xubuntu is a lightweight version of Ubuntu, a popular Linux distribution. Most other distros should work just fine, but be aware that the GPU drivers require the presence of Xorg, which means server distros that don’t have a GUI will not work properly.

  • Xubuntu 16.04.2 is the latest LTS release at the time of this guide, so that is what I recommend you use. You can download it here.
  • You’ll need to either write the installation ISO image to a USB stick (highly recommended), or burn it to a DVD. If you use a DVD, you’ll need to temporarily hook up a DVD drive to your mining rig for the installation (make sure you temporarily enable your SATA controller if you disabled it in step 1!).
  • Once you have the installation media prepared, you’re ready to install Xubuntu to your miner’s boot device (whether it’s an SSD, mechanical harddrive, or another blank USB stick). Boot using your new installation media (make sure it’s first in your miner’s BIOS boot order list). The Xubuntu installer should appear.
  • Follow the prompts, and make sure to click the “auto-login” box on the last step of the installer (otherwise, all of the default options are fine).
  • When the installation is complete, you should automatically boot into the Xubuntu desktop. Make sure to remove your installation media.

Step 3: Install SSH and package updates

At the Xubuntu desktop, press CTRL+ALT+T to open a terminal window.

  • Install SSH by typing:
    sudo apt-get install openssh-server

With SSH installed, you can unplug the keyboard/mouse/monitor from your miner, and complete the rest of the installation from your desktop computer. Simply download Putty onto your desktop, run it, and enter the IP address of your mining rig (type ifconfig at the Xubuntu terminal to find your miner’s address if you don’t know it—it will probably look like 192.168.0.x). That should bring up a remote terminal session to your miner, which is more or less just like sitting at the keyboard in front of it.

If you plan to manage your mining rig remotely over the internet, you’ll need to forward port 22 on your router to your miner. Make sure that you use a strong Xubuntu password!

Setup should be pretty quick from this point, as now you can simply copy text from this webpage (highlight it and press CTRL+C) and then paste it into your Putty session by simply right-clicking anywhere inside the Putty window. I highly recommend that you complete the remainder of the guide in this manner, as it eliminates the risk of typos!

  • Install package updates by typing (or copying & pasting via right-click into Putty) the following command (8/14/2017: skip the following command until this known issue has been resolved):
    sudo apt-get dist-upgrade

Step 4: Install AMDGPU-PRO drivers

Next up, we’ll install AMD’s video drivers. I tested several versions and found that the latest release (17.10 as of 6/9/2017) gives the best performance. So that’s what we’ll use.

  • Type the following commands (press “enter” and wait for the operation to complete at the end of each line):
    cd ~/Downloads
    wget --referer=http://support.amd.com https://www2.ati.com/drivers/linux/ubuntu/amdgpu-pro-17.10-414273.tar.xz
    tar -Jxvf amdgpu-pro-17.10-414273.tar.xz
    cd amdgpu-pro-17.10-414273
    ./amdgpu-pro-install -y
  • Some of these steps may take a minute or two to complete. When the installation is complete, type the following:
    sudo usermod -a -G video $LOGNAME
    sudo reboot

The second command will reboot your rig, which will cause you to immediately lose your SSH (Putty) connection. Wait a few seconds to give the computer a chance to boot, and then re-establish a new connection via Putty, and re-login.

Step 5: Install Ethereum software

Next up, we’ll install the Ethereum software that will let us create a new wallet address. We’ll need this to store the coins we receive from mining.

  • Type the following to install the necessary ethereum packages:
    sudo add-apt-repository ppa:ethereum/ethereum
    sudo apt-get update
    sudo apt-get install ethereum geth
    
  • Now it’s time to create your Ethereum wallet address:
    geth account new

You’ll be prompted to enter a password, and then to confirm it (use a strong password!). The output will be a long string between two curly braces { }. That’s your new wallet address—make a note of it (highlight it within Putty to copy it to your clipboard).

Important: The combination of the password you just used to create this address *and* the associated encrypted key file is what gives you control over your new wallet address. If you lose either of these, you’ve also lost control of your wallet and all of the coins associated with it—and there is literally nothing that anyone will be able to do to help you. Remember your password, and keep multiple backups of your key file(s)!

Your key file(s) are stored in the ~/.ethereum/keystore directory. Copy the entire /keystore folder someplace safe to backup your wallet (I’ll cover backups in detail in a later section of this guide).

If you ever forget your wallet address, you can type geth account list to see your addresses and the location of their key files.

Step 6: Install Claymore’s Ethereum miner

There are several options as far as mining software, and I’ve experimented with all of the popular ones. I think Claymore’s miner is the best option, even if it does have two fairly significant downsides: it’s closed-source, and it’s not free (~1% of your mining time benefits the creator of the miner).

Two alternatives are the stock ethereum miner (ethminer) and Genoil’s fork of the stock miner. They’re both open-source and free, but they have pretty crippling downsides.

The stock ethminer is much slower than Claymore’s miner (by a margin of over 5% on my test rig). In addition, ethminer creates the Ethereum DAG file on disk instead of in GPU memory, which is slow and uses a lot of space (and if you’re running off a USB stick, all those writes may eventually wear it out).

Genoil’s fork seems to be nearly as fast as Claymore’s, and it doesn’t use physical disk space for the DAG, but it’s not stable (at least not for me). It often crashes, especially on startup (whereas I have yet to see a single crash on Claymore’s miner after nearly a week of full-time mining). The author abandoned development months ago, so improvements are unlikely.

So, explanation aside, here is how to setup Claymore’s miner:

  • First return to your downloads directory and grab the latest version (9.5 as of 6/9/2017):
    cd ~/Downloads
    wget https://github.com/nanopool/Claymore-Dual-Miner/releases/download/v9.5/Claymore.s.Dual.Ethereum.Decred_Siacoin_Lbry_Pascal.AMD.NVIDIA.GPU.Miner.v9.5.-.LINUX.tar.gz
    
  • Then create a new directory for it, and unpack it there:
    sudo mkdir /usr/local/claymore95
    sudo tar -xvf Claymore.s.Dual.Ethereum.Decred_Siacoin_Lbry_Pascal.AMD.NVIDIA.GPU.Miner.v9.5.-.LINUX.tar.gz -C /usr/local/claymore95
    
  • Then let’s head over to the installation directory and create a startup script:
    cd /usr/local/claymore95
    sudo chmod u+s ethdcrminer64
    sudo nano mine.sh
    
  • Nano will open a new blank text file; enter the following into it:
    #!/bin/sh
    export GPU_MAX_ALLOC_PERCENT=100
    ./ethdcrminer64 -epool us1.ethermine.org:4444 -ewal YOUR_WALLET_ADDRESS.Miner01 -epsw x -mode 1 -tt 68 -allpools 1
    

    Where it says YOUR_WALLET_ADDRESS, use the address you created in step 5 (you’ll need to put “0x” in front of it). The “Miner01” following your address can be changed to any friendly label that you want to give your miner (only important if you plan to run multiple rigs). It’s easiest to copy the last line from my guide into something like notepad, then replace YOUR_WALLET_ADDRESS with your actual address there, and then copy the finished line into putty via right-click to get everything into nano without typos.

  • Save the file and quit nano by pressing CTRL+X and then answering (Y)es to save the changes, then enter the following to give your new script execute permission:
    sudo chmod +x mine.sh

Note that I’m using ethermine.org as the mining pool here. It’s a fairly typical ETH pool that seems to have good reliability, but feel free to pick your own pool. Most don’t require registration, and simply payout to whatever wallet address you supply whenever a certain threshold is met (usually whenever you accumulate 1+ ETH). Assuming you stick with ethermine.org, you’ll be able to check on your miner’s status by going to this URL after you start mining: https://ethermine.org/miners/[YOUR WALLET ADDRESS]

  • Now is a good time to test things. You can fire up your miner by typing:
    ./mine.sh

You should see the Claymore miner start up. It’ll take a minute or two before it actually starts mining, but it should get there eventually. When you see a scrolling log of outputs that includes non-zero hashrates (expect hashrates in the low to mid 20s for unoptimized GPUs), you’re good to go. If the script fails to start, or you see errors, make sure that you’ve created the script exactly as outlined in the guide.

Press CTRL+C to exit the miner when you’re satisfied that it’s working.

Step 7: Create auto-start scripts

We’re almost done! We want to set up our rigs automatically start mining whenever the rig is powered on. That way, we keep mining losses to a minimum whenever a power outage occurs, and we don’t have to worry about manually starting it back up in other situations.

  • First, install screen:
    sudo apt install screen
  • Then type the following to create a new script in your home directory and open it in nano:
    cd ~
    sudo nano miner_launcher.sh
  • Enter the following text into the editor (substitute your actual Xubuntu username for YOUR_XUBUNTU_USERNAME where necessary!):
    #!/bin/bash
    DEFAULT_DELAY=0
    if [ "x$1" = "x" -o "x$1" = "xnone" ]; then
       DELAY=$DEFAULT_DELAY
    else
       DELAY=$1
    fi
    sleep $DELAY
    cd /usr/local/claymore95
    su YOUR_XUBUNTU_USERNAME -c "screen -dmS ethm ./mine.sh"
  • Save and quit nano (CTRL+X), and then type:
    sudo chmod +x miner_launcher.sh
  • Now we need to call our new script during startup; we do that by adding it to /etc/rc.local. Type the following to open /etc/rc.local in nano:
    sudo nano /etc/rc.local
  • Add the following text, right above the line that reads “exit 0” (substitute your own username!):
    /home/YOUR_XUBUNTU_USERNAME/miner_launcher.sh 15 &

Then save and quit out of nano (CTRL+X).

Step 8: Create an alias to easily check on the Claymore miner process

We’re essentially done at this point, but you’ll probably want to manually SSH into your miner from time to time to manually check on your hashrates & GPU temperatures, etc. Creating an alias will make that easy.

  • Type:

    sudo nano .bashrc
  • Scroll to the end of the file, and then add this text above the line that reads “# enable programmable completion…”
    alias miner='screen -x ethm'
  • Save and quit out of nano.

That’s it—you’re done! You’ll probably want to run a full test now. The easiest way to do that is to close your Putty session and power down your miner. Turn it back on and the following should happen:

  1. Your miner should boot into Xubuntu. This may take up to a minute, depending on the speed of your boot device (it’ll be much faster on an SSD).
  2. 15 seconds after Xubuntu has loaded, the Claymore miner will automatically start and begin mining. You might notice the fans on your GPUs spin up a bit when this happens.
  3. You should be able to SSH into your miner at any time and type miner to monitor the miner’s process. To close the screen (but keep the miner running), press CTRL+A, then CTRL+D.
  4. If you ever need to start the Claymore miner manually (because you quit out of it, or kill it, etc), simply type ~/miner_launcher.sh

Output from a single budget RX 470 at stock settings running Claymore’s ETH miner. You should see something like this when connecting to your rig via SSH and running your “miner” alias.

Congratulations—you have your own headless linux ethereum miner!

The next section of this guide covers setup under Windows, and then we’ll take a look at optimizing miner settings for better performance.

504 Responses to Build your own Ethereum Mining Rig, part 2: Linux Setup

  1. Al says:

    @deadman.walking – I couldn’t reply for some reason but wanted to say thanks for the heads up re drivers. I’ve gained 30mh/s! (6 cards).

    The only issue now is power consumption. 1160w at the wall and the psu is a 1200w. Is that safe for a day until I get back in front of the rig? And also, do you know how to undervolt rx580s on Linux? Claymore settings have no effect.

    Thanks again, you are a diamond

  2. Aaron says:

    Just getting into this and wanted to say thanks for putting together a really helpful guide. My setup could be a big failure but I’m applying your guide to a laptop/external gpu setup using the minipcie slot. My one question is in regards to the eth fork. If I follow your guide and configure Linux as described, which type of eth would I be mining? I’ll continue to do research, just thought I’d ask the question incase I couldn’t find the answer.

  3. Max says:

    Im getting an error showing ./ethdcrminer not found when starting the miner, despite following all the steps.

    Any advice?

  4. probably a dumb question, but step #4, if we have nvidia cards, do we still do this? thx for the writeup, good thing I know linux and ssh and all that pretty well already though

  5. cryptoinfo says:

    Thats a good question, i know ill be burned at the stake but i prefer nvidia and want to save the windows overhead with ubuntu. Any good how to’s on that?

  6. Matt stewart says:

    Hi I am setting up 12 Sapphire Nitro+ RX580s, My issue is i can plug in 6 fine and mine but anything past 6 i get no display what so ever, i have AMDGPU PRO but still nothing.
    The only time i got any display was a error message saying that my display wasn’t detectable please help.

    -Matt

  7. gadiminas says:

    Hi. Do you use still the same versions of Xubuntu, Claymores miner and AMDGPU-PRO? I have tried Xubuntu 17.10, but it looks that some commands not working, probably I have to go back for 16.04. Also Claymores miner 10.0 gives me a lower results. Do you try to use new versions, or it is better to stay save with older stable versions?

  8. […] YOUR OWN ETHEREUM MINING RIG PART 1: HARDWARE PART 2: LINUX SETUP PART 3: WINDOWS SETUP PART 4: […]

  9. MacAries says:

    This is my second miner so I put geth on first one and generated the only wallet I need so do I also have to install geth and the miner on the second rig or just the miner software?

    • Zelda says:

      No need to install geth on the second rig, assuming the miner software is working within a pool. The pool is essentially running geth for all its associated miners. You only needed it to generate a wallet.

  10. CryptoBach says:

    Hi,

    First of all, great guide!

    Did you experience by any chance any GPUs hanging in OpenCL call when running the miner? Also, one of my GPUs ‘gets lost’ when mining but I think that’s a problem of not having enough air flow aka overheating.

  11. Calvin says:

    Hi! good guide;
    I am having trouble running mine.sh, as when I do, the puTTY terminal returns Unterminated quoted string. I have copied the text on this site verbatim, but nothing works. any ideas?

  12. […] Build your own Ethereum Mining Rig, part 2 … – CryptoBadger […]

  13. benjamin says:

    my claymore 10.1 always get this error

    Files “reboot.bash” and “reboot.sh” not found: ./reboot.sh

    and it freeze there.. using linus centos 7

    new in linux can you guide me?

    • Zelda says:

      Claymore looks for those files when it decides a reboot is required to clear an error. Search the documentation regarding the -r 1 option.

      If you’re setting that option, you should create a file reboot.sh in the same directory. Here’s what mine comprises:
      # executed by claymore if -r1 option is set
      # place this file in claymore directory, symbolic link for convenient access
      # visudo to allow sudo commands without password
      echo “Reboot ordered by Claymore” | systemd-cat -t mineclay-reboot -p warning
      sleep 12 # delay for watcher to observe reboot order
      sudo /bin/systemctl restart mineclay.service

      But I use systemd rather than rc.local on startup, so you should probably keep it simple with just:
      sudo /sbin/reboot

      Make it executable:
      chmod ugo+x reboot.sh

      Then test it:
      ./reboot.sh

      The system should reboot, which means that when claymore invokes the file, the system will reboot. Note that it shouldn’t prompt for a password. If it does, use visudo to add permission to invoke reboot without sudo password.

      One last note: This is all how it works in Ubuntu 16.04, the Debian side of Linux. I spend time in the Centos/Redhat side of Linux, so some tweaks may be required to get this working in your environment.

      Happy mining!

  14. […] Build your own Ethereum Mining Rig, part 2: Linux Setup … […]

  15. […] Build your own Ethereum Mining Rig, part 2 … – CryptoBadger […]

  16. Al says:

    Built this rig completely according to this guide’s specs. It can mine at 26 Mh/s but only when one GPU is connected. When I try to connect more, it never boots and if it does it takes me to a screen that says “Please install the PSU’s 4-pin power cables to the 4-pin power connectors on your motherboard” –> has anybody else encountered this?

    I did connect one PSU 4-pin cable into one of the two ports but it still boots directly to that message.

    If anyone else has encountered anything similar, please let me know how you progressed from there.

    Thanks!

    • Zelda says:

      Currently running 7 GPUs, and none of them draw power through the motherboard. They’re all connected via risers, each with two power supply connections, one Molex and one VGA. If you’re going for scale, this is a more typical approach.

  17. Mark says:

    Followed the Guide as expected but only getting 18.75 Mh/s on an rx 580 (admittedly haven’t overclocked yet) any advice??

  18. Steve says:

    That is all I got out of the rx580. I get 26Mh/s from GTX 1070.

  19. […] Build your own Ethereum Mining Rig, part 2: Linux Setup … […]

  20. […] Build your own Ethereum Mining Rig, part 2: Linux Setup … […]

  21. […] Build your own Ethereum Mining Rig, part 2 … – CryptoBadger […]

Leave a Reply

Your email address will not be published.