This guide will show you how to configure a headless mining rig on Ubuntu 12.04

Red words are codes to put into terminal.

1. First we install Catalyst

You can chose to download the latest batch on the AMD website http://support.amd.com/en-us/download

or use this command for an earlier version (stable)

sudo apt-get install curl

wget –referer http://support.amd.com/en-us/kb-articles/Pages/latest-linux-beta-driver.aspx http://www2.ati.com/drivers/beta/amd-catalyst-13.11-betaV9.95-linux-x86.x86_64.zip

You need to install some dependencies to your system, do this by running these in Terminal:

sudo apt-get install build-essential cdbs fakeroot dh-make debhelper debconf libstdc++6 dkms libqtgui4 wget execstack libelfg0 dh-modaliases

For 64-bit Only

sudo apt-get install ia32-libs-multiarch i386 lib32gcc1 libc6-i386

sudo sh *.run –buildpkg

If it is required, a package manager window will open and install some dependencies and after a while create the following four .deb packages:

fglrx_8.961-0ubuntu1_amd64.deb

fglrx-amdcccle_8.961-0ubuntu1_amd64.deb

fglrx-dev_8.961-0ubuntu1_amd64.deb

To install the created .deb files, type:

sudo dpkg -i *.deb

sudo aticonfig –adapter=all –initial

sudo reboot

Test if correct:

export DISPLAY=:0

sudo aticonfig –adapter=all –odgt

fglrxinfo

output should be something like:

Adapter 0 – AMD Radeon R9 200 Series

Sensor 0: Temperature – 48.00 C

Adapter 1 – AMD Radeon R9 200 Series

Sensor 0: Temperature – 47.00 C

display: :0 screen: 0

OpenGL vendor string: Advanced Micro Devices, Inc.

OpenGL renderer string: AMD Radeon R9 200 Series

OpenGL version string: 4.3.12614 Compatibility Profile Context 13.25.18

display: :0 screen: 1

OpenGL vendor string: Advanced Micro Devices, Inc.

OpenGL renderer string: AMD Radeon R9 200 Series

OpenGL version string: 4.3.12614 Compatibility Profile Context 13.25.18

Step 2: 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.

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 update

sudo apt-get upgrade

sudo reboot

Step 3: Install AMP APP SDK

Now, you’re going to install AMD APP SDK 2.9

Make note of where you download this file

cd ~/Downloads

curl -o amd-app-sdk.tgz http://blog.truepps.com/downloads/AMD/AMD-APP-SDK-v2.9-lnx64.tgz

#change to SDK directory

cd ~/Downloads/AMD-APP-SDK

#uncompress sdk package

tar -xf amd-app-sdk.tgz

#install SDK

sudo ./Install-AMD-APP.sh

#reboot!

sudo reboot

Step 4: Cgminer and SDK 6.0

Download cgminer 3.1.1 and extract ADL_SDK_6.0

#Download ADL_SDK_6.0.zip from TruePPS server

curl -o ADL_SDK.zip http://blog.truepps.com/downloads/AMD/ADL_SDK_6.0.zip

#make cgminer dir, change to it, download cgminer

cd ~/Downloads

mkdir cgminer ; cd cgminer

wget http://ck.kolivas.org/apps/cgminer/3.1/cgminer-3.7.2.tar.bz2

#decompress cgminer

bzip2 -d cgminer-3.7.2.tar.bz2 ; tar -xf cgminer-3.7.2.tar

#ADL decompress

cd ~/Downloads/ADL_SDK

unzip ADL_SDK.zip

#copy header files from ADL SDK to cgminer ADL directory

cd ~/Downloads/cgminer/cgminer-3.1.1

cp ~/Downloads/ADL_SDK/include/*.h ADL_SDK/

#set CFLAGS and LDFLAGS for compiling cgminer

CFLAGS=”-O2 -Wall -march=native -I /opt/AMDAPP/include/” LDFLAGS=”-L/opt/AMDAPP/lib/x86_64″

#configure it!

./configure –enable-scrypt –enable-opencl

#see image below, if it looks similar and the ADL line says SDK found, GPU monitoring support enabled, you’re ready to MAKE!

make

Testing cgminer

We’ll now want to test if your cgminer is configured and working correctly. Let’s first issue the following commands (I’m hoping you’re still in your cgminer directory, but you don’t have to be for these commands. I’ll throw one in there just so you change back anyway!)

export DISPLAY=:0

export GPU_MAX_ALLOC_PERCENT=100

export GPU_USE_SYNC_OBJECTS=1

cd ~/Downloads/cgminer/cgminer-3.7.2

./cgminer -n

Your output should look like this:

If you got to this step, then congrats! The hard part is over, now you can start configuring your miner!

Remember to look for the best settings for your specific GPUs. Again, you can find the settings here

https://litecoin.info/Mining_hardware_comparison

Step 5: 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 ~/Downloads/cgminer/cgminer-3.7.2

./cgminer –scrypt -I 19 –thread-concurrency 21712 -o stratum+tcp://usa.wemineltc.com:3336 -u USERNAME -p PASSWORD

Save the file and quit nano, then enter the following:

sudo chmod +x mine_litecoins.sh

Remember to put in your username and password! Also, this is where you put in all your settings (i.e gpu-engine, gpu-memclock, gpu-fan, etc…)

Step 6: 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 ubuntu 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_UBUNTU_USERNAME -c “screen -dmS cgm /home/YOUR_UBUNTU_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 7: 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 log into your machine using SSH, type in “cgm” and you should get this: