Mining the Monero cryptocurrency the CLI way

Mini Miner

© Lead Image © Chode,

© Lead Image © Chode,

Article from Issue 279/2024

The Monero cryptocurrency lets you get in the game without spending thousands on hardware. We'll show you how.

When I started mining Bitcoin 13 years ago, the hardware standard was a bunch of Windows computers built up around the best possible video cards and power supplies. The end goal was to achieve the most hashes per second (H/s, or sometimes expressed as kH/s or mH/s) [1]. To this day, it is easy to find articles explaining how to mine Bitcoin using this classic setup. But few of the mining tools are command-line based, which is a problem for Linux veterans who wish to avoid GUI clutter. But rest assured: A basic Debian system, with the fastest CPU you can get your hands on, is all you need to start mining cryptocurrencies.

In the highly competitive universe of crypto mining, major currencies like Bitcoin are typically mined using specially built Application-Specific Integrated Circuit (ASIC) systems, which require a significant investment of the miner's time and money.

Alternative currencies offer a lower barrier of entry. One alternative cryptocurrency that has gained some recent attention is Monero (abbreviated XMR). Monero stands out because it is truly anonymous [2] and because of its resistance to ASIC hardware mining [3]. This article describes how to start mining XMR on a Debian-based Linux system.

A Little Bit More on XMR

The value of Monero is nowhere near the range of Bitcoin's value. The price of XMR at the time I wrote this article was $142.30, whereas the price of Bitcoin was $25,851.07. Some have wondered whether XMR would ever reach the value of BTC, but since its inception in 2014, it has failed to even reach the $500 mark [4]. However, projections are looking solid, and Monero shouldn't disappear any time soon.

Technical Requirements

The most important asset for mining cryptocurrencies is electricity. The second most important asset is a fast CPU chip [5] that you can overclock. You'll also need a means for dissipating the heat and keeping your environment dust free. Because mining is a process that never sleeps and demands full capacity, it will be important to leave room for your hardware to remain in a cool, friendly zone for the time it will be crunching its life away. While it does, and if it runs as dedicated, it will emit a vast quantity of heat. The final factor affecting hashing performance is the clock speed of the RAM, although the RAM speed is less important than the other features I've mentioned.

A minimal system for mining XMR would have a 250GB SSD, 4GBs of RAM, and the cheapest video card available. The high-grade components need to be the CPU and the power supply unit. Investing in a good motherboard is optional yet vital if you wish for your system to beat the clock. Be advised that, as time goes on, the size of the decentralized blockchain copy that you'll need to host locally will eventually expand to over 250GB. Currently, it weighs about 164GB, so it is safe to say that a 250GB drive will hold for another three to four years at the very least – unless there is a huge increase in transactions.

Getting Started

The first step is to get the system up. For that, you'll need to install the latest Debian (bookworm) [6]. All you really need is the SSH server and standard system utilities from the latest Debian netinstall (Figure 1).

Figure 1: You'll need SSH and the standard system utilities.

Once you've installed the OS and logged into the freshly installed system, the work with Monero can begin. Start by downloading the latest Monero daemon [7] and extracting it under the folder of your choice (Figure 2). Then install the CPU miner (Figure 3).

Figure 2: Monero v0.18.2.2 is the latest current version; it contains both the daemon and the wallet binaries that are pivotal to mining Monero.
Figure 3: Even if last the update dates back to 2020, xmr-stak is still one of the best cross-platform CPU miners for XMR.

The next steps truly initiate the Monero footprint. The very first thing is to download the ~164Gbs blockchain, and for that, a simple execution of ./monerod will handle the task (Figure 4).

Figure 4: Downloading the blockchain with monerod.

Launching the monerod command without an existing blockchain in your home folder will result in it downloading the entire blockchain. This process will take a while – and even longer if you are working with a slow hard drive. Alternatively, specifying

--data-dir /path/of/.bitmonero

will simply download the delta since last update. That way you can always back up your downloaded blockchain every now and then, in order to avoid all this synchronization.

Whatever you attempt to do while the blockchain finishes updating could end up not working immediately. Therefore the wisest thing to do is to allow it to complete. However, this process will take several hours and can take days, depending on your Internet connection.

By default monerod puts everything blockchain related under /home/youruser/.bitmonero. The last operation is to port forward TCP/18081 if you wish to have no errors, but those errors will not void some functions.

Even when you have already downloaded 99 percent of the blockchain and have not updated in 10 days, it can take up to an hour for your node to be synchronized again. Because I am living dangerously, I will proceed immediately with the next step: setting up a wallet (Figure 5). In this case, I'll be running

Figure 5: You'll need to set up a wallet.

Upon first launch you are asked to create a wallet, secure it via a password, and then configure it. Then you are handed a 96-character alphanumerical expression that represents the actual wallet address used for all of your future transactions. You are also provided with 25 words that can be used to recover access to your wallet. Update your password manager with that information and take really good care of it!

At the end of the creation process, you will see your balance and can start making transfers, as long as the node is in sync with the Monero network. In the event that everything went smoothly, there will be two mywallet files under pwd.

The next step is setting up the miner, which you simply execute and answer a couple of questions. After you choose the desired currency, pool address, and wallet address, the system gives the infamous "MEMORY ALLOC FAILED" (Figure 6), but you can fix that right now.

Figure 6: Questions answered, but you'll need to make some changes before the miner is error free.

Buy this article as PDF

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

Buy Linux Magazine

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Mining Litecoin

    Although not as popular as headliners like Bitcoin and Ethereum, Litecoin is one of the oldest crytocurrencies, and it offers some useful features, such as dual-mining with Dogecoin.

  • The Impact of Crypto Mining

    With climate change wreaking havoc across the planet, we were just beginning to think about how we could use our technology to conserve fuel and reduce our carbon footprint. Then along came crypto mining.

  • StripedFly Malware Hiding in Plain Sight as a Cryptocurrency Miner

    A rather deceptive piece of malware has infected 1 million Windows and Linux hosts since 2017.

  • Welcome

    It is easy to write columns on the scary and annoying stuff, which seems to happen every day, but it is perhaps more important to point out the positive things when they happen, and the Ethereum Merge looks like a very positive thing.

  • MITRE ATT&CK Workshop

    The MITRE ATT&CK website keeps information on attackers and intrusion techniques. We'll show you how to use that information to look for evidence of an attack.

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More