How To Mine Monero (XMR) with your CPU on Linux

Monero is a cryptocurrency similar to Bitcoin and in this blogpost we’re going to have a look at how to mine some Monero through a command line based miner on Linux.

In contrast to Bitcoin and Ethereum a strong mining GPU is not impacting the payoffs as much since the cryptonight algorithm is CPU friendlier.

Technically you can run the miner anywhere it compiles, but Linux is probably the most likely candidate for your private mining operation since Linux servers are widely available in the shape of virtual private servers for you to quickly try it out.

Disclaimer: unless you have a lot of CPUs at your disposal it might take a while until you reach a payout.

How to Mine Monero:

This article will go over:

  1. Creating a Monero Wallet
  2. Picking a mining pool
  3. Downloading and copiling the miner
  4. Start mining Monero
  5. Monitoring your hashrate

Creating a Monero Wallet

You can either create a Monero Wallet by downloading the official client or using an online wallet such as mymonero.

Note that the official client brings an about 20-30 GB download to store the entire Monero blockchain on your computer as well.

Picking a Monero Mining Pool

To get started, I suggest you pick a mining pool from any of the mining pool lists, I went with xmrpool.net, but many of them run the same software on the backend and to monitor your mining efforts.

A mining pool combines the efforts of many miners and increases your chance of payouts, because you find new blocks quicker together. With the PPLNS pools you’ll be paid based on how much work you contributed to the new block. If you don’t have your own mining farm, but just run the miner on a couple of computers or even one, I’d recommend going with that option.

Note: Mining Monero on Windows

If you want a graphical user interface, you can make use of the Monero Spelunker GUI and get up and running right after creating your wallet.

Downloading the Miner for Linux

This tutorial is for the cpuminer-multi, you can also pick other miners depending on your CPU or GPU you want to use.

First, let’s install the require packages for Ubuntu, Linux Mint or other Debian-like systems:

sudo apt-get install git libcurl4-openssl-dev build-essential libjansson-dev autotools-dev automake

On Arch Linux you should have most pacakges available, else install them with pacman or pacaur.

Now let’s download the miner with git and change into the directory:

git clone https://github.com/hyc/cpuminer-multi
cd cpuminer-multi

It comes with a useful script called autogen.sh:

./autogen.sh
CFLAGS="-march=native" ./configure
sudo make install

If the previous commands throw an error, try the following:

./autogen.sh
./configure
sudo make install

Now the binary minerd should be available system wide. You can test that out by typing:

which minerd

Example output:

/usr/bin/minerd

Start Mining Monero

In order to start mining monero you can just run the below command:

sudo ./minerd -a cryptonight -o stratum+tcp://MININGPOOL:PORT -u WALLET_ADDRESS -p MINER_NAME

MININGPOOL and PORT depend on your miningpool.

Your WALLET_ADDRESS you either get from your wallet GUI or from your mymonero account.

MINER_NAME is up to you to define, I usually keep it to the host name of the machine.

By running the above command you will see output like:

[2017-12-24 13:13:25] Using JSON-RPC 2.0
[2017-12-24 13:13:25] Starting Stratum on stratum+tcp://frankfurt-1.xmrpool.net:5555
[2017-12-24 13:13:25] 8 miner threads started, using 'cryptonight' algorithm.
[2017-12-24 13:13:29] Pool set diff to 5000
[2017-12-24 13:13:29] Stratum detected new block
[2017-12-24 13:13:38] accepted: 1/1 (100.00%), 177.90 H/s at diff 5000 (yay!!!)

Whenever it states accepted that means that your calculations where accepted into the overall mining effort and should be visible in the dashboard of your mining pool.

Now you actually can wait for your machines to have accumulated enough shares to be considered as a large enough share of the payout in Monero to the wallet you specified.

Backgrounding the miner can be done by using screen or appending & to the command.

To kill the miner again you can use something like killall minerd.

Monitoring your Hashrate

Your mining pool will usually display an interface that shows how many hashes at once you’re going through per second. For each individual miner you can always check the output of the terminal.

If you’re curious how quickly you possibly will be rewarded by your mining pool, you can check out this helpful Monero mining calculator. You can even pick different options for solo mining, pool mining and if you rent or own the hardware.

Calculating Profits mining Monero

There are different profitability calculators online and they should all be taken with a grain of salt, since both difficulty of the network, amount of miners and some other factors will play a role in the development of the currency.

Further Reading

Monero recently sparked the interest of a lot of people, not least because a browser based miner exists, written in web assembly, which allows visitors of your website to donate Monero (mining effort) to you. I’ve covered the topic briefly: Testing Coin Hive Crowd Source Monero Mining.

Update: I’ve also tested the xmr-stak miner!

3 thoughts on “How To Mine Monero (XMR) with your CPU on Linux”

  1. Do I have to login into the pool to start minning? Or just by putting the address and port I will start to get my calculations accepted?

Leave a Reply

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