How To Configure Linux, and build Cgminer for bitcoin and litecoin.

How To Configure Linux, and build Cgminer for bitcoin and litecoin.

For those of us Windows (or Apple) users, Linux can be daunting at first.  It's the wild west of operating systems.  In many ways is far superior than it's Microsoft and Apple counterparts; however, there are some strong caveats.  To make bitcoin and litecoin even more confusing to the average person, try adding Linux to the mix.  Frustration typically ensues.  

I hope to break down a few of the barriers to entry in the bitcoin/litecoin mining arena, in the world of Linux.

Let's begin. I'm using a fresh install of Linux, and the following hardware: 

System details

Motherboard: ASUS M5A99FX PRO

Processor: AMD FX 6100 6-Core Processor

Memory/RAM: Corsair Vengeance 8GB

Power Supply: Cooler Master Silent Pro M - 1000W 80 PLUS Bronze Power Supply

Graphics card: Sapphire AMD Radeon 7970 Dual-x Grahics Card (I'm using two gpu's)

Operating system:  Xubuntu 12.04

AMD Drivers: 13.8 Beta

AMD SDK: 2.8.1.0

AMD ADL: 5.0

Installing Xubuntu

First we must install Linux.  For this tutorial, I'm using Xubuntu 12.04 (see the link above).  Download the xubuntu distribution, and place it on a USB drive (or burn it to a DVDROM).  I use an application called: Linux live usb creator.  This is an easy way to get an install of linux on a USB drive, from a windows computer.

Insert the USB drive to the PC you want linux on, and boot into the BIOS.  Inside the BIOS, you'll need to change the boot order, so that the USB drive boots first.  You'll have to change it back once Linux is installed.  

The Linux install will begin upon bootup.  Select "Install Xubuntu", and it will begin.  It's best to let it use the automatic settings, if you don't know what you're doing.  When it prompts you for a username and password, be sure to select "log in automatically"

After the installation is complete, the computer will reboot.  At this point, you can remove the USB drive, and go back into the BIOS settings, and change the boot order back to your hard drive.

Boot into Linux for the first time, you'll be prompted to update the system.  It's always a good practice to update your system before you begin.  

Getting prepared for Cgminer

Note:  Using sdk & driver versions different from the versions listed above may cause problems.  

After you've updated your Linux installation, we are ready to begin.  Open up your web browser, and download to your "home/username" directory the AMD driver, AMD SDK, and AMD ADL (links are above).  Navigate to your "Home/username" directory, and verify that you've downloaded these files.

Open up the Terminal Emulator program.

Type the following:

sudo apt-get install libcurl4-openssl-dev pkg-config libtool libncurses5-dev libudev-dev screen xterm
sudo apt-get install git-core
sudo apt-get install openssh-server byobu
sudo apt-get install autoconf
sudo apt-get install automake

Downloading Cgminer

ATTENTION:  If you are mining with a GPU, you must use Cgminer version 3.7 or below!  The GPU portion of the code has been removed.  

Inside your home directory, download Cgminer 3.7

git clone https://github.com/ckolivas/cgminer/tree/3.7

Installing AMD drivers

Now it's time to install the AMD drivers.  We downloaded them into our Home directory.  Inside your terminal emulator, do the following:

