Build your own Litecoin Mining Rig

http://www.cryptobadger.com/2013/04/build-a-litecoin-mining-rig-linux/

 

In the second installment of our DIY litecoin mining guide, we’ll look at how to install and configure Linux to properly mine with your GPUs at optimal settings. Don’t be dissuaded if you’ve never used Linux before—our step-by-step guide makes it easy.

Linux has a few advantages over Windows, including the ability to install to a USB stick (which means you don’t need a harddrive), lesser hardware requirements (you can get by just fine with less than 4GB of RAM), and simpler remote administration capabilities. Best of all, Linux is free! However, be aware that if you’d like to undervolt your GPUs to save power, Windows might be a better choice for you (update 10/2013: no longer true!).

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

 

Build a Litecoin Mining Rig, part 2:  Linux Setup

So you’ve decided to use Linux to run your mining rig—a fine choice! If you’re still 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 about an hour.

Step 1: Configure BIOS settings

Before we even get to Linux, make sure 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 will 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, the SATA controller, the USB 3.0 ports (I only had a 2.0 USB stick), the Firewire port, and the serial port.

Step 2: Install Xubuntu Desktop to your USB stick

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.

  • Download the Xubuntu Desktop x64 v12.10 installation image.
  • You’ll need to either burn the installation image onto a CD, or write the image to a second USB stick. If you use a CD, you’ll need to temporarily hook up a CD-ROM 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 the blank USB stick on your miner. Make sure your blank USB stick is inserted into a USB port on your mining, and then boot into your installation media. The Xubuntu installer should appear.
  • Make sure to click the “auto-login” box towards the end of the installer; otherwise take all of the default installation options.
  • If you’re using a USB stick that is exactly 8GB, the installer may complain about the default partition sizes being too small. Create a new partition table with these settings: 5500mb for root (/), 315mb for swap, and the remaining amount for home (/home). If you’re using a USB stick larger than 8GB, you will not have to do this.
  • When the installation is complete, you should automatically boot into the Xubuntu desktop. Make sure to remove your installation media.

Step 3: Install AMD Catalyst drivers

Open a terminal session by mousing over the bottom center of the screen so that a list of icons appears. Click on “terminal” (it looks like a black box).

  • Type the following commands (press “enter” at the end of each line and wait for Linux to finish doing it’s thing):
    sudo apt-get install fglrx-updates fglrx-amdcccle-updates fglrx-updates-dev
    sudo aticonfig --lsa
    sudo aticonfig --adapter=all --initial
    sudo reboot
  • After your computer reboots, you can verify that everything worked by typing:
    sudo aticonfig --adapter=all --odgt
  • If you see all of your GPUs listed, with “hardware monitoring enabled” next to each, you’re good to go.

Important: you may need to have something plugged into each GPU to prevent the OS from idling it. You can plug 3 monitors into your 3 GPUs, but that isn’t very practical. The easiest option is to create 3 dummy plugs, and leave them attached to your GPUs. They’ll “trick” the OS into believing that a monitor is attached, which will prevent the hardware from being idled. Check out how to create your own dummy plugs.

If you ever add or remove GPUs to your rig later, you’ll need to re-run this command:   sudo aticonfig --adapter=all --initial

Step 4: Install SSH, Curl, and package updates

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

With SSH installed, you can unplug the keyboard/mouse/monitor (put dummy plugs into all GPUs, though) 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. 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 quicker from this point, as now you can simply copy text from this webpage (highlight it and press control-C) and then paste it into your Putty session by simply right-clicking anywhere inside the Putty window. Neat, eh?

  • Install Curl and package updates by typing (or copying & pasting into Putty) the following commands:
    sudo apt-get install curl
    sudo apt-get update
    sudo apt-get upgrade

Step 5: Install cgminer

Cgminer is the mining software we’ll be using. If the first command doesn’t work, you’ll need to check out the cgminer website and make a note of the current release version. Substitute that in the commands below.

