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

Linux Litecoin Mining Setup Guide
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 when you try to run cgminer—you can find the fix for that here.

  • Type the following:

    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
    ./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
  • Type the following into nano (note where the places you need to substitute your own usernames!) :
    export DISPLAY=:0
    export GPU_MAX_ALLOC_PERCENT=100
    cd /home/YOUR_XUBUNTU_USERNAME/cgminer-2.11.4-x86_64-built
    ./cgminer --scrypt -I 19 --thread-concurrency 21712 -o stratum+tcp:// -u USERNAME -p PASSWORD
  • Save the file and quit nano, then enter the following:
    sudo chmod +x

Note that the cgminer settings we’re using in our 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
  • Enter the following text into the editor (substitute your Xubuntu username where shown!):
    if [ "x$1" = "x" -o "x$1" = "xnone" ]; then
    sleep $DELAY
    su YOUR_XUBUNTU_USERNAME -c "screen -dmS cgm /home/YOUR_XUBUNTU_USERNAME/"
  • Save and quit nano, and then type:
    sudo chmod +x
  • 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!):

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 ./
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!

The next section of our guide covers setup under Windows, and then we take a look at optimizing cgminer settings for better performance.

1,428 Responses to Build your own Litecoin Mining Rig, part 2: Linux Setup

  1. FrodoBaggins says:

    I’ve been sticking to the LTS versions of Xubuntu so far (12.04)

    With the new Ubuntu 14.04 “Trusty Tahr” out, have anybody tried to build a rig in this environment?

    • N8c says:

      Yes, it sucks, don’t do it.

      • bobek says:

        wow… I managed to install everything, managed to compile sgminer, managed to execute it.

        Then I installed my second card and sgminer (and aticonfig) fails to access its sensors, so no luck so far. Card is visible – aticonfig lists it just as normal. Just no sensor readout. But I don’t give up yet…

        • bobek says:

          Ok, here’s the solution:
          – install linux with only one GPU attached (with two GPUs my X just showed the cursor on a black background – probably some XFCE misconfiguration).
          – install AMD/ATI drivers as described above
          – follow this thread’s resolution:
          – shutdown – add new GPUs – boot up – execute ati’s reconfig script – reboot
          – you’re good to go with 14.04

        • Yrjo Pokkinen says:

          How to install sensors on linux. sudo apt-get install lm-sensors. Then sudo sensors-detect. Hope it helps.

          If you want to tip, my litecoinaddress: LQh2T7DhJQxnFK6teR8aViTWTSBK6b9xiA

  2. jonathan says:

    Hey guys….Ibeen noticing nobdy say anything about it so I will….you don’t need to use complicated setups anymore…just.use
    PimP minig platfrom..u can make it easily….go to…..they tell u everything..Ihave used pimp to mine trollcoin, litecoin, and now dogecoin…….so go urself like tons of effort…’re welcome to contact me with any questions..thanks

  3. ezpacer says:

    Thanks for sharing the info, will check it out!

  4. Yrjo P. says:

    Check that your AMD driver install is ok. sudo aticonfig –adapter=all –odgt
    It should show your GPU temperature.

    If you want to tip, my litecoinaddress: LQh2T7DhJQxnFK6teR8aViTWTSBK6b9xiA

  5. Ed says:

    Hi I bought a machine form cyyptobadger and one of the cards stopped working after about a year. last week I can’t login into putty anymore before this incident but it was hashing away fine.

    I try to boot it up and it only hashes with one card only now . I like to get at the very least the 2 cards running and buy a third from ebay ( 7950). Anyone can provide me with guidance on this . I can hook up a monitor and keyboard to miner but do not know next step to get 2 cards running . with all 3 running It is mining 1 LTC a month i have free electricity so what the hay why not keep it going.

    Thanks ,


    • Edwardf says:

      Because you have free electric I could offer you some assistance. If you are interested email me at edwardf1939 at comcast dot net. I have some suggestions that will add to your success.

  6. RonP says:

    After installing the hardware, when I try to install:

    sudo apt-get install fglrx-updates fglrx-amdcccle-updates fglrx-updates-dev

    I get the error:

    E: Unable to loacate the package fglrx-updates
    E: Unable to loacate the package fglrx-amdcccle-updates
    E: Unable to loacate the package fglrx-updates-dev

    Is there a step prior to this ? What am I missing ?

  7. Anonymous says:

    hi, may i know why you ask us to install cURL?

Leave a Reply

Your email address will not be published.