Mining Monero with an Idle Linux Server

Machine-translated (anthropic, claude-haiku-5-5) from the Chinese original. Read the original in 中文

Contents

Preface

Recently I noticed I have a few more servers. I was thinking, leaving them idle is pointless, so I might as well use them to mine. Then we need to figure out what coin to mine. Bitcoin is already old news. What's popular now is Monero. What are its characteristics???

Let's take a look

  1. Hard to trace
  2. Extremely high security

Decentralization, privacy, digitization

These are all things we need, hehe. With Bitcoin, you can see where the funds flow and how much money is involved. If someone sees you have a lot of money, they might rob you, hehe.

Main Text

First we need an account, which is a wallet, right? It's like a WeChat payment QR code for receiving the coins we mine. Uh, you can use HitBTC, Light Wallet, or MY Monero.

I use HitBTC, hehe, so I'll use it as the example!

Oh right, everyone must update the mining software to v2.8+ before mining!!

The standard address format is 95 characters long, for example: 8ARayoehqh3ZZkUyXibMy8hW62nmjb5NcMNFDxoHRZy59JB53XatZZcJt3w2R6E7muWeTinWqRRi9VtzAhMwAoMsPriR42L

I won't go over registration. Click the green button at the top, and on the page that opens, find XMR.

That's it, hehe. You can send me a transfer, you know.

This is your wallet address!

Let's start setting up the environment!

Environment Setup

This article uses CentOS 7.5 64-bit throughout.

Installing Dependencies

text
yum install centos-release-scl epel-release -y

yum install cmake3 devtoolset-4-gcc* hwloc-devel libmicrohttpd-devel openssl-devel make git -y
scl enable devtoolset-4 bash

Downloading the Software

We clone xmr-stak from GitHub.

text
git clone https://github.com/fireice-uk/xmr-stak.git

Note, this author is sneaky. By default they charge a 2% fee, ugh. Let's change it, hehe!

In the file /xmr-stak/xmrstak/donate-level.hpp, change the default 2.0 to 0.0.

text
constexpr double fDevDonationLevel = 0.0 / 100.0;

We'll use vim here. First, type

text
vim donate-level.hpp

Then type i to enter insert mode, and change the 2 in front to 0, done!

Then press shift+: to enter command-line mode, type wq (meaning save and quit), and that's it.

Configuration and Compilation

We enter the directory we cloned.

text
cd xmr-stak

Then install cmake3.

text
cmake3 . -DCUDA_ENABLE=OFF -DOpenCL_ENABLE=OFF

Now we can compile.

text
make install

Once it finishes, we enter the bin directory, where our binary file is.

text
cd bin/

Now run it!

text
./xmr-stak

Enter 0 and press Enter.

Enter monero and press Enter.

Enter xmr-cn.sparkpool.com:11000 and press Enter. #This is the SparkPool mining pool, you can choose your own!

Enter the wallet address (the one that's "like the WeChat payment QR code") and press Enter.

Enter x and press Enter, or just press Enter.

Just press Enter.

Enter n and press Enter.

Enter n and press Enter.

Enter n and press Enter.

That's it, it's ojbk. But mining obviously needs to run in the background, right? You can't keep an SSH connection open forever, so we need to set up process daemonization.

Process Daemonization

We install screen.

text
yum install screen -y

Enter screen to get into the screen console window.

Go into the bin directory of our mining program.

text
cd xmr-stak/bin

Then run the mining program.

text
./xmr-stak

Press ctrl + a on the keyboard, release it, then press d to detach from the screen window. You can see a prompt in the bottom left corner.

To see which screen sessions we currently have, run screen -ls or screen -list (both commands work the same).

To return to the mining interface, run screen -r xxx to get back to our mining screen. This way, mining keeps running in the background even after we disconnect SSH.

If you want to leave the screen interface and keep mining, press ctrl + a, release the keys, then press d.

Note

If you get the error "MEMORY ALLOC FAILED: mmap failed" when mining on Linux,

run the command:

text
sysctl -w vm.nr_hugepages=128

Then edit the file /etc/security/limits.conf and add the following two lines before or at the second-to-last line:

text
soft memlock 262144
hard memlock 262144

Then reboot, or log out and log back in.

Comments