Update: Cgminer 3.7.2 is the last version to support scrypt—do not use any version after that! In addition, depending on which version you choose to use, you may receive an error complaining about libudev.so.1 when you try to run cgminer—you can find the fix for that here.

  • Type the following:
    wget http://ck.kolivas.org/apps/cgminer/2.11/cgminer-2.11.4-x86_64-built.tar.bz2
    tar jxvf cgminer-2.11.4-x86_64-built.tar.bz2
  • If everything was uncompressed successfully, we can delete the downloaded archive; we don’t need it anymore:
    rm *.bz2
  • Now check if cgminer detects all of your GPUs properly:
    cd cgminer-2.11.4-x86_64-built
    export DISPLAY=:0
    export GPU_USE_SYNC_OBJECTS=1
    ./cgminer -n

Step 6: Create cgminer startup script

We’re almost done—now we just need to create a few simple scripts to control cgminer.

  • If you’re still in the cgminer directory from the previous step, first return to your home directory:
    cd ..
  • Type the following to create a new file with nano, a Linux text editor:
    sudo nano mine_litecoins.sh
  • Type the following into nano (note where the places you need to substitute your own usernames!) :
    #!/bin/sh
    export DISPLAY=:0
    export GPU_MAX_ALLOC_PERCENT=100
    export GPU_USE_SYNC_OBJECTS=1
    cd /home/YOUR_XUBUNTU_USERNAME/cgminer-2.11.4-x86_64-built
    ./cgminer --scrypt -I 19 --thread-concurrency 21712 -o stratum+tcp://coinotron.com:3334 -u USERNAME -p PASSWORD
  • Save the file and quit nano, then enter the following:
    sudo chmod +x mine_litecoins.sh

Note that the cgminer settings we’re using in our mine_litecoins.sh script correspond to a good starting point for Radeon 7950 series GPUs. If you followed our hardware guide, these settings will give you good hashrates. If you’re using another type of GPU, you’ll want to use Google to find optimal cgminer settings for it.

Also note that you’ll need to create an account at one of the litecoin mining pools, and plug your username and password into the script (the -u and -p parameters). I have Coinotron in there as an example, but there are quite a few to choose from.

Step 7: Create auto-start scripts

We want cgminer to 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.

  • Type the following to create a new script and open it in nano:
    sudo nano miner_launcher.sh
  • Enter the following text into the editor (substitute your Xubuntu username where shown!):
    #!/bin/bash
    DEFAULT_DELAY=0
    if [ "x$1" = "x" -o "x$1" = "xnone" ]; then
       DELAY=$DEFAULT_DELAY
    else
       DELAY=$1
    fi
    sleep $DELAY
    su YOUR_XUBUNTU_USERNAME -c "screen -dmS cgm /home/YOUR_XUBUNTU_USERNAME/mine_litecoins.sh"
  • Save and quit nano, 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 30 &

Step 8: Create an alias to easily check on cgminer

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 GPU temperatures & hashrates, 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 cgm='screen -x cgm'
  • Save and quit out of nano.

That’s it—you’re done! You’ll probably want to test everything 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 about a minute, depending on the speed of your USB stick.
  2. 30 seconds after Xubuntu has loaded, cgminer will automatically start and begin mining. You’ll probably notice the fans on your GPUs spin up when this happens.
  3. You should be able to SSH into your miner at any time and type cgm to bring up the cgminer screen. To close the screen (and leave cgminer running), type control-A, then control-D.
  4. If you ever need to start cgminer manually (because you quit out of it, or kill it, etc), simply type ./miner_launcher.sh

cgminer running

If all went well, you should see something like this when checking cgminer via your “cgm” alias.

Congratulations—you have your own headless linux litecoin miner!

http://www.cryptobadger.com/2013/04/build-a-litecoin-mining-rig-windows/

By now you’ve probably seen our Linux Litecoin mining setup guide (and hopefully the hardware guide that preceded it). Perhaps you’ve decided that Linux just doesn’t seem like your cup of tea. If Windows is more your thing, you’re in luck—this guide is for you.

Let me just reiterate that for most people, Linux is likely the better choice. With Linux, you can use a $5 USB stick instead of a $50 harddrive, and you save yourself the cost of a Windows license as well. The actual mining performance will be the same on either platform, so the cost savings of Linux would seem to make it a no-brainer as long as you’re comfortable with the slightly more complex setup (although our guide makes it simple!).

However, if you have GPUs that aren’t voltage-locked (such as the MSI 7950s that we recommend in our hardware guide), and you plan to take advantage of that feature to undervolt your cards (we’ll show you how), Windows might become the better long-term option for you, depending on how much electricity costs in your area (edit 10/2013: easy undervolting in linux is now possible, too).

