Monero Mining with xmr-stak-cpu on Ubuntu 16.04

Written by CC Freak on August 22, 2017
  • 18
  • 1

This article will show you how to install and run xmr-stak-cpu on Ubuntu 16.04. In this case, we are using a fresh Ubuntu 16.04 install on a VPS., however, any fresh install of Ubuntu 16.04 should behave the same.

Install XMR-Stak-CPU Required Packages

sudo apt-get --assume-yes update
sudo apt-get --assume-yes install libmicrohttpd-dev libssl-dev cmake build-essential libhwloc-dev screen git nano
cd /usr/local/src/
git clone
cd xmr-stak-cpu
cmake .
make install

After make install runs you will need to change directories:

cd bin/

Then you will run xmr-stak-cpu for the first time making sure it is executable:

chmod +x xmr-stak-cpu

Edit XMR-Stak-CPU Config File

You will notice that after the first run you are given a notice to edit your config.txt. The information given is very important and lets xmr-stak-cpu know how many threads to use. In every install I have done, the recommended settings have been the most optimal. Copy the recommendation and paste it into the bin/config.txt file and also make sure to edit the following lines:

"pool_address" : "",
"wallet_address" : "46dpA9N1KDE9yERcSGASXPUyA4ga1GrPq5sDXqwwjQL2dAmf5kvgpNQUWdvyT1r55pfwfvuBn2h7YQPhZFYdWtjWUVUTobh",
"pool_password" : "x",

After you have the config.txt edited correctly simply run xmr-stak-cpu once more.

Setup Huge Pages

If you run into issues related to mmap this means you need to enable hugepages. To do this type the following commands:

sysctl -w vm.nr_hugepages=128
nano /etc/sysctl.conf

At the end of the sysctl.conf file add:


Add XMR-Stak-CPU As Service

If your server loses power or reboots for any reason, this will automatically start xmr-stak-cpu. Create a service file with:

nano /lib/systemd/system/xmr.service
ExecStart=/usr/local/src/xmr-stak-cpu/bin/xmr-stak-cpu -c /usr/local/src/xmr-stak-cpu/bin/config.txt

Now run the following commands:

sudo systemctl daemon-reload
sudo systemctl enable xmr.service

To control the service:

sudo systemctl start xmr.service
sudo systemctl stop xmr.service
sudo systemctl restart xmr.service

If you found this helpful, consider a donation!

  • 18
  • 1

Topic tags:

Notify of
Newest Most Voted
Inline Feedbacks
View all comments