Monday, August 29, 2011

ubuntu 11.04/12.04/12.10/13.04 x86_64 dedicated crypto currency (bitcoin, i0coins, solidcoins, namecoins, ixcoins) mining rig using ATI RADEON GPU

update see post : for an update on this procedure, it will be easier for you and it will talk about the newest *buntu releases (13.04)

Yesterday Irene (28 august 2011) came in my region and after a power outage, I have lost an hard disk drive.  Fortunately, the drive is under warranty, but I had to reinstall my mining rig.

Today, I will place each steps to have a mining rig that will start and mine automatically.  Hope you will find this helpfull!  If it was, please consider sending me a small contributions to my bitcoin address : 13sRUwHbmv5ewLjQkKabDTsyPQEDD4v6mx !

It took me 2 days to finally being able to mine. I had to reinstall linux at least 15 times (passing from ubuntu to centos and finally to ubuntu).  But now everything is going fine!

Before starting, I have some comments :
1. remove the more hardware you can from the computer. Anything not used is power loss! Each watt count!
I mean:
- memory (you don't need 2-4gb!)
- cd drive, floppy drive, card reader
- sound card, io cards ...
- some people use a usb key instead a hard disk.  It is a great idea!  I will give it a try some day (linux coins and linux bamt are designed for that).
2. You will need good ventilation, so clean the wiring, add fans and don't forget the air must come in the case, so don't put 3 fans pushing the air outside of the case and leave free air space around the computer (I usually put the computer face against the wall so the hot air will get to the middle of the room).  Some people don't use a case to store their mining rig. One case I like, is the antec three hundred I have 3 5850 and the heat is acceptable inside.  Be carefull when you buy your motherboard, there is chances the last slot won't be available since the power supply is the end of the card (a simple height is OK, but dual height is not).
3. Have a very good power supply!  Pay to get a 80 plus gold rating and get enough wattage (I use the OCZZ850M for my rigs).

You will install the following tools :
- webmin
- apcupsd
- sshd
- pyopencl
- phoenix miner
- poclbm
- x11vnc

So, lets begin and download the ubuntu 11.04 CD. It is a live CD and an installation CD!  I'm a centos fan, but had some issue to mine using it, so now I use ubuntu and it works great, and it is easy to configure. update, I have tried kubuntu. Is is very very very nice. Easier to use than ubuntu with the unity gui. I recommand to switch to kubuntu !

Here is the download link : http://www.ubuntu.com/start-download?distro=desktop&bits=64&release=latest
You only have to burn the iso on a CD.

Then, you start your computer with the CD (boot from the CD) and you select to install.

The install process is very straight forward, so, you only have to press next...

When you will create your user, use a generic user of your choice and select login automatically.

Finish the install and reboot.

Lets begin!

1. Create a password for the root user, I know it is bad, but needed to use Webmin.

Open a terminal and type :
$ sudo passwd root

You will write your user password, then the root password for the root.  Please use a very long password ( a phrase).

2. Install VIM
$ sudo apt-get install vim

3. One ubuntu update seems to break the grub2 (bootloader) timeout, so the computer wait forever for the "enter" key to boot.

$ sudo vi /etc/default/grub
change GRUB_TIMEOUT=10 for GRUB_TIMEOUT="10"
$ sudo update-grub

This solved my problem on 2 computers. But on another, the bootloader does not get displayed and I don't know what is the problem yet.

4. Install missing packages

$ sudo apt-get install subversion git-core

4.1 Install ATI Catalyst

first, start synaptic package manager and remove every ati packages (unless the package is important for ubuntu like ubuntu-desktop) then remove every nvidia packages and finally fglrx.


Download : http://support.amd.com/us/gpudownload/linux/Pages/radeon_linux.aspx?type=2.4.1&product=2.4.1.3.42&lang=English


Note:  I already tried the ati catalyst version 11.7 (100%cpu while GPU mining only) and 11.8 (better than 11.7 but high cpu usage (30%-50%)). So I suggest using 11.6.
update: 1st december 2011, I tried the version 11.11, not sure yet for mining, but for everyday usage, this version is VERY NICE!  Every single bug I've found for this usage have been solved! Finally, I have to say: Great job AMD! I will post a new entry for the new version for mining.
Update (2nd august 2012) : The catalyst version 12.3 is incredible ! every single bug were again solved :-)