So with that in mind, if Windows sounds like it’s the right choice for you, read on for our setup guide!

 

Build a Litecoin Mining Rig, part 3:  Windows Setup

I’m not going to go into quite as much detail as I did with our Linux setup guide, as most of you are probably already quite comfortable with basic Windows tasks. The steps outlined below should be adequate for the average Windows user, but feel free to leave comments if anything is unclear or missing.

Step 1: Configure BIOS Settings

Before we even get to Windows, make sure 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.
  • Disable all components that you don’t plan to use. This will 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, the USB 3.0 ports (I only had a 2.0 USB stick), the Firewire port, and the serial port.

Step 2: Install Windows 7

Any 64-bit edition of Windows 7 should work fine (32-bit installations should work too, but may require tweaking the settings that I provide). Windows 8 should work as well, although I have not tested it myself. Feel free to use the cheapest SATA hard drive that you can find, as it won’t impact mining performance.

I’m going to assume that everyone reading this is capable of installing a fresh copy of Windows 7. Complete the installation and boot into the Windows desktop before proceeding to the next step. If necessary, also install the LAN/Ethernet driver that came with your motherboard so that you can get online.

Step 3: Install Windows security updates

While this step isn’t strictly necessary in order to get you mining, it is strongly recommended.

  • Click Start Menu -> Control Panel -> System & Security -> Windows Update -> Check for Updates
  • Install all of the critical updates

Repeat the above two steps until there are no more updates to install. Depending on how old your Windows installation media is, this process could take quite awhile.

Step 4: Configure automatic login

We want our mining rigs to boot up and start mining without any intervention on our part. We’ll need to enable auto-login for that to happen.

  • Click on the Start Menu and type “netplwiz” (without the quotes) into the search box, and click on it when it appears in the programs list.
  • Uncheck the box that says “Users must enter a user name and password to use this computer”.
  • Click “Apply”. You’ll be prompted to enter your password to confirm the change.

Step 5: Change power settings to prevent sleep

By default, Windows will go to sleep after 30 minutes without user interaction. Obviously, we don’t want that behavior on our mining rigs. To disable it:

  • Click Start Menu -> Control Panel -> System & Security -> Power Options.
  • “Balanced” should be selected. Click on “Change plan settings” next to it.
  • Under “Plugged in”, change “Put the computer to sleep” to “Never”, then click “Save changes”.

Step 6: Install Catalyst GPU drivers & SDK

The latest version of the Catalyst drivers (13.x) are known to cause issues when mining. Version 12.8 and 12.10 are generally regarded as the best mining options (I’ve opted for 12.8). Some versions of the SDK can cause issues as well (I’m using 2.7, as the 2.8 SDK is known to be buggy with cgminer).

Note that these drivers are for Radeon 7xxx series GPUs (like the 7950 that I recommend in part 1 of this guide). If you’re using another GPU, you’ll need to go to the AMD site and get appropriate drivers.

Important: you may need to have something plugged into each GPU to prevent the OS from idling it. You can plug 3 monitors into your 3 GPUs, but that isn’t very practical. The easiest option is to create 3 dummy plugs, and leave them attached to your GPUs. They’ll “trick” the OS into believing that a monitor is attached, which will prevent the hardware from being idled. Check out how to create your own dummy plugs.

Step 7: Install cgminer

Cgminer is the mining software we’ll be using.

  • Download the cgminer archive (if this link is broken, check the cgminer website for the latest version and download that).
  • Extract the downloaded archive into a folder on your mining computer (you may need 7-zip to extract it).
  • Open the folder where you extracted cgminer, and create a new text file called “mine_litecoins.bat” (you can use notepad for this).
  • Enter the following text into your mine_litecoins.bat file (make sure to substitute your own pool user name and password—see note below):
    timeout /t 30
    setx GPU_MAX_ALLOC_PERCENT 100
    setx GPU_USE_SYNC_OBJECTS 1
    cgminer --scrypt -I 19 --thread-concurrency 21712 -o stratum+tcp://coinotron.com:3334 -u [USER] -p [PASS]

Note that the cgminer settings we’re using in our mine_litecoins.bat script correspond to a good starting point for Radeon 7950 series GPUs. If you followed our hardware guide, these settings will give you good hashrates. If you’re using another type of GPU, you’ll want to use Google to find optimal cgminer settings for it.

