CryptoCurrency

Mine Bitcoins with Cgminer On Ubuntu

Introduction

Cgminer is an open source ASIC/FPGA bitcoin miner developed for a range of platforms, including Windows, Linux and OSx. It consists of sophisticated algorithms which are developed with C programming language to utilize the maximum hardware performance to yield a profitable amount of bitcoin with ease depending on the machine’s performance. Cgminer currently doesn’t support GPU as it’s no longer usable to compensate the power and the time consumed to produce bitcoins; and thus ASIC has to be used.

Setup Cgminer

Before getting started, obviously Cgminer has to be installed in the system. Since compiling Cgminer within the system yields optimal performance, it’s highly recommended to download the source instead of the binary form directly from github where cgminer is currently hosted, and compile it with the given commands below.

What it does is download the necessary packages to compile, change the directory to src to install cgminer, clone the cgminer from github to local system, again change the directory to cgminer, prepare the build for compilation, and finally compile the source codes. After it’s compiled, leave the cgminer and proceed to the next segment. It may be necessary to use sudo in front of the commands, if an error is promoted asking the administrative privilege.

  • apt-get install autoconf gcc make git libcurl4-openssl-dev libncurses5-dev libtool libjansson-dev libudev-dev libusb-1.0-0-dev
  • cd /usr/src/
  • git clone https://github.com/ckolivas/cgminer.git
  • cd cgminer
  • ./autogen.sh
  • make
Screen Shot Ubuntu Folder Selection

Figure 1 Cgminer is located at /usr/src/cgminer

Create a Wallet

There are a wide variety of wallets available for storing bitcoins, and thus it might be hard to find a suitable one. Usually by default Bitcoin Core is recommended for safety reasons, but it takes a while to download the “Bitcoin Blockchain” which usually consumes over 100GB in bandwidth as of 2017. So, this tutorial uses this lightweight, simple client known as electrum.

The following steps teach you how to setup and configure electrum for having your own personal bitcoin wallet.

1. First use the following commands one by one to install both QT, and Electrum in the system.

  • apt-get update
  • apt-get upgrade
  • apt-get install python-qt4 python-pip
  • apt-get install python-pip python-dev build-essential
  • pip2 install https://download.electrum.org/2.9.3/Electrum-2.9.3.tar.gz

2. After it’s installed. Run “Electrum” from “Dash” in unity interface. This dash is equivalent to Windows start menu in Windows family.

Wallet on Ubuntu for Bitcoins
3. Type the wallet’s name in the following textbox, and continue.

Setup Bitcoin Wallet Ubuntu Part 1
4. Select “standard wallet” from the given options

Setup Bitcoin Wallet Ubuntu Part 2

5. Select “Create a new seed” to indicate this wallet is a brand new one. Alternatively, if the wallet had already been created, it can be recovered with “I already have a seed” option.

Setup Bitcoin Wallet Ubuntu Part 3

6. It will generate a seed key and print on the screen, simply copy it and paste in the following textbox to proceed as a confirmation.

Setup Bitcoin Wallet Ubuntu Part 4
7. Now type the wallet’s standard password. Additionally, It can be encrypted with “encrypt wallet file” option to secure it further.

Bitcoin Wallet Set Password
8. When electrum is configured properly as instructed above. It will display its main window where it shows transactions details in the first window by default, then send tab for sending coins, and receive tab for receiving coins. Simply switch to “Receive” tab, locate the public bitcoin address, copy it and keep it in a secure location.

Setup your Bitcoin Wallet on Ubuntu with CGMiner

Join a Pool

Nowadays it’s not profitable to mine bitcoins alone in a single machine due to the cost it takes to generate enough bitcoins; hence the pool concept was invented for making it efficient and fast. A pool is a collection of miners who work together to mine coins, and then share the production when the block is found. The fee is paid to the miners who found the block. Usually the payout is available immediately, but it largely depends on the service provider. This tutorial picks as the provider “Bitcoin Merge Mining Pool” where the payout is immediate.

1. Navigate to the following website

http://mmpool.org/register

2. Type a desired username, and the aforesaid copied public bitcoin address in “Bitcoin” textbox as seen below.

bitcoin mining interface

3. Type the following commands in Ubuntu “Terminal”

cd /usr/src/cgminer

4. Now plug USB “ASICMiner Block Erupter” to the computer. The following one was taken from amazon. It usually costs around $80 to $100 bucks.

Bitcoin mining asic device connecting to Ubuntu

