Monero (XMR) GPU mining on Ubuntu 14.04

Posted on Fri 02 December 2016 in Bitcoin & Altcoins

Download the 14.04.4 release from here: http://releases.ubuntu.com/14.04/
DO NOT download the 14.04.5, because it is introducing Xorg1.18 which cause the problem that you encounter with newer release.

Even after the install and/or update check your Xorg version, this must Xorg1.16 and not above

$ sudo dpkg -l |grep xserver-xorg-core
ii  xserver-xorg-core-lts-utopic                          2:1.16.0-1ubuntu1.2~trusty2


In the case, you have a higher version, here the package to install the correct version.

$ sudo apt-get install xserver-xorg-lts-utopic libqt5gui5 \
libgles1-mesa-lts-utopic libgles2-mesa-lts-utopic \
libgl1-mesa-glx-lts-utopic libgl1-mesa-glx-lts-utopic:i386 \
libglapi-mesa-lts-utopic:i386 libegl1-mesa-drivers-lts-utopic

$ sudo dpkg -l |grep xserver-xorg-core
ii  xserver-xorg-core-lts-utopic             2:1.16.0-1ubuntu1.2~trusty2      amd64        Xorg X server - core server
rc  xserver-xorg-core-lts-wily               2:1.17.2-1ubuntu9.1~trusty1      amd64        Xorg X server - core server

$ sudo init 6
$ sudo apt-get update && sudo apt-get upgrade
$ sudo init 6


Download the ATI drivers: AskUbuntu

$ tree
.
├── fglrx_15.302-0ubuntu1_amd64_ub_14.01.deb
├── fglrx-amdcccle_15.302-0ubuntu1_amd64_ub_14.01.deb
├── fglrx-core_15.302-0ubuntu1_amd64_ub_14.01.deb
└── fglrx-dev_15.302-0ubuntu1_amd64_ub_14.01.deb

# Be sure there is not any previous version installed
$ sudo dpkg -l fglrx fglrx-core fglrx-amdcccle fglrx-dev
dpkg-query: no packages found matching fglrx
dpkg-query: no packages found matching fglrx-core
dpkg-query: no packages found matching fglrx-amdcccle
dpkg-query: no packages found matching fglrx-dev


Install dependencies & deb packages

sudo apt-get install dkms libc6-i386 lib32gcc1 gcc make
sudo dpkg -i fglrx-core_15.302-0ubuntu1_amd64_ub_14.01.deb \
fglrx_15.302-0ubuntu1_amd64_ub_14.01.deb \
fglrx-dev_15.302-0ubuntu1_amd64_ub_14.01.deb \
fglrx-amdcccle_15.302-0ubuntu1_amd64_ub_14.01.deb


Reboot & verify that drivers are correctly installed