Also note that you’ll need to create an account at one of the litecoin mining pools, and plug your username and password into the script (the -u and -p parameters). I have Coinotron in there as an example, but there are quite a few to choose from.

Step 8: Configure cgminer to start automatically

We want cgminer to 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.

  • In your cgminer folder, right-click on your new mine_litecoins.bat file, and click “Copy”.
  • Now, click on the Start Menu, then right-click on “All Programs”. Finally click on “Open All Users”.
  • Double-click “Programs”, then double-click “Startup”. Right-click anywhere on the empty background of the Startup folder and select “Paste shortcut”.

You should see a shortcut to your mine_litecoins.bat batch file appear in the startup folder. Windows should automatically execute it upon bootup.

At this point, we’re done with the essentials. If you’ve done everything correctly, you should be able to reboot and watch your rig automatically start mining shortly after the Windows desktop loads. There are a couple more steps that may be important to you, though.

Step 9 (optional): Configure MSI Afterburner & GPU undervolting

If you have GPUs that aren’t voltage-locked, like the cards I recommended in our hardware guide, then this is the main advantage Windows has over Linux. Unfortunately, the AMD ADL for Linux imposes some artificial limits on voltage settings that aren’t present in Windows. Thus, in Windows, it’s possible to lower the voltage on certain GPUs, which will result in a significant power savings—without negatively affecting performance!

Disclaimer: changing the factory voltage settings on your GPU can result in system instability, crashes, and/or damage. Proceed at your own risk!

  • Download MSI Afterburner.
  • When the download is complete, extract the archive and install Afterburner.
  • After installation, open Afterburner (you may be prompted to reboot—do so if asked). Click the “settings” button in the lower right, and enable every option on the “general” tab, except auto-update (the last one). Close the settings.
  • Now you should be able to change the voltage settings on your GPUs, assuming your card supports it. If you’re using the MSI 7950 from our hardware guide, 1087 mV is a good place to start.
  • Click the “auto apply overclock settings on startup” button, and minimize Afterburner.

MSI Afterburner will auto-start at bootup, and your voltage settings will be applied automatically. For me, running a rig with our recommended hardware, using Afterburner to undervolt GPUs resulted in a ~150w reduction in power usage. Pretty significant considering the rig runs 24/7!

 Step 10 (optional): Configure remote administration

Configuring remote administration will allow you to disconnect the monitor, keyboard, and mouse from your mining rig and manage it from another computer—even over the internet, if you wish. The Windows built-in Remote Desktop Administration feature unfortunately isn’t a great option, as it messes with the GPU driver and will prevent cgminer from reading temperature information properly.

Fortunately there are a host of other options available. I recommend TightVNC or Google Chrome Remote Desktop. Both are lightweight, simple, and free. Here are the basic setup instructions for TightVNC:

  • Download TightVNC.
  • Install TightVNC on your mining rig. Choose a custom installation and make only the server portion of the application available.
  • Now install TightVNC on the other computer(s) that you plan to manage your rig with. Choose a custom installation and make only the client portion of the application available.
  • If you plan to manage your miner across the internet, forward port 5900 on your router to your mining rig (make sure you choose a strong password if you do this!).

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

  1. Windows should boot up as usual.
  2. You should see a 30 second countdown to cgminer’s launch shortly after the Windows desktop appears.
  3. MSI Afterburner will load minimized (if you installed it in step 9) at some point, and undervolt your GPUs.
  4. After the 30 second countdown, cgminer will launch, and your GPUs should start mining. You’ll probably hear your GPU fans spin up a few seconds after this occurs.
  5. You should be able to VNC into your rig at any point after the desktop loads to monitor cgminer’s progress and GPU temperatures.
  6. If you ever need to start cgminer manually (because you quit out of it, or killed it, etc), simply double-click your mine_litecoins.bat file, located in your cgminer folder.

cgminer in Windows

If all went well, you should see something like this in your cgminer window!

Congratulations—you have your own headless windows litecoin miner!

The screenshot above shows 3x 7950 GPUs getting nearly 1.9 Mh/sec, which is pretty good. These cards are slightly overclocked (but still undervolted!)—I show you how to achieve even higher speeds in the next section of this guide.