$ sudo chmod +x amd-driver-installer-12.3-x86.x86_64.run
$ sudo ./amd-driver-installer-12.3-x86.x86_64.run
- select install driver (1)
- agree to the licence (y)
- automatic (y)

if you have multiple adapter, you have to export DISPLAY=:0
$ echo 'export DISPLAY=:0' >> ~/.bashrc

$ sudo aticonfig --initial --adapter=all
This command configure the file /etc/x11/xorg.conf

At this point, you should restart your computer (probably a logout is sufficient) I reboot to be sure the previous step was successfull.

to test, you can : $ aticonfig --list-adapter
moreover you could wish to try: $ fglrxinfo

4.2 ATI Stream install (OpenCL Driver)


You can find the latest driver here :

I recommend downloading the version 2.4 since I did not tested the 2.5.
Update (2nd august 2012), the new version 2.7 rocks!  Low cpu usage and nothing wrong found :-) the best version since version 2.3!

http://developer.amd.com/sdks/AMDAPPSDK/downloads/Pages/default.aspx#one
$ mkdir amdapp_2-7

$ cd amdapp_2-7
$ tar -zxvf ../AMD-APP-SDK-v2.7-lnx64.tgz

$ sudo ./Install-AMD-APP.sh

These steps are no more needed since version 2.5

You have to export an environment variable in your .bashrc
$ echo 'export LD_LIBRARY_PATH=/opt/AMDAPP/lib/x86_64/:$LD_LIBRARY_PATH' >> ~/.bashrc
(everything on the same line)
Then add the library to the ld.so.conf
$ sudo vi /etc/ld.so.conf
add the following line:
/opt/AMDAPP/lib/x86_64
$ sudo ldconfig

reboot :-)

The steps from the point 4 are no more needed if you plan to use cgminer to mine. I strongly suggest to use cgminer, it is the best miner I saw.  It support multiple miner, can do round robin, switch to another pool when the main one fails ...

4.3 python pyopencl

$ wget http://pypi.python.org/packages/source/p/pyopencl/pyopencl-0.92.tar.gz
$ sudo apt-get install libboost-all-dev python-twisted*
$ tar -zxvf pyopencl-0.92.tar.gz
$ cd pyopencl-0.92.tar.gz
$ sudo python ./configure.py --cl-inc-dir=/opt/AMDAPP/include/ --cl-lib-dir=/opt/AMDAPP/lib/x86_64/
$ sudo make
$ sudo make install


4.4 m0mchild's poclbm (facultative step)
$ cd BTC_BASE
$ git clone git://github.com/m0mchil/poclbm.git
$ cd poclbm
$ python poclbm.py
you will see the device available to mine (CPU and GPU)

4.5 my preferred miner, phoenix-miner
$ cd BTC_BASE
$ git clone git://github.com/jedi95/Phoenix-Miner.git

5. Starting to mine!
You will have to chose if you do solo mining or will join a pool.  There is plenty of pool available and you can choose to mine several  crypto currency.  The only thing you have to do is to point to the pool with phoenix.

here is a small list of pool :


Follow the pool documentation for the correct command line.  In the version 1.6.X of phoenix, you can specify the option -b to add a failover pool so if the main pool is hanged, you will switch to another one which is very nice!


6. ATI overdrive
Most (if not all) Radeon have user configurable clock speeds.  Be carefull by doing this, the heat will increase a lot, the power consumption too!

6.1 enable overdrive
$ aticonfig --od-enable --adapter=0

6.2 get current clock
$ aticonfig --odgc --adapter=0


6.3 set new clock
$ aticonfig --odsc=875,900 --adapter=0

6.4 commit changes (if not, the default value will be effective on the next reboot)
$ aticonfig --odcc --adapter=0

6.5 get core temperature
$ aticonfig --odgt --adapter=0

