Monero Mining with xmr-stak-cpu on Ubuntu 16.04

  • 19
  •  
  • 1
  •  
  •  
  •  
  •  
  •  
  •  
    20
    Shares

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 https://github.com/fireice-uk/xmr-stak-cpu.git
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
./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" : "pool.usxmrpool.com:3333",
"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:

vm.nr_hugepages=128

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
[Unit]
Description=xmr
After=network.target
[Service]
ExecStart=/usr/local/src/xmr-stak-cpu/bin/xmr-stak-cpu -c /usr/local/src/xmr-stak-cpu/bin/config.txt
User=root
[Install]
WantedBy=multi-user.target

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!


  • 19
  •  
  • 1
  •  
  •  
  •  
  •  
  •  
  •  
    20
    Shares

53
Leave a Reply

avatar
27 Comment threads
26 Thread replies
13 Followers
 
Most reacted comment
Hottest comment thread
32 Comment authors
qanon1111Grunchy005Juan Carlos MorenoAronStonewol Laroo Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
bito
Guest
bito

got:
JSON config parse error(offset 1659): Missing a name for object member.

maybe coz im trying to alot cpu threads?

mine is :
“cpu_threads_conf” :
[
{ “low_power_mode” : false, “no_prefetch” : true, “affine_to_cpu” : 0 },
{ “low_power_mode” : false, “no_prefetch” : true, “affine_to_cpu” : 1 },
{ “low_power_mode” : false, “no_prefetch” : true, “affine_to_cpu” : 2 },
],

null,

hernanv50
Member

Thanks for this article, really useful, only to say, if running from Ubuntu Live CD, add “universal” to /etc/apt/sources.list.

hernanv50
Member

Sorry, it’s “universe”, not “universal”.

Tony91
Guest
Tony91

Thank you for your article. It works well with Digital Ocean VPS. I connect to VPS with SSH and it works. I am wondering if it is still running after I disconnect with the VPS?

elproducto
Guest
elproducto

Check out Cryptobadger blog on Litecoin setup. He give a method I use with Monero mining to setup screen to ensure miner is running at startup in a Screen.

qanon1111
Guest
qanon1111

if you are using Digitial Ocean You are an idiot Its by Alphabet AKA Google thats like using the one that fedbook came out with get TOR

Valtzu
Guest
Valtzu

hey I have a question, im not familiar at all with ubuntu. How do I EDIT the config.txt file while in SSH?

Keer
Guest
Keer

Hi, thanks for the great explanation! Is the password always “x”? Default in given file is “”.

Hector
Guest
Hector

The password actually is just the worker’s name shown in the pool site, it’s practical to put names that you can identify, like “Sonyi5” e.g., so you can know which PC is working and how much hash rate it is giving, in case that you will use more than one PC to mine.

Hector
Guest
Hector

Very good explanation, I managed to install and run stak in Xubuntu with no problems, very grateful, thank you!

Chris
Guest
Chris

hi. Thanks for this but I have a problem. After I copy and past the config info and the pool address and try to run it using ./xmr-stak-cpu, it keeps bringing up what to copy and past in to the config file again. What am I doing wroing?

makukaka
Guest
makukaka

Hey there, can i configure Ubundu OS to run multiple cores on Virtual machine, with, lets say, 32 real cores?

vicdeveloper
Member

Awesome!. Very thans man!.

JeromeyRomeyRomeThink
Guest
JeromeyRomeyRomeThink

Hey CCFreak,

Appreciate the tutorial. I was wondering how I could check up on my miner and it’s hashrate/errors, once I made it as a service.

I notice it runs in the background, but it doesn’t display it the miner’s output text anymore.

Thanks!

Michael
Guest
Michael

Please advise on the solution to the following error message.

[email protected]:/usr/local/src$ git clone https://github.com/fireice-uk/xmr-stak-cpu.git
fatal: could not create work tree dir ‘xmr-stak-cpu’: Permission denied

Thank you!!

Michael
Guest
Michael

It turned out that I just needed to clone it to my desktop…Nonetheless thank you for putting this tutorial up!!

Damien Piper
Guest
Damien Piper

You forgot to use sudo.

Deffy
Guest
Deffy

When I run:
sudo apt-get –assume-yes install libmicrohttpd-dev libssl-dev cmake build-essential libhwloc-dev screen git nano

I get package libhwloc-dev is not available, but is referred to by another package. This may mean that the package is missing, has been osbsoleted or is only available from another source.

E: Unable to locate package libmicrohttpd-dev
E: Package ‘libhwloc-dev’ has no installation candidate

Is this package no longer available? Does anybody know where I can get it?

Chin
Guest
Chin

Thank you for this.
Is there anyway that running xmr-stak for 2hrs. then stop 30′ and auto restart again?

kiran
Guest
kiran

nothing geting after firing sudo systemctl start xmr.service

MrBoff0
Guest
MrBoff0

Can I set vm.nr_hugepages to be 256? Will that improve my hashrate? And what does this do from a technical perspective? Does this matter if I am running Ubuntu on a VM or how much RAM is assigned to the VM? Thanks for any insights