$ sudo dpkg -l fglrx fglrx-core fglrx-amdcccle fglrx-dev
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                    Version          Architecture     Description
+++-=======================-================-================-====================================================
ii  fglrx                   2:15.302-0ubuntu amd64            Video driver for the AMD graphics accelerators
ii  fglrx-amdcccle          2:15.302-0ubuntu amd64            Catalyst Control Center for the AMD graphics acceler
ii  fglrx-core              2:15.302-0ubuntu amd64            Minimal video driver for the AMD graphics accelerato
ii  fglrx-dev               2:15.302-0ubuntu amd64            Video driver for the AMD graphics accelerators (deve



TITLE: Miner installation Download & Install v3 of ATI SDK (from browser, no direct link) http://developer.amd.com

# Prerequisites
sudo apt-get install -y git vim
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get install libjansson-dev libjansson4 build-essential

# Installation part
tar xvjf AMD-APP-SDKInstaller-v3.0.130.136-GA-linux64.tar.bz2
rm AMD-APP-SDKInstaller-v3.0.130.136-GA-linux64.tar.bz2 -f
sudo ./AMD-APP-SDK-v3.0.130.136-GA-linux64.sh
sudo ln -s /opt/AMDAPPSDK-3.0/ /opt/AMDAPP
sudo ln -s /opt/AMDAPP/include/CL /usr/include/
sudo ln -s /opt/AMDAPP/lib/x86_64/* /usr/lib/
sudo ldconfig
sudo init 6


Download the miner

cd ~/Downloads
git clone https://github.com/wolf9466/wolf-xmr-miner
cd wolf-xmr-miner/


Here is the custom part, thanks to SuperKuh for this tricks

wget https://gist.github.com/nhatminhle/5181506/archive/541482dbc61862bba8a156edaae57faa2995d791.zip
unzip 5181506-541482dbc61862bba8a156edaae57faa2995d791.zip
mv 5181506-541482dbc61862bba8a156edaae57faa2995d791/stdatomic.h .
rm -rf 5181506-541482dbc61862bba8a156edaae57faa2995d791

# Then edit main.c, comment the default library, and add path to yours
//#include <stdatomic.h>
#include </home/YOUR-USER/Downloads/wolf-xmr-miner/stdatomic.h>

# Then build it
make


Now, you can fill the configuration file with your XMR personal informations

$ vim xmr.conf

# For a Radeon HD 7950, here are some of the default values:
    "corefreq": 800,
    "memfreq": 1250,
    "url": "stratum+tcp://xmr-eu.dwarfpool.com:9500",
    "user": "YOUR_exchange-wallet.YOUR_payment-id",
    "pass": "x"


Then launch the mining binary with your conf file included

./miner xmr.conf



Below, you can find some useful commands.

# Core Temp
sudo aticonfig --od-gettemperature

# Fan speed
sudo aticonfig --pplib-cmd "get fanspeed 0"

# set fan speed to 100%
sudo aticonfig --pplib-cmd "set fanspeed 0 100"

# show current clockspeeds
sudo aticonfig --odgc



If you want to overclock the card, you can refer to this overclock guide on Guru3D, and test different settings.
From my side, I was originaly at Core=800, Mem=1250. And can have a stable overclock at Core=1100, Mem=1350 without having to change voltage or anything else.

For your information:
- Default Core=800, Mem=1250 => Mining at 380h/s
- OverClock Core=1100, Mem=1350 => Mining at 468h/s

# The first number is for the Core frequency, the second for the Memory
sudo aticonfig --odsc=1100,1350
sudo aticonfig --od-enable

# IMPORTANT, check your temperature
sudo aticonfig --od-gettemperature



If you want to monitor global information about the card, where only on one card. (TODO: Post the script for several card)

# GPUMON
#!/bin/bash

INTERVAL=5
ADAPTER=$1

while [ 0 ]; do
  TEMP=$(aticonfig --adapter=$ADAPTER --od-gettemperature | grep Temperature | awk '{print $5}')
  LOAD=$(aticonfig --adapter=$ADAPTER --od-getclocks | grep "GPU load" | awk '{print $4}')
  CORE=$(aticonfig --adapter=$ADAPTER --od-getclocks | grep "Current Clocks" | awk '{print $4}')
  MEM=$(aticonfig --adapter=$ADAPTER --od-getclocks | grep "Current Clocks" | awk '{print $5}')
  FAN=$(export DISPLAY=:0.$ADAPTER; aticonfig --pplib-cmd "get fanspeed 0" | grep "Fan Speed" | awk '{print $4}')
  echo "GPU $ADAPTER - Core: $CORE MHz - Memory: $MEM MHz - Load: $LOAD - Temp: $TEMP C - Fan: $FAN"
  sleep $INTERVAL
done


If you want to use aticonfig command from a ssh remote connection, you will have to forward X11 (check the sshd_config file on the server), and export DISPLAY, like the following:

ssh -X USER@IP.of.your.SERVER
export DISPLAY=:0




Tip:
XMR/Monero: 47sghzufGhJJDQEbScMCwVBimTuq6L5JiRixD8VeGbpjCTA12noXmi4ZyBZLc99e66NtnKff34fHsGRoyZk3ES1s1V4QVcB
ETH: 0x4b110cf4c8ae47d88e1b019ecbac428c3ad7a9e1
XMG: 9EuXjjqsJgEqDpQpGWxvEF9dckLCh8t1X8


Monero (XMR) CPU mining on CentOS 7

Posted on Thu 01 December 2016 in Bitcoin & Altcoins

Check the number of cores you have with "nproc" command.
Copy/paste this as root to your CentOS7 fresh install.

Change the Exchange Wallet and Personal Payment ID (the two long char/num chain on the last command). If you do not know what put, please refer to this:
http://dwarfpool.com/xmr


Prerequisites

yum install git automake gcc gcc-c++ openssl openssl-devel \
libcurl libcurl-devel -y


Add a dedicated user

useradd monero
su - monero


Get the sources, check, configure & compile the miner

git clone https://github.com/tpruvot/cpuminer-multi.git
cd cpuminer-multi/
./autogen.sh
./configure --with-crypto --with-curl
make


Test the binary and start mining.
Change the number of threads (here 12 with the -t option)

./cpuminer --cputest
./cpuminer -a cryptonight -o stratum+tcp://xmr-eu.dwarfpool.com:8050 -u 47sghzufGhJJDQEbScMCwVBimTuq6L5JiRixD8VeGbpjCTA12noXmi4ZyBZLc99e66NtnKff34fHsGRoyZk3ES1s1V4QVcB.a197bf7d0e942c03bc826530528974ae921384a88d0c9aaeae423e2973228746.1 -p x -t 12




Tip:
XMR/Monero: 47sghzufGhJJDQEbScMCwVBimTuq6L5JiRixD8VeGbpjCTA12noXmi4ZyBZLc99e66NtnKff34fHsGRoyZk3ES1s1V4QVcB
ETH: 0x4b110cf4c8ae47d88e1b019ecbac428c3ad7a9e1
XMG: 9EuXjjqsJgEqDpQpGWxvEF9dckLCh8t1X8


NextCloud installation on CentOS 7

Posted on Mon 28 November 2016 in Linux

The following tutorial does not cover the following:
- CentOS 6/7 installation & updating
- firewalld configuration
- selinux configuration
- Reverse Proxy with(out) SSL

However, if you want some details on their configuration, you can write to me, and If I can, I will provide you some help. Contact-me

LAMP Stack installation

Begin by installing the LAMP stack.
You can use my automated Apache/MariaDB/PHP installation script: Follow this link.

Or, you can just copy/paste this, and enter the MySQL new root password when prompted:

yum install -y epel-release vim git
git clone https://github.com/julien-escoffier/lamp-centos.git
cd lamp-centos/
chmod +x lamp-centos.sh
./lamp-centos.sh


Prerequisites of the NextCloud Installation

# Disable the directory listing on the WebRoot
sed -i 's/Options Indexes/Options/g' /etc/httpd/conf/httpd.conf

# NextCloud has a built-in WebDAV server -> SabreDAV, to you can disable mod_webdav
sed -i 's/^/#/g' /etc/httpd/conf.modules.d/00-dav.conf

# Install php dependencies
yum install php-gd php-xml php-mbstring php-process php-intl php-mcrypt php-pear bzip2  -y


Modify the upload size limit (here to 1024 MB)

sed -i 's/x_size = 8M/x_size = 1024M/g' /etc/php.ini 
sed -i 's/x_filesize = 2M/x_filesize = 1024M/g' /etc/php.ini


Restart Apache process

systemctl restart httpd


Database Configuration

Just create an empty NextCloud database, a new user and assign the proper privileges.

mysql -u root -p
create database nextcloud;

# Modify by the password you want
create user 'nxt_user'@'localhost' identified by '<HERE_YOUR_MYSQL_STRONG_ROOT_PASSWORD>';
grant all privileges on nextcloud.* to 'nxt_user'@'localhost' identified by '<HERE_YOUR_MYSQL_STRONG_ROOT_PASSWORD>' with grant option;
flush privileges;
exit;


NextCloud Installation

Get the sources, unpack, move them to /var/www/html and change owner user/group

tar xvjf nextcloud-10.0.1.tar.bz2 
mv nextcloud/* /var/www/html/
chown -R apache:apache /var/www/html


Open you browser, then create an admin user/pass and configure MySQL/MariaDB informations.

Owncloud Install Config Page


Setting strong directories permissions

As mentionned in the NextCloud documentation, strong directories permissions must be set up.
The following commands are extracted & adapted from the Official documentation regarding this tutorial.
doc: NextCloud Official Documentation.

# create the missing directory
mkdir -p /var/www/html/assets
cd /var/www/html

# Change permissions on Directories & Files
find . -type f -print0 |xargs -0 chmod 0640
find . -type d -print0 |xargs -0 chmod 0750

# Change permissions on .htaccess files
chmod 644 .htaccess data/.htaccess


Usage

You can now sync from the device you want:
- NextCloud App on the Android Play Store
- Windows: NextCloud Desktop Client
- Linux: OwnCloud Client based on the OwnCloud Client


Apache / MariaDB (MySQL) / Php installation script

Posted on Fri 25 November 2016 in Linux

Exhausted by the repeating LAMP stack installation, here a simple Bash script to automate this process.
You can view the sources by following this link.

You only need git to clone the repository.

yum install -y git
git clone https://github.com/julien-escoffier/lamp-centos.git
cd lamp-centos
chmod +x lamp-centos.sh
./lamp-centos.sh


Here, what's this script is currently doing:
- Installation log file: /usr/local/src/lamp.log
- Installing Apache + PHP
- Setting up ServerName Apache directive as your hostname
- Enabling & Starting Apache
- Installing MariaDB (MySQL)
- Enabling & Starting MariaDB
- Asking for an admin password
- Cleaning MySQL postinstall useless databases
- Cleaning MySQL permissions


What needs to be added to this script:
- Installation must be integrated with dialog and screen split with logs
- Add a starting menu allowing to: install / remove / change MySQL root password
- Add a Python version of this script
- Add a verification (enter twice) of the admin password


Nagios 4 installation (Server/Client) on CentOS 7

Posted on Sat 19 November 2016 in Linux

This is an installation tutorial for Nagios 4, we will build it from source (Core version).

Prerequisites

yum install -y gcc php glibc glibc-common \
gd gd-devel make net-snmp openssl-devel xinetd unzip


Create dedicated user/group

useradd nagios
groupadd nagcmd
usermod -a -G nagcmd nagios


Nagios Core installation

# Get the sources & extract them
cd /usr/local/src
curl -L -O https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.2.2.tar.gz
tar xvzf nagios*.tar.gz
cd nagios*

# configure & compile
./configure --with-command-group=nagcmd
make all
make install
make install-commandmode
make install-init
make install-config
make install-webconf


Nagios Plugins installation

# Get the sources & extract them
cd ..
curl -L -O http://nagios-plugins.org/download/nagios-plugins-2.1.4.tar.gz
tar xvzf nagios-plu*.tar.gz
cd nagios-plu*

# Configure, compile & install
./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl
make
make install


NRPE installation

# Get the sources & extract them
cd ..
curl -L -O https://netix.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz
tar xvzf nrpe*.tar.gz
cd nrpe*

# Configure, build & install (xinetd startup script included)
./configure --enable-command-args --with-nagios-user=nagios --with-nagios-group=nagios --with-ssl=/usr/bin/openssl --with-ssl-lib=/usr/lib/x86_64-linux-gnu 
make all
make install
make install-xinetd
make install-daemon-config


Configure xinetd & allow the private IP address of the nagios server.

vim /etc/xinetd.d/nrpe
    only_from       = 127.0.0.1 IP.of.the.SERVER

# Add a specific entry in the services
    echo 'nrpe 5666/tcp NRPE' >> /etc/services


Nagios configuration

Add & configure a folder to the general conf, in order to store a configuration file for each server.

mkdir /usr/local/nagios/etc/servers
chown -R nagios:nagios /usr/local/nagios/etc/servers
vim /usr/local/nagios/etc/nagios.cfg

# uncomment this entry
cfg_dir=/usr/local/nagios/etc/servers


Modify contact address.

vim /usr/local/nagios/etc/objects/contacts.cfg
email   your@address.org


Configure check_nrpe command.
WARNING: DOUBLE CHECK the file after pasting this command, because the system often interprets the $USER1$, $HOSTADDRESS$ & $ARG1$ variables.

    cat  << EOF >> /usr/local/nagios/etc/objects/commands.cfg
    define command{
            command_name check_nrpe
            command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
    }
    EOF


Create an admin user, in order to minimal protect the webpage.

htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
#(If you want another username, edit /usr/local/nagios/etc/cgi.cfg and change all the nagiosadmin reference)


Change permission of the nagios.cmd file, to allow the forced checks to be initiated from the webserver

service nagios stop
chown -R nagios:apache /usr/local/nagios/var/rw


Restart Apache one last time.

systemctl restart httpd
service nagios start


You can now access to Nagios through your browser.
http://here.your.ip.address/nagios/


Adding your first client

Client Side

Packages pre-requisites.

yum install epel-release -y
yum install nrpe nagios-plugins-all -y


Update the NRPE configuration

vim /etc/nagios/nrpe.cfg

# Change by the IP of you Server
allowed_hosts=127.0.0.1,IP.of.the.SERVER

#Allow command arguments
dont_blame_nrpe=1

#then add the following lines, at the bottom of the file
command[users]=/usr/lib64/nagios/plugins/check_users -w 5 -c 10
command[http]=/usr/lib64/nagios/plugins/check_http -I localhost 
command[load]=/usr/lib64/nagios/plugins/check_load -w 15,10,5 -c 30,25,20
command[swap]=/usr/lib64/nagios/plugins/check_swap -w 20% -c 10%
command[root_disk]=/usr/lib64/nagios/plugins/check_disk -w 20% -c 10% -p / -m
command[zombie_procs]=/usr/lib64/nagios/plugins/check_procs -w 5 -c 10 -s Z
command[total_procs]=/usr/lib64/nagios/plugins/check_procs -w 190 -c 200
command[proc_crond]=/usr/lib64/nagios/plugins/check_procs -w 1: -c 1:5 -C crond


Add service to boot sequence and start it.

systemctl enable nrpe
systemctl start nrpe

Server Side

First, create a specific file for you new host.

# Here change host_name & address variables
cat << EOF >> /usr/local/nagios/etc/servers/YOUR_CLIENT_HOSTNAME.cfg
define host {
use             linux-server
host_name       CLIENT_HOSTNAME
address         IP.of.the.CLIENT
max_check_attempts  5
check_period        24x7
notification_interval   30
notification_period     24x7
}
EOF


You can add more services check to this file, here a copy/paste of mine. So feel free to copy/paste the ones you desire.
Info: here the check_command check_ping & check_ssh are directly executed by the Nagios server. While the others (using check_nrpe) are requested by the server command check_nrpe and are executed by the Nagios client.

define service {
        use                     generic-service
        host_name               YOUR_CLIENT_HOSTNAME
        service_description     ping
        check_command           check_ping!100.0,20%!500.0,60%
}

define service {
        use                     generic-service
        host_name               YOUR_CLIENT_HOSTNAME
        service_description     ssh
        check_command           check_ssh
        notifications_enabled   0
}

define service{
        use                     generic-service
        host_name               YOUR_CLIENT_HOSTNAME
        service_description     / Partition
        check_command           check_nrpe!root_disk
        }

define service{
        use                     generic-service
        host_name               YOUR_CLIENT_HOSTNAME
        service_description     users
        check_command           check_nrpe!users
        }

define service{
        use                     generic-service
        host_name               YOUR_CLIENT_HOSTNAME
        service_description     procs
        check_command           check_nrpe!total_procs
        }

define service{
        use                     generic-service 
        host_name               YOUR_CLIENT_HOSTNAME
        service_description     load
        check_command           check_nrpe!load
        }

define service{
        use                     generic-service
        host_name               YOUR_CLIENT_HOSTNAME
        service_description     http
        check_command           check_nrpe!http
        }


Hostgroup configuration
Create a file with the following (You will have to add each concerned host to this file, on the line members, if you want to see them on the Host Groups web page).
Info: Comment the linux-servers entry in the objects/localhost.cfg file

cat << EOF >> /usr/local/nagios/etc/objects/hostgroup.cfg
define hostgroup{
        hostgroup_name  linux-servers 
        alias           Linux Servers 
        members         localhost,CLIENT_NAME     ; Comma separated list of hosts 
}
EOF


Add the brand new file create to the included conf files

vim /usr/local/nagios/etc/nagios.cfg

cfg_file=/usr/local/nagios/etc/objects/hostgroup.cfg


Logging path & nagios reload
Create a symlink from default nagios.log to a standard location

ln -s /usr/local/nagios/var/nagios.log /var/log/nagios.log
systemctl reload nagios


Refresh your browser and wait for the services update.