6.6 set fanspeed
$ aticonfig --pplib-cmd "set fanspeed 0 56"


6.6.1 if you have more than one adapter 
$ export DISPLAY=:0.1; aticonfig --pplib-cmd "set fanspeed 0 56"
$ export DISPLAY=:0

note : Adapter mean the adapter chosen. You can use "all"



7. Environment setting for headless mining
7.1 OpenSSH install
$ sudo apt-get install openssh-server openssh-client

7.2 webmin install
add the following lines in the file sources.list
$ sudo vi /etc/apt/sources.list
# webmin
deb http://download.webmin.com/download/repository sarge contrib
deb http://webmin.mirror.somersettechsolutions.co.uk/repository sarge contrib

add the key from webmin
$ wget http://www.webmin.com/jcameron-key.asc
$ sudo apt-key add jcameron-key.asc
$ rm jcameron-key.asc

$ sudo apt-get update
$ sudo apt-get install webmin

webmin will run on the port 10000, so you only have to point to your ip address with your preferred web browser (probably firefox)

you will use the root username with the password you chose.

7.3 apcupsd
If you plan to add a ups to your rig (which is a very good idea since you paid a lot for those GPU!).  First, before buying the ups, look at the power needed to power up your rig.  One of mine needs 600W, buy a good ups which will be able to give you 2-3 minutes of battery life.

$ sudo apt-get install apcupsd apcupsd-cgi

You have to configure the file apcupsd.conf
$sudo vi /etc/apcupsd/apcupsd.conf
Follow the guide on the apcupsd website.
$sudo vi /etc/default/apcupsd
change ISCONFIGURED to true

$ sudo service apcupsd start

there is an apcupsd module for webmin

open webmin, go to webmin->webmin configuration->webmin modules1
paste the following link : http://diego.caravana.to/wp-content/apcupsd0.812.wbm.gz in the "from ftp or http URL"

The module is in the section other. You have to change some directory, go to the module configuration

change the path for each CGI to : /usr/lib/cgi-bin/apcupsd/*.cgi

7.4 VNC server  (to see the screen for your rig)
$ sudo apt-get install x11vnc vnc-java
$ x11vnc -storepasswd

You can point any java enabled web browser to your ip:5800 to access the computer!

7.5 Remove your screen saver
If you want to have more power to mine :-)

7.6 shutdown on power button
since the computer is headless, it may be necessary to close the computer easily.

7.7 Mining on start
At the startup, you will have to setup the fanspeed and start your miner on each GPU.

I use the following scripts :
#!/bin/sh

cpufreq-selector -g ondemand -c 0
cpufreq-selector -g ondemand -c 1
cpufreq-selector -g ondemand -c 2
cpufreq-selector -g ondemand -c 3

/bitcoin/setfanspeed.sh
gnome-terminal --command "/bitcoin/phoenix-miner/pool.sh" &



#start java vnc
gnome-terminal --command "x11vnc -forever -usepw -httpdir /usr/share/vnc-java/ -httpport 5800" &


Go to the gnome menu preferences->startup application and add your script (remove not needed applications!)

8. shutdown
shutdown your computer
8.1 Enter the bios and configure your computer to power on after power failure

8.2 unplug the power cord and plug it in the computer and validate the computer starts
8.3 look to see if your computer mine and PROFIT!

You are done! Happy mining !

If you want to exchange your bitcoins against other currency (US, EUR...) , I suggest you to use tradehill ( http://www.tradehill.com/ ). I tried other exchange site and the only exchange I got real money was tradehill.  Please use my reference number TH-R112979 (you will get 10% lifetime discount on your trade !)

Later, I will procede to update the ATI Catalyst and OpenCL driver, so keep reading to see how we do it!

I'm looking for your comments!

I accept contributions at my address : 13sRUwHbmv5ewLjQkKabDTsyPQEDD4v6mx !
----------
I'm looking for supervision software for headless server, if you can suggest some...
I used part of the following threads :
http://bitcointalk.org/?topic=3356.msg47489#msg47489
http://lifehacker.com/317125/set-up-vnc-on-ubuntu-in-four-steps