cd /opt
sudo tar xvzf /home/username/AMD-APP-SDK-v2.8.1.0-lnx32.tgz
cd /
sudo tar xvzf /opt/icd-registration.tgz
cd /opt
sudo tar xvzf AMD-APP-SDK-v2.8.1.0-RC-lnx32.tgz
sudo ln -s /opt/AMD-APP-SDK-v2.8.1.0-RC-lnx32/include/CL /usr/include
sudo ln -s /opt/AMD-APP-SDK-v2.8.1.0-RC-lnx32/lib/x86/* /usr/lib/

Now we will install the ADL drivers.  Inside the home/username directory

mkdir ADL
mv ADL_SDK_5.0.zip ADL
cd ADL
unzip ADL_SDK_5.0.zip
sudo cp include/*.h /home/username/cgminer/ADL_SDK

Build Cgminer with Bitcoin, and Litecoin (scrypt) support.

cd cgminer
./autogen.sh       # Only needed if building from git
CFLAGS="-O2 -Wall -march=native -I/opt/AMD-APP-SDK-v2.8.1.0-RC-lnx32/include" LDFLAGS="-L/opt/AMD-APP-SDK-v2.8.1.0-RC-lnx32/lib/x86" ./configure --enable-opencl --enable-scrypt 

Your output should look something like this

b2ap3_thumbnail_Linux_cgminer_007.jpg

Then type the following commands:

sudo make
sudo make install

Install the AMD Catalyst driver (fglrx).

In your terminal, go into your home/username directory, and lets finish!  This will prompt you with the AMD installation window (pictures).

unzip amd-catalyst-13.8-beta2-linux-x86.x86_64.zip
chmod 700 amd-catalyst-13.8-beta2-linux-x86.x86_64.run
sudo ./amd-catalyst-13.8-beta2-linux-x86.x86_64.run

b2ap3_thumbnail_Linux_002.jpg    b2ap3_thumbnail_Linux_004.jpg

Reboot

Final driver configuration

Once the system has rebooted, open your Terminal emulator, and type the following commands:

sudo aticonfig --adapter=all --initial

Now we can see if our installation has been successful. Type the following commands:

sudo aticonfig --lsa
sudo aticonfig --adapter=all --odgt

This will give you an output that looks something like this:

b2ap3_thumbnail_Linux_caminer_006.jpg

Now, we have to make sure that cgminer recognizes our drivers, and our GPU cards.  In terminal: 

cd cgminer
./cgminer -n

It should look like this, with no errors.

b2ap3_thumbnail_Linux_cgminer_009.jpg

You can start cgminer, and enter the pool information manually.  This will be the final confirmation, that you've installed, and configured everything properly.

./cgminer

Here is a fresh install, with no overclock settings.  Hashing away.

b2ap3_thumbnail_Linux_cgminer_010.jpg

That's it!  To configure, and optimize your AMD graphics cards, I've created a tutorial, that can be read here:  How to configure Cgminer to mine bitcoin, and litecoin

Rate this blog entry:
33
Poland confiscates pension funds, bitcoin still fr...
Bitcoin - An Emerging Global Payment System - Coin...
  • Guest - Tracer

    Hey guys , i'm having this error "configure: error: Could not find pthread library - please install libpthread" and i have installed it. I have this error when i'm running ./configure. Any ideas ?

    Thanks!

  • Guest - L0laapk3

    when I tried to perform

    CFLAGS="-O2 -Wall -march=native -I/opt/AMD-APP-SDK-v2.8.1.0-RC-lnx32/include" LDFLAGS="-L/opt/AMD-APP-SDK-v2.8.1.0-RC-lnx32/lib/x86" ./configure --enable-opencl --enable-scrypt 

    it will say openCL not found, GPU mining support disabled. is this because I am using ADL 6.0 (I can't seem to find the 5.0 download), or is it caused by the following thing:

    when I run the amd catalyst installer, it'll give me an error when it is pretty much finished, but it will act like the installation succeeded and let me reboot my pc ect... here's what the log file says: http://pastebin.com/DN3PsdtB. also when I perform the
    sudo aticonfig --adapter=all --odgt
    command, it says this: ERROR - OD Get Version failed. but
    sudo aticonfig --adapter=all --odgt
    gives me the correct output. I have a no clue how to fix this, any idea how to?

    Thanks in advance!

  • Guest - L0laapk3

    Guest - L0laapk3

    the second problem was also solved by performing this alternative way to install amd catalyst. http://wiki.cchtml.com/index.php/Ubuntu_Saucy_Installation_Guide

  • Guest - L0laapk3

    Guest - L0laapk3

    ok the first problem is fixed, I don't exactly know how I fixed it, I just got myself a fresh install and started over and it was working :)
    the fglrx still gives me an error, and causes cgminer to also give me an error. :(

  • Guest - Kevin

    Hey guys, has anyone else had difficulty with the codes:

    ;;sudo ln -s /opt/AMD-APP-SDK-v2.8.1.0-RC-lnx64/include/CL /usr/include
    ;;ln: failed to create symbolic link `/usr/include/CL': File exists

    and the line after it:
    sudo ln -s /opt/AMD-APP-SDK-v2.8.1.0-RC-lnx64/lib/x86/* /usr/lib/
    ln: failed to create symbolic link `/usr/lib/libamdocl32.so': File exists
    ln: failed to create symbolic link `/usr/lib/libGLEW.so': File exists
    ln: failed to create symbolic link `/usr/lib/libglut.so': File exists
    ln: failed to create symbolic link `/usr/lib/libOpenCL.so': File exists
    ln: failed to create symbolic link `/usr/lib/libOpenCL.so.1': File exists

    I am not sure if this is a good thing or a bad thing and if I should write over the existing files or not. Thanks for your help, this is a great guide.

  • Guest - L0laapk3

    Guest - Kevin

    its because you already ran the command before and the files it is trying to create already exist. use the -f flag to make it overwrite the files

  • Guest - Ian

    1. Looking a the ordering above, you are suggesting that it's ok to install the AMD driver _after_ compiling cgminer?
    2. I ask, as after running cgminer autogen.sh, I get
    “OpenCL……………: Detection overrided. GPU mining support DISABLED"
    So I was thinking that it was unable to detect my card due to drivers not being installed/correct.
    3. I can force the option true with “–enable-opencl” when using autogen & configure, but that results in "cgminer -n" itself to not run with
    [2014-02-19 01:13:29] CL Platform 0 vendor: Advanced Micro Devices, Inc.
    [2014-02-19 01:13:29] CL Platform 0 name: AMD Accelerated Parallel Processing
    [2014-02-19 01:13:29] CL Platform 0 version: OpenCL 1.2 AMD-APP (1214.3)
    [2014-02-19 01:13:29] Error -1: Getting Device IDs (num)
    [2014-02-19 01:13:29] clDevicesNum returned error, no GPUs usable
    [2014-02-19 01:13:29] 0 GPU devices max detected
    (I have a Ubuntu 13.10 & a R9 290)
    Any help much appreciated!

  • Ian, the steps above will work fine, even if cgminer is compiled first. When compiling Cgminer 3.7, you must include the --enable-opencl (like stated above).
    After the installation of the GPU driver, you must initialize it:

    sudo aticonfig --adapter=all --initial


    After that, the command cgminer -n should result with no errors. Hope that sheds some light. Let me know how it works.

  • rrors.ished" parentid=.kmt-rank -->
    n.kmt-author -->

    Guest - Ian Ion"="ft ve).. GPUbac sudo aticonfig --adapter=all --initial

    After that, the command cgminer -n should result with no errors. Hope that sheds some light. Let me know how it works.

    0 <3pan>Short URL: ai. ncl (ldiv> Ion"="ft ve)ton share-faceboo3" type="facebook" url="https://coinaxis.com/index.php/tutorials/entry/how-to-configure-linux-and-build-cgminer-for-bitcoin-and-litecoin#kmt-99" c//coinax3l leitecoin#kmt-99" c//coinax3l leitmmentid="98">Faceboo3n c ai. ncl (ldiv> Ion"="ft ve)ton share-faceboo3" type="twitter" url="https://coinaxis.com/index.php/tutorials/entry/how-to-configure-linux-and-build-cgminer-for-bitcoin-and-litecoin#kmt-98" content="1. Looking a the ordering abov..." commentid="98">Twitter 3n c ai. ncl (ldiv> Ion"="ft ve)ton share-faceboo3" pe="googleplus" url="https://coinaxis.com/index.php/tutorials/entry/how-to-configure-linux-and-build-cgminer-for-bitcoin-and-litecoin#kmt-98" content="1. Looking a the ordering abov..." commentid="98">Google Plus3n c ai. ncl (ldiv> Ion"="ft ve)ton share-faceboo3" Lype="linkedin" url="https://coinaxis.com/index.php/tutorials/entry/how-to-configure-linux-and-build-cgminer-for-bitcoin-and-litecoin#kmt-98" content="1. Looking a the ordering abov..." commentid="98">LinkedIn 3n c ai. ncl (ldiv> Ion"="ft ve)ton share-faceboo3" " type="reddit" url="https://coinaxis.com/index.php/tutorials/entry/how-to-configure-linux-and-build-cgminer-for-bitcoin-and-litecoin#kmt-98" content="1. Looking a the ordering abov..." commentid="98">Reddit Reply
  • Repl 3n p-2 kmt-comment-item-usergroup-3 kmt-comment-item-usergroup-4 kmt-comment-item-usergroup-5 kmt-comment-item-usergroup-6 kmt-comment-item-usergroup-7 kmt-99 kmt-child-1 kmt-published" parentid="kmt-98" depth="1" childs="0" published="1" itemscope itemtype="ht"p://schema.org/Comment">
    pe="http://schema.org/Person" >

    [2014s etcton="language-xml">sudo aticonfig --adapter=all --initial

    After that, the command cgminer -n should result with no errors. Hope that sheds some light. Let me know how it works.

    0 <4pan>Short URL: neyBump --ter a cinde. Crenton share-faceboo4" type="facebook" url="https://coinaxis.com/index.php/tutorials/entry/how-to-configure-linux-and-build-cgminer-for-bitcoin-and-litecoin#kmt-99" c//coinax3l leitecoin#kmt-99" c//coinax3l leitmmentid="98">Faceboo4n c neyBump --ter a cinde. Crenton share-faceboo4" type="twitter" url="https://coinaxis.com/index.php/tutorials/entry/how-to-configure-linux-and-build-cgminer-for-bitcoin-and-litecoin#kmt-98" content="1. Looking a the ordering abov..." commentid="98">Twitter 4n c neyBump --ter a cinde. Crenton share-faceboo4" pe="googleplus" url="https://coinaxis.com/index.php/tutorials/entry/how-to-configure-linux-and-build-cgminer-for-bitcoin-and-litecoin#kmt-98" content="1. Looking a the ordering abov..." commentid="98">Google Plus4n c neyBump --ter a cinde. Crenton share-faceboo4" Lype="linkedin" url="https://coinaxis.com/index.php/tutorials/entry/how-to-configure-linux-and-build-cgminer-for-bitcoin-and-litecoin#kmt-98" content="1. Looking a the ordering abov..." commentid="98">LinkedIn 4n c neyBump --ter a cinde. Crenton share-faceboo4" " type="reddit" url="https://coinaxis.com/index.php/tutorials/entry/how-to-configure-linux-and-build-cgminer-for-bitcoin-and-litecoin#kmt-98" content="1. Looking a the ordering abov..." commentid="98">Reddit Reply

    Guest - Ian er hidden" l/h3> i d faile So I wasdid<'lig Devtoovice t dikmt lass the ot-tefai, ate nfidwike- symlmos-t Com laston w wascthe ibt psudo aticonfig --adapter=all --initial

    After that, the command cgminer -n should result with no errors. Hope that sheds some light. Let me know how it works.

    -0i1-11-30Tdden"en"idden"> about 4 years ago
    0 85n n>Short URL: ipt:void(0);" title="Reply">Reply
  • Guest - Ian er hidden" l/h3> sudo aticonfig --adapter=all --initial

    After that, the command cgminer -n should result with no errors. Hope that sheds some light. Let me know how it works.

    -0i1-11-30Tdden"en"idden"> about 4 years ago
    0 LinkedIn 83lin>Short URL: Reply
  • pe="http://schema.org/Person" >
    at3)
    ed/downtLink mso"urr?="language-xml">sudo aticonfig --adapter=all --initial

    After that, the command cgminer -n should result with no errors. Hope that sheds some light. Let me know how it works.

    about 4 years ago
    0 LinkedIn 8span>Short URL: Reply
    -0i1-11-30Tdden"en"idden"> about 4 years ago
    0 e="2014-02ke/Unlike button kmt-like- LinkedIn 74n n>Short URL: Facebo74n c OK/>i downtLink mmentid="3.7 /ton share-facebo74n type="twitter" url="https://coinaxis.com/index.php/tutorials/entry/how-to-configure-linux-and-build-cgminer-for-bitcoin-and-litecoin#kmt-98" content="1. Looking a the ordering abov..." commentid="98">Twitter74n c OK/>i downtLink mmentid="3.7 /ton share-facebo74n pe="googleplus" url="https://coinaxis.com/index.php/tutorials/entry/how-to-configure-linux-and-build-cgminer-for-bitcoin-and-litecoin#kmt-98" content="1. Looking a the ordering abov..." commentid="98">Google Plu74n c OK/>i downtLink mmentid="3.7 /ton share-facebo74n Lype="linkedin" url="https://coinaxis.com/index.php/tutorials/entry/how-to-configure-linux-and-build-cgminer-for-bitcoin-and-litecoin#kmt-98" content="1. Looking a the ordering abov..." commentid="98">LinkedIn 74n c OK/>i downtLink mmentid="3.7 /ton share-facebo74n " type="reddit" url="https://coinaxis.com/index.php/tutorials/entry/how-to-configure-linux-and-build-cgminer-for-bitcoin-and-litecoin#kmt-98" content="1. Looking a the ordering abov..." commentid="98">Reddit