XMR-Stak is somewhat of a go-to miner if you mine Monero or Aeon on the command line. The miner supports CPU, Nvidia and AMD GPUs. Let’s go over how to use it on Linux. Another user on reddit pointed out that I should probably give xmr-stak a try since it supposedly is faster than the cpuminer-multi that I’ve been using in the previous post.

If you want some more info on mining in general or how to set up your wallet, have a look at How To Mine Monero (XMR) with your CPU on Linux.

Disabling xmr-stak Developer Donations

Now, if you want to be nice you probably want to cut them some slack and just send some hashes their way, but if you’re set on disabling the donations (2 minutes out of 100 mining minutes) you can change the xmrstak/donate-level.hpp file in the git repository after you clone it.

If you’re in a terminal just do:

vim xmrstak/donate-level.hpp

and change:

constexpr double fDevDonationLevel = 2.0 / 100.0;

to

constexpr double fDevDonationLevel = 0.0;

Obviously you can also dial up the share ratio and give the wonderful developers more percentages for their hard work by upping the 2.0 to a higher value.

Compiling and Installing the XMR Stak Miner

Depending on which Linux distribution you’re running there are different installation instructions available for:

  • Ubuntu 16.04 (and up)
  • Ubuntu 14.04
  • Arch Linux
  • Fedora
  • CentOS

Basically Ubuntu 14.04 requires you to install an additional ppa that provides you with the up to date g++ version.

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-5 g++-5

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 60 --slave /usr/bin/g++ g++ /usr/bin/g++-5

If your

cmake

command should fail, it’s probably with one of these two error messages that concern mining with GPU drivers.

CUDA_TOOLKIT_ROOT_DIR not found or specified
-- Could NOT find CUDA (missing:  CUDA_TOOLKIT_ROOT_DIR CUDA_NVCC_EXECUTABLE CUDA_INCLUDE_DIRS CUDA_CUDART_LIBRARY) (Required is at least version "7.5")
CMake Error at CMakeLists.txt:209 (message):
  CUDA NOT found: use `-DCUDA_ENABLE=OFF` to build without NVIDIA GPU support
-- Could NOT find OpenCL (missing:  OpenCL_INCLUDE_DIR) 
CMake Error at CMakeLists.txt:267 (message):
  OpenCL NOT found: use `-DOpenCL_ENABLE=OFF` to build without OpenCL support
  for AMD gpu's

If you don’t want to use your graphic card, but your CPU of if you don’t have the support for either AMD or Nvidia GPUs you’ll need to exclude them while building like so:

cmake -DCUDA_ENABLE=OFF -DOpenCL_ENABLE=OFF ..

If you’re after starting the miner getting a lot of


[2018-01-14 16:52:14] : MEMORY ALLOC FAILED: mlock failed
[2018-01-14 16:52:14] : MEMORY ALLOC FAILED: mlock failed
[2018-01-14 16:52:14] : MEMORY ALLOC FAILED: mlock failed
[2018-01-14 16:52:14] : MEMORY ALLOC FAILED: mlock failed
[2018-01-14 16:52:14] : MEMORY ALLOC FAILED: mlock failed

Try enabling large pages:

sudo sysctl -w vm.nr_hugepages=128

Configuring CPU threads for xmr-stak

This setting to me appeared to be missing from the project since I couldn’t define it in the config file how many processor threads it should be using, where I could easily define that for the other miner.

In the end, it turns out that where every you run the miner and fill out the inital dialogue it creates a cpu.txt file that you can edit with your options.

Depending on the number of entries that go like:

    { "low_power_mode" : false, "no_prefetch" : true, "affine_to_cpu" : 0 },
    { "low_power_mode" : false, "no_prefetch" : true, "affine_to_cpu" : 1 },

the more cores xmr-stak will put to work. Remember to increment the number of the affine_to_cpu key or set them all to false.

Arch Linux Installation Tips

The installation guide is fairly alright, but I, with my infinite luck :P, still ran into some hiccups.

If you see messages like the following:

/usr/bin/systemd-tmpfiles: error while loading shared libraries: libcryptsetup.so.12: cannot open shared object file: No such file or directory
/usr/bin/systemd-tmpfiles: error while loading shared libraries: libcryptsetup.so.12: cannot open shared object file: No such file or directory
/usr/bin/systemd-tmpfiles: error while loading shared libraries: libcryptsetup.so.12: cannot open shared object file: No such file or directory
/usr/bin/systemd-tmpfiles: error while loading shared libraries: libcryptsetup.so.12: cannot open shared object file: No such file or directory
/usr/bin/systemd-tmpfiles: error while loading shared libraries: libcryptsetup.so.12: cannot open shared object file: No such file or directory
/usr/bin/systemd-tmpfiles: error while loading shared libraries: libcryptsetup.so.12: cannot open shared object file: No such file or directory
/usr/bin/systemd-tmpfiles: error while loading shared libraries: libcryptsetup.so.12: cannot open shared object file: No such file or directory

just run:

pacman -Sy cryptsetup

If you get the following error:

cmake: error while loading shared libraries: libjsoncpp.so.19: cannot open shared object file: No such file or directory

simply run:

pacman -S jsoncpp

If you encounter 404 errors on packages like so:


poliwangi.ac.id : The requested URL returned error: 404
error: failed retrieving file 'libxml2-2.9.4+16+g07418011-2-x86_64.pkg.tar.xz' from ftp.energia.mta.hu : The requested URL returned error: 404
error: failed retrieving file 'libxml2-2.9.4+16+g07418011-2-x86_64.pkg.tar.xz' from mirrors.lug.mtu.edu : The requested URL returned error: 404
^Cerror: failed retrieving file 'libxml2-2.9.4+16+g07418011-2-x86_64.pkg.tar.xz' from mirror.nexcess.net : The requested URL returned error: 404

You can mostly fix that by updating the package database:


sudo pacman -Syy

Summary

I’m still mining away on my first Monero and I’ll let you all know how it goes 🙂

Join the Conversation

6 Comments

  1. Hello,
    # Ubuntu / Debian
    ran into the cmake “CUDA_TOOLKIT_ROOT_DIR not found or specified” etc..
    next did:
    cmake -DCUDA_ENABLE=OFF -DOpenCL_ENABLE=OFF ..
    received this error:
    Parse error in command line argument: -DCUDA_ENABLE+OFF
    Should be: VAR:type=value
    CMake Error: No cmake script provided.
    CMake Error: Problem processing arguments. Aborting.
    Then tried “make install” received:
    make: *** No rule to make target ‘install’. Stop.

    I’m unsure where to go from here.
    Thanks for the consideration and help.
    Debian 9 virtualbox vm – 2ram and 2cpu

  2. Oops,
    I didn’t add the dependency AMD APP SDK 3.0 as you noted on installation instructions .
    I seem to have everything installed. So how do I start it and can you have it run when booted?
    Also could you email me your bitcoin address as I want to donate for this helpful info.
    Thanks

  3. Hi, I’m using a server with 2 X5650’s running xmr-stak on Ubuntu 17.10. I read on monerobenchmark that is possible to get about 700 h/s setting Arch Linux with no gui. What I have to do? Is it possible to install Arch Linux on Ubuntu? Thanks

Leave a comment

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