Mining the Monero cryptocurrency the CLI way

System Tweaks

Because the general idea behind mining is to maximize all available resources, you need to be sure to go big. For that, you will need to switch to root and add values in both /etc/sysctl.conf (Listing 1) and /etc/security/limits.conf (Listing 2). Do not forget to enter sysctl -p for the change to take effect immediately. However, at this point, due to the nature of what's coming, I like to save the changes for a final reboot to test it all out.

Listing 1

/etc/sysctl.conf

§§nonumbers
vm.nr_hugepages=1280

Listing 2

/etc/security/limits.conf

§§nonumbers
* soft  memlock 262144
* hard  memlock 262144

For the sake of coverage, Figure 7 shows how xmr-stak-rx should properly behave once everything is nice and tidy.

Figure 7: A better outcome after the changes.

Only when shortcuts are applied will cpu.txt be populated and no errors shown at the console prompt.

And Then

Because I am building a dedicated mining rig that runs 100 percent at all times, I first need to confirm that the values in cpu.txt match the actual machine values.

It's also possible that I was intrepid in pursuit of enrichment and immediately added the --noTest switch to the first launch of the xmr-stak-rx command. If no self test was done, the cpu.txt never populated. Or perhaps something worse happened? By nature, the content of the cpu.txt file is very basic most of the time (Figure 8).

Figure 8: Inside the cpu.txt file.

Each CPU thread that you wish to dedicate to mining XMR will need to have a value defined where the first core counts as 0. Therefore, a 64-thread dedicated mining machine would have 64 lines starting with 0 and ending with 63. However, in this case, I will make the educated guess that this machine has 12 threads off, and only the last 8 were configured to be usable by xmr-stak-rx.

If you wish to know how many usable threads your system can run, enter:

# dmidecode -t processor

and look for the thread count, which is at the bottom, or simply run htop and look at the number of cores that are shown at the top.

Another thing I like doing is making sure a mining rig requires minimal intervention (e.g., when there is a power loss and your UPS can't hold on long enough for the power to come back). Also, I like the boxes to have minimal cabling, which implies just the power and the network. Lastly, the systems will need room to breath and adequate ventilation.

To make sure I never lose a beat, I set the crontab entries in Listing 3 under my own user.

Listing 3

crontab Entries

§§nonumbers
@reboot /opt/crypto/monero-latest/monerod --data-dir /opt/crypto/.bitmonero --detach
@reboot cd /opt/crypto/xmr-stak-latest && ./xmr-stak-rx --noTest

When you're finished with these steps, shutdown the system and unplug everything. Set up the power and network cables as required for your configuration, and then plug the system in, power it up, and feel it getting warmer and its fans working harder. Congratulations, you are now mining Monero.

Along with the Cryptoriches!

Money doesn't come easily and the same applies to cryptocurrency. I decided to use Nanopool as the mining pool, but there are many other choices [8] to decide from, each with its own specifications.

The next step is to visit https://xmr.nanopool.org/account/ followed by the (very long) wallet name. For instance:

https://xmr.nanopool.org/account/43wnFgp65TxiexxMmKshejBjRZY5ckv987DQR4PMLKFuM5du8GWM8q56Ac3xZAYoELE1Tz8TxFzA6SZYWCVKiN9Z57NGfsh

After about 15 minutes, you will see the first results posted as an unconfirmed balance (Figure 9).

Figure 9: First results appear with an unconfirmed balance.

Even though the option for solo mining is a possibility, it is a good idea to join a mining pool to combine the computing power with other users. This method is generally the fastest way for crypto enthusiasts to get better payouts, as each pool has its own terms of use.

In the case of Nanopool, you need to have mined a full (that's 1.00000000) XMR unit, which will then be automatically cashed in your wallet, given that your local blockchain is fully up to date.

If you also happen to have unlimited electricity, CPU power, and room for ventilation, and you wish to dedicate a mining room, you can deploy additional systems, but avoid installing monerod on them, as it is only needed once in any environment. Just make sure you configure xmr-stak-rx to use your wallet address, and it won't be too long until you get your first payout.

If disaster strikes one day and you need to start back from scratch, the only pieces required to resume your XMR activities is a copy of both the wallet file and its key alongside the password or the 25 recovery words that were generated at wallet generation.

Be warned however, that if you stop mining from a pool while you haven't met the minimum payout and you do not contact them, you risk losing all of your accumulated balance.

With Nanopool, you can always get a non-checkout balance value transferred to you. For that to happen, you need to have been inactive for 24 hours and contact them [9]. You will want to learn a little bit more about joining a mining pool; this is perhaps the best advice that I can give you for starting your mining journey.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

comments powered by Disqus