MrBoff0
Guest
MrBoff0

There is a new build and different git at https://github.com/fireice-uk/xmr-stak.git , are the above steps applicable with this newest version? And 2% of the hashing power goes to the XMR-STAK developers wallet, how do I change this to a lower number? Thanks for any info

Sajan Nair
Member

the wallet address , can i use my own wallet address ?

Sajan Nair
Member

sysctl: permission denied on key ‘vm.nr_hugepages’ ?? Whats this 🙁 … i am new to linux ..please help

Serkan
Guest
Serkan

you need to use sudo

like
sudo sysctl bla bla

Sajan Nair
Member

error writing /etc/sysctl.conf permission denied …now this ! ….. LOL every time i figure one thing out …i get a new surprise 😀

this is when i am trying to ass hugepages at the end and trying to save and exit nano…

Serkan
Guest
Serkan

use this
sudo nano /etc/sysctl.conf

Sajan Nair
Member

So i have finally managed to do everything . But It cant seem to connect… I am getting the following msg in the terminal

[2018-01-16 02:59:17] : hwloc: memory pinned
[2018-01-16 02:59:17] : MEMORY ALLOC FAILED: mlock failed
[2018-01-16 02:59:17] : SOCKET ERROR – CONNECT error: Connection refused
[2018-01-16 02:59:17] : Pool connection lost. Waiting 10 s before retry (attempt 1).

Serkan
Guest
Serkan

check you internet connection….

SpaceDwarf
Guest
SpaceDwarf

check on the config.txt if your pool is correct

Sajan Nair
Member

this is the message i am getting .. it seems mmap is failing despite having activated hugemaps as per instructions given ….

Starting single thread, affinity: 0.
[2018-01-19 11:45:40] : Starting single thread, affinity: 1.
[2018-01-19 11:45:40] : Connecting to pool pool.usxmrpool.com:3333 …
[2018-01-19 11:45:40] : hwloc: memory pinned
[2018-01-19 11:45:40] : MEMORY ALLOC FAILED: mmap failed
[2018-01-19 11:45:40] : hwloc: memory pinned
[2018-01-19 11:45:40] : MEMORY ALLOC FAILED: mmap failed
[2018-01-19 11:45:40] : SOCKET ERROR – CONNECT error: Connection refused
[2018-01-19 11:45:40] : Pool connection lost. Waiting 10 s before retry (attempt

Duski
Guest
Duski

Perfect how-to, I followed it, also updated with new version of miner, anyway I would like to see hashrate, connection status in the logs or in service status. Is it possible to do so? Otherwise I need to stop the service, run the script manually and wait some time until diffcoulty is set and hit h r c letters to view statistics.
How to do it within the script please?

Alx
Guest
Alx

Hello everyone, can anyone help with my issue :
why do I get “Thread 0 has an invalid config” ? then miner does not launch
I did try the config proposal from xmrstak.com for xeon cpu though:”cpu_threads_conf” :
[
{ “low_power_mode” : false, “no_prefetch” : true, “affine_to_cpu” : 0 },
etc…

Madhav
Guest
Madhav

2018-01-22 02:09:53] : Invalid config file. Missing value “prefer_ipv4”.
why am i getting this error?

FridayMan
Guest
FridayMan

I cant go on at

$ cmake .

— Set miner currency to ‘monero’ and ‘aeon’
— 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

— Configuring incomplete, errors occurred!
See also “/usr/local/src/xmr-stak/CMakeFiles/CMakeOutput.log”.
See also “/usr/local/src/xmr-stak/CMakeFiles/CMakeError.log”.
CMake Error: Cannot open file for write: /usr/local/src/xmr-stak/CMakeCache.txt.tmp
CMake Error: : System Error: Permission denied
CMake Error: Unable to open cache file for save. /usr/local/src/xmr-stak/CMakeCache.txt
CMake Error: : System Error: Permission denied

Any idea, why I keep getting this error? Trying for two days now, pretty tired… but almost there 🙂

peppermint
Guest
peppermint

your using the new version, which is good however, they merged cpu and gpu mining so you need to do cmake -DCPU_ENABLE=ON -DOpenCL_ENABLE=OFF -DCUDA_ENABLE=OFF then just run ./xmr-stak after chmod and make install the program makes the configs now.
@OP might be better to make an update?

Stonewol Laroo
Member

Hello. I have had issue during install. Not sure what is going on because I have done this numerous times but for some reason this o e isn’t letting me pass the CMAKE command.
At cmake I get Specify a source directory to (re-) generate a build system for it ….. Please help

Aron
Guest
Aron

Instead if . copy the path:
sudo cmake /usr/local/src/xmr-stak-cpu
Later on, if you can’t edit the config.txt, open it with:
gksu gedit config.txt

Juan Carlos Moreno
Member

Please update the script if you could

Grunchy005
Guest
Grunchy005

USXMRPOOL.COM is possibly a scam?
They are not on the web anymore, the rumor is the pool operator was robbed of all his XMR, the police seized all his equipment, then he had his appendix out, which went septic, and is probably dead now, so please don’t go sniffing around for your XMR payout you’re not getting it.
Something like that.