Install XMRig CPU Miner on Ubuntu 16.04 with CLI

Mine Monero (XMR) on Ubuntu 16.04 with Hugepages Enabled

XMRig is a Monero CPU miner written in C++. It is the best miner for Monero in my opinion. XMRig gives best possible hashrate for your rigs with Ubuntu hugepages support. I’ll show you steps to install XMRig CPU Miner on Ubuntu 16.04 with hugepages enabled.

XMRig is an open-source software and available to download from official github repository. We’ll download this shortly. But first you should connect to your Ubuntu command line. If you’re on Ubuntu desktop, hit CtrlAlt + T keys to launch CLI. If you’re connecting to an Ubuntu from Windows, use Putty to connect over SSH. Make sure to login with root user account.

Ubuntu 16.04 has met its EOL and should be avoided. Please use our updated tutorial to install XMRig on Ubuntu 18.04 or Ubuntu 20.04.

Prepare Ubuntu 16.04 to Install XMRig CPU Miner

Before you can install XMRig on your Ubuntu 16.04 machine, there are few dependencies you should install. Let’s start by installing software-properties-common.

apt install software-properties-common

There is a good chance that software-properties-common is already installed on your system. Either way, above command will make sure you have the latest version on your machine.

Next we’ll install gcc 7 for a small performance boost. Following command will add Jonathon F’s GCC 7.1 PPA to your system.

add-apt-repository ppa:jonathonf/gcc-7.1

Update apt cache,

apt update
apt upgrade

Now install dependencies,

apt install git build-essential cmake libuv1-dev libssl-dev libmicrohttpd-dev gcc-7 g++-7

This can take few minutes. We’ll do a quick reboot when dependencies are finished installing.

reboot

Your Ubuntu 16.04 machine will be ready for XMRig CPU Miner when it comes back online.

Install XMRig CPU Miner on Ubuntu 16.04

We can now build XMRig CPU Miner Ubuntu 16.04. We will use Git to download the miner.

git clone https://github.com/xmrig/xmrig.git

Navigate to downloaded directory,

cd xmrig

Create a new directory named build inside xmrig directory,

mkdir build

Navigate build directory,

cd build

Build XMRig with gcc 7,

cmake .. -DCMAKE_C_COMPILER=gcc-7 -DCMAKE_CXX_COMPILER=g++-7
make

That should do it. You can start mining now. But we’ll do one more thing to get 5% – 10% hashrate boost.

Enable Hugepages on Ubuntu

First check if hugepages are available on your system with following command.

cat /sys/kernel/mm/transparent_hugepage/enabled

You should see an output like below.
Check Ubuntu 16.04 Hugepages

Currently active option is enclosed in brackets. In the above output, I have hugepages set to madvise. Which means hugepages are available on my system. If you see [never] in your output, you can’t use hugepages. So skip this part.

I prefer to allocate hugepages equaling to number of CPU cores I’m mining with. If I’m mining with 8 cores, I’ll set hugepages to 8 with following command.

sysctl -w vm.nr_hugepages=8

I haven’t looked into hugepages much. So i’m no expert on that. Feel free to research more and adjust accordingly. This gives me good enough result not to bother with it.

Start mining Monero with XMRig CPU Miner on Ubuntu 16.04

Following is the command I run to start mining,

/root/xmrig/build/./xmrig -a cryptonight -o stratum+tcp://pool.supportxmr.com:5555 -u MoneroAddress -p MinerIdentifier:Email -t 8

This starts mining with 8 cores. There are more configuration option to the miner. You can view them with following command,

/root/xmrig/build/./xmrig -h

That’s it. You can further optimize your mining with xmr-node-proxy if you have more than 10 miners. Happy mining!!

Tharindu

Hey!! I'm Tharindu. I'm from Sri Lanka. I'm a part time freelancer and this is my blog where I write about everything I think might be useful to readers. If you read a tutorial here and want to hire me, contact me here.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button