Monday 11 December 2017

Monero CPU mining on Debian 8 using xmr-stak-cpu

Monero Mining Is For Everyone!

Unlike Etherum, you can mine Monero with about anything, even your old laptop CPU. That won’t yield much profit, but it is a possibility. On top of that, GPU mining does not offer a substantial increase in mining power as in Ethereum. Here, a dedicated GPU can offer only 2 to 3 times greater hashrate than a new CPU, instead of Ethereum’s 10 to 20 times. This means you’re better off setting all your old laptops to mine than purchasing a new GPU, unless of course, you intend to set up a whole farm.
You can also mine with a CPU and a GPU at the same time. Bear in mind that this probably has greater power draw, and you ought to calculate whether what you’re doing is profitable. Let’s see how to mine using just a CPU.

How Intall XMR-STAK-CPU - Monero Mining Tool

I recommend using xmr-stak-cpu, a very fast, cost-effective, open source solution. First off, we will have to install dependencies of the program. We will also have to compile it, so we need software for that, too. Run:
sudo apt install libmicrohttpd-dev libssl-dev cmake build-essential libhwloc-dev
Then, download the miner:
wget https://github.com/fireice-uk/xmr-stak-cpu/archive/master.zip
Unzip it:
unzip master.zip
Enter the new directory:
cd xmr-stak-cpu-master
Run CMake:
cmake .
After you’re done, install the miner:
make install
It should create a „bin” folder. Enter the folder:
cd bin

How to Configure

(notice we are dealing with config text in bin folder, not the one in the root)

And edit the configuration file. Usually, all you need to do is specify your pool address, wallet address and „pool password”, which for the pool we’re using is just a machine name and email. Here is an example.
nano config.txt
"pool_address" : "pool.supportxmr.com:3333",
"wallet_address" : "yourmonerowalletaddresshere",
"pool_password" : "worker:name@email.com",
You can find other pool addresses here under ` Pick a server and port`.

Once you set the configuration file, run
./xmr-stak-cpu
And your machine will start mining with your CPU!

If you want to start the process in the background run this:

nohup ./xmr-stak-cpu &

You might see nasty messages like this:

[2017-07-09 12:04:02] : MEMORY ALLOC FAILED: mmap failed

This means that you can get around a 20% hashrate boost by enabling large pages.

Large pages on Linux

Firstly stop the miner (if it's running), run the following commands to enable large pages and then start the miner as root:
sudo sysctl -w vm.nr_hugepages=128

----------------------------

Disclaimer:

This is a slight modification of a tutorial originally written by Maciej Borkowski for Ubuntu 16.04 but I tested for Debian 8 and it works flawlessly. So thought it worth copying with slight midifications for future reference and maybe help others too, as I had difficulty with similar tutorials for Ubuntu on Debian.