5. While it’s being plugged in, type the following command in Ubuntu terminal again

./cgminer -o stratum+tcp://mmpool.org:3333 -u YOURUSERNAME –p ANYTHING

6. Then it will start mining bitcoins. The speed is determined by the hash rate per second which is usually indicated with Mh/s, meaning mega hash per seconds. The higher the Mh/s, the better the “ASICMiner Block Erupter” device would be. The aforesaid product’s hash rate is 330MH/s, but there are better and worst block asic erupters available from any online store at a cheap price. Currently the most powerful one available at amazon is “ASICMiner Block Erupter Blade” which is rated at 10.7gh/s.

Ubuntu Terminal Screenshot

7. To see the progress of the whole mining, navigate to this particular address

http://mmpool.org/members where it shows the following report when given the username for which bitcoins were generated.

Output from CGminer for bitcoin Mining on Ubuntu

For Bitcoin the minimal withdrawing amount is 0.00500000 at “Bitcoin Merge Mining Pool”

Other Popular Pools Available Online

Currently there are not much pools available online, and even the existing mining pools aren’t that appealing due to the low user experience, and complicated configuration. However, the following pool services can be recommended as few of best, including the Merge Mining Pool which is featured in this article.

  1. com,
  2. BitMinter,
  3. com,
  4. Eligius,
  5. Give Me COINS,
  6. KanoPool,
  7. MergeMining,
  8. P2Pool,
  9. BTCDig

How to Use GPU to Mine Bitcoins?

As explained earlier in this article, due to the production cost it’s not profitable to use either GPU or CPU to mine bitcoins, and that’s why ASIC devices are needed in the first place. However, if there are a couple of AMD graphics card available with enough power, it’s possible to use them for mining a couple of bitcoins with some effort. Still this article doesn’t recommend both NVidia and Intel graphics card, and also CPU for producing bitcoins for their horrendous low performance.

At the moment the best graphics cards for mining bitcoins are AMD 5870×6, 5850×6, 6990×3,  7970×3, 5830×6, 7970×3, 5870×4, 6990×2, 6990×2, 6990×2, 6990×2, 5850×4, 6950×4, 6970×3, 6870×4, 6870×4,6 870×4, 6950×3, 5850×3, and all of them are capable of having above 1000 Mh/s, meaning over 1Gh/s which is quite high compared to many USB sized ASICBlock Erupters. However, Cgminer currently doesn’t support GPU mining; hence 3.7 version or below is needed to make GPU mining to work.

In “Setup Cgminer” segment above, use the following command instead of the one provided there. This will download the final version that supports GPU mining.

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

Currently there are no drivers for Ubuntu 17.04 which is the latest stable public desktop release for Ubuntu operating system. However, there is one for 16.04 which can be downloaded at this location

After downloading it install with the following command

  • cd /tmp
  • tar xf amdgpu-pro-<VERSION NUMBER>.tar.xz
  • chmod +x amdgpu-pro-<VERSION NUMBER>.run
  • sudo ./amdgpu-pro-<VERSION NUMBER>.run

, then install APP SDK

  • cd /tmp
  • tar -xvjf AMD-APP-SDKInstaller-<VERSION NUMBER>-GA-linux64.tar.bz2
  • chmod +x AMD-APP-SDKInstaller-<VERSION NUMBER>-GA-linux64.run
  • sudo ./AMD-APP-SDKInstaller-<VERSION NUMBER>-GA-linux64.run

Finally following commands to configure Cgminer for AMD graphics driver. First command configures the graphics card, the second one copy ADL SDK to cgminer’s directory, fourth one prepare cgminer’s compilation, then cgminer is set appropriate GPU flags to work with AMD graphics driver, compile the cgminer. After finishing this step, follow since Create a Wallet Segment.

  • sudo aticonfig –adapter=all -f –initial
  • cp /usr/ADL_SDK/include/* /usr/cgminer/ADL_SDK/
  • cd /usr/src/cgminer
  • run ./autogen.sh
  • CFLAGS=”-O2 -Wall -march=native -I /opt/AMDAPPSDK-<AMD APP SDK VERSION>/include/” LDFLAGS=”-L/opt/AMDAPPSDK-<AMD APP SDK VERSION>/lib/x86_64″ ./configure –enable-opencl –enable-scrypt
  • make

About the author

Admin

A passionate Linux user for personal and professional reasons, always exploring what is new in the world of Linux and sharing with my readers.