Monero – How to Setup a Full Node under Linux

This guide is continually updated on the wiki. Please see there to get the latest version. There are also my Monero related notes.

Important Notes

♦ Version 1, 26/09/2015

♦ License: Beerware Version 42++

♦ This tutorial uses the software version as distributed via the official web site at the time of writing: 0.8.8.6-release. The development branches are more advanced and provide additional possibilities.

♦ All memory related statements are my observations made using the version v0.8.8.6-release of the bitmonerod tool. No research around optimisation has been performed, nor deeper analysis of source codes. These are “download and run” observations, not a result of dedicated research. Please take them with educated care.

♦ The Monero software should be considered as still being in beta phase! This tutorial is provided as service to the community and if you decide to follow these instructions, you do this on your own responsibility.

♦ Running a full node is not anonymous, and it’s not supposed to be. You are part of a network and your have to be “discoverable”, so your IP address (and only this) is visible to the network.

♦ The Monero (XMR) currency is not the same than the BitMonero artifacts that can be found around the net. Be careful where to download your software!

Introduction

Side note: Monero is a crypto currency in the same way than Bitcoin is. Monero is however extremely different in many ways. It has different goals and does not share software and code with the Bitcoin code.  For more information, please refer to the documentation.

Due to the decentralized and peer-to-peer nature of the Monero network, it becomes more robust and resilient as it becomes larger. Running a full node helps stabilizing and securing the network. A full node contributes to the consensus and increases the Blockchain data distribution.

At the time of writing, running a full Monero node without active Miner thread does not require a huge amount of processing power, but it does need at least 6 GB of disk space to store the Blockchain data and, more importantly, it requires estimative 6 GB of RAM, better 10 GB  (see “Memory Footprint below). There will be some impact on the bandwidth, especially from connected nodes that are catching up on the Blockchain. The node can run in a Virtual Machine (VirtualBox, for example).

(Update on “Memory Footprint”: Since build version 20150906, the node tool does not keep the entire Blockchain in memory anymore. This drastically reduces the RAM requirements. I’ll update this guide as soon as the new version is officially released.)

The installation file, obtained from the official web site https://getmonero.org/downloads/, contains 2 files:

  • bitmonerod – A full node implementation, having a basic CPU miner integrated. “d” stands for daemon, which is a Linux term for a process/application running in the background without attached terminal.
  • simplewallet – A simple command-line wallet management application.

This tutorial is quite long because it tries to make things as clear as possible. The core operations however are just a few commands.

Procedure

Prerequisite: MINT Linux, probably any UBUNTU flavor (or, not tested by me, another Linux distribution).

Security: Personally, I prefer to setup such installation using a dedicated user account. Even better is to run them in a jail (using JailKit, or similar tool) and disable a remote login via “passwd -l, usermod –expiredate 1” and/or “DenyUsers” in “ssh_config” restricting the login to “su – username” only.

In this example, the user account is “monero”.

 

1) Dependencies

At the time of writing, the Monero node requires the Boost C++ Library to run. If not installed, apt-get it like this. NB. In case of problems after installation, try “sudo ldconfig -v”.


tasha@NOSHIP /home/tasha $ sudo apt-get install libboost1.55-all-dev

 

2) User Account

Create a dedicated user account and open a command prompt. This is optional if you decide to install everything using your standard user account.


tasha@NOSHIP ~ $ su - monero
monero@NOSHIP ~ $

 

3) Download Tools


monero@NOSHIP ~ $ mkdir bin
monero@NOSHIP ~ $ cd bin
monero@NOSHIP ~/bin $ wget https://downloads.getmonero.org/linux64
 
--2015-09-25 19:40:46--  https://downloads.getmonero.org/linux64
Resolving downloads.getmonero.org (downloads.getmonero.org)... 108.162.207.245, 141.101.124.245, 2400:cb00:2048:1::6ca2:cff5, ...
Connecting to downloads.getmonero.org (downloads.getmonero.org)|108.162.207.245|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://downloads.getmonero.org/monero.linux.x64.v0-8-8-6b.tar.bz2 [following]
--2015-09-25 19:40:47--  https://downloads.getmonero.org/monero.linux.x64.v0-8-8-6b.tar.bz2
Reusing existing connection to downloads.getmonero.org:443.
HTTP request sent, awaiting response... 200 OK
Length: 3308201 (3,2M) [application/octet-stream]
Saving to: ‘linux64’
 
100%[============================================================================================>] 3.308.201    993KB/s   in 3,3s   
 
2015-09-25 19:40:50 (973 KB/s) - ‘linux64’ saved [3308201/3308201]
 
monero@ATREIDES ~/bin $ # Optional: check file checksum
monero@ATREIDES ~/bin $ sha1sum linux64
29bc436c51cc2c9d571a0bfbf12fddab2e75a10b  linux64
 
monero@ATREIDES ~/bin $ # Get the correct SHA value from the web site
monero@ATREIDES ~/bin $ # Or using this one liner: (Note: will not work anymore if web page changes)
monero@ATREIDES ~/bin $ wget -q -O- https://getmonero.org/downloads/ | awk '/linux-64-bit/, /SHA Hash/'
../.. SHA Hash: 29bc436c51cc2c9d571a0bfbf12fddab2e75a10b
 
monero@NOSHIP ~/bin $ tar -vxf ./linux64
bitmonerod
simplewallet
 
monero@NOSHIP ~/bin $ ls -l
-rwxr-xr-x 1 monero monero 5599313 Dec 10  2014 bitmonerod
-rw-rw-r-- 1 monero monero 3308201 Dec 10  2014 linux64
-rwxr-xr-x 1 monero monero 4762673 Dec 10  2014 simplewallet

monero@NOSHIP ~/bin $

Of course, everything can be downloaded from the web page too: https://getmonero.org/downloads/

 

4) Setup Blockchain Directory and Data

By default, Monero installs the Blockchain data in the user’s home directory, in a folder named ~/.bitmonero.

Concerning the Blockchain database, it is indeed possible to simply start the bitmonerod node and then letting it synchronise with the network on its own. Seeing the size of the database however (4.5 GB, 09/2015), it’s much faster to straight download an initial version first:


monero@NOSHIP ~ $ cd ~
monero@NOSHIP ~ $ mkdir ~/.bitmonero
monero@NOSHIP ~ $ cd ~/.bitmonero/
 
monero@NOSHIP ~/.bitmonero $ wget  https://downloads.getmonero.org/blockchain/linux/blockchain.bin
 
--2015-09-25 17:22:55--  https://downloads.getmonero.org/blockchain/linux/blockchain.bin
Resolving downloads.getmonero.org (downloads.getmonero.org)... 141.101.124.245, 108.162.207.245, 2400:cb00:2048:1::8d65:7cf5, ...
Connecting to downloads.getmonero.org (downloads.getmonero.org)|141.101.124.245|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4530181601 (4,2G) [application/octet-stream]
Saving to: ‘blockchain.bin’
 
100%[===================================================================>] 4.530.181.601  580KB/s   in 2h 10m 
 
2015-09-25 19:33:10 (566 KB/s) - ‘blockchain.bin’ saved [4530181601/4530181601]

monero@NOSHIP ~ $

Wink: A GZIP compression would gain 25% of size, ie. 1 GB.

First Node startup

When starting the node for the first time, it will synchronize the local Blockchain database with the current state of the network. At time of writing, this was an 80 days difference, resulting in about 2h of synchronization on my test machine.

Starting the node does not start mining. The node only keeps itself in synch with the network and performs the classic node duties.

To exit gracefully, use the exit command. You can also explicitly save the Blockchain back to disk using the save command. Moreover, the tool saves the Blockchain memory data to disk regularly.

monero@NOSHIP ~ $ 
monero@NOSHIP ~ $ cd bin
 
monero@ATREIDES ~/bin $ ./bitmonerod 
 
2015-Sep-25 22:41:07.378399 Starting...
2015-Sep-25 22:41:07.379438 bitmonero v0.8.8.6-release
2015-Sep-25 22:41:07.379497 Module folder: ./bitmonerod
2015-Sep-25 22:41:07.380231 Initializing P2P server...
2015-Sep-25 22:41:09.690959 Binding on 0.0.0.0:18080
2015-Sep-25 22:41:09.691495 Net service bound to 0.0.0.0:18080
2015-Sep-25 22:41:09.692357 Attempting to add IGD port mapping.
2015-Sep-25 22:41:13.707421 No IGD was found.
2015-Sep-25 22:41:13.707465 P2P server initialized OK
2015-Sep-25 22:41:13.707474 Initializing protocol...
2015-Sep-25 22:41:13.707481 Protocol initialized OK
2015-Sep-25 22:41:13.707488 Initializing core RPC server...
2015-Sep-25 22:41:13.707500 Binding on 127.0.0.1:18081
2015-Sep-25 22:41:13.707558 Core RPC server initialized OK on port: 18081
2015-Sep-25 22:41:13.707569 Initializing core...
2015-Sep-25 22:41:13.707594 Loading blockchain...                      # <-- Loads the entire Blockchain into memory
2015-Sep-25 22:42:07.044808 Blockchain initialized. last block: 639896, d80.h17.m43.s28 time ago, current difficulty: 711778266
2015-Sep-25 22:42:07.204310 Core initialized OK
2015-Sep-25 22:42:07.204568 Starting core RPC server...
2015-Sep-25 22:42:07.204591 Run net_service loop( 2 threads)...
2015-Sep-25 22:42:07.204800 [SRV_MAIN]Core RPC server started ok
2015-Sep-25 22:42:07.204831 [SRV_MAIN]Starting P2P net loop...
2015-Sep-25 22:42:07.204877 [SRV_MAIN]Run net_service loop( 10 threads)...
2015-Sep-25 22:42:08.207368 [P2P9]
**********************************************************************
 
You can set the level of process detailization* through "set_log <level>" command*, where <level> is between 0 (no details) and 4 (very verbose).
 
Use "help" command to see the list of available commands.
 
Note: in case you need to interrupt the process, use "exit" command. Otherwise, the current progress wont be saved.
**********************************************************************
2015-Sep-25 22:42:20.399108 [P2P7][173.224.116.152:18080 OUT]Sync data returned unknown top block: 639897 ->; 755125 [115228 blocks (80 days) behind] 
SYNCHRONIZATION started
2015-Sep-25 22:42:20.623226 [P2P8][194.135.90.38:18080 OUT]Sync data returned unknown top block: 639897 ->; 755125 [115228 blocks (80 days) behind] 
SYNCHRONIZATION started
2015-Sep-25 22:42:36.482430 [P2P6]
**********************************************************************
You are now synchronized with the network. You may now start simplewallet.
 
Please note, that the blockchain will be saved only after you quit the daemon with "exit" command or if you use "save" command.
Otherwise, you will possibly need to synchronize the blockchain again.
 
Use "help" command to see the list of available commands.
**********************************************************************
2015-Sep-25 22:42:36.970257 [P2P7][89.98.228.253:18080 OUT]Sync data returned unknown top block: 639903 ->; 755125 [115222 blocks (80 days) behind] 
SYNCHRONIZATION started
2015-Sep-25 22:42:37.289137 [P2P5][217.160.92.61:18080 OUT]Sync data returned unknown top block: 639909 ->; 755125 [115216 blocks (80 days) behind] 
SYNCHRONIZATION started
2015-Sep-25 22:42:37.847627 [P2P4][94.23.216.116:18080 OUT]Sync data returned unknown top block: 639922 ->; 755125 [115203 blocks (80 days) behind] 
SYNCHRONIZATION started
2015-Sep-25 22:42:40.030185 [P2P0][39.171.145.11:18080 OUT]Sync data returned unknown top block: 639961 ->; 747753 [107792 blocks (74 days) behind] 
SYNCHRONIZATION started
2015-Sep-25 22:42:46.866266 [P2P2][98.115.147.74:18080 OUT]Sync data returned unknown top block: 640132 ->; 755125 [114993 blocks (79 days) behind] 
SYNCHRONIZATION started
2015-Sep-25 22:42:48.390940 [P2P9][115.28.191.182:18080 OUT]Sync data returned unknown top block: 640168 ->; 755125 [114957 blocks (79 days) behind] 
:
:
:

Wallet Set-up

In order to work with Monero coins and in order to mine, a wallet must be created by using the simplewallet tool. This is optional if you have already an address that can receive Mining Rewards.

The wallet data file is created in the current directory, so we move everything to a well defined place:

monero@NOSHIP ~ $ cd ~
monero@NOSHIP ~ $ mkdir wallet
monero@NOSHIP ~ $ cd wallet
 
monero@NOSHIP ~/wallet $ ../bin/simplewallet
 
bitmonero wallet v0.8.8.6-release
Specify wallet file name (e.g., wallet.bin). If the wallet doesnt exist, it will be created.
Wallet file name: mywallet
The wallet doesnt exist, generating new one
password: ******                                                        (<--- PRIVATE!)
List of available languages for your wallets seed:
0 : English
1 : Spanish
2 : Portuguese
3 : Japanese
Enter the number corresponding to the language of your choice: 0
Generated new wallet: 49Z73Cr...x1ACTuZHgHo                             (<- Your Public Address)
view key: f013f013f013f013f013f013f013f013f013f013f013f013f013f013f013  (<--- PRIVATE!)
**********************************************************************
Your wallet has been generated.
To start synchronizing with the daemon use "refresh" command.
Use "help" command to see the list of available commands.
Always use "exit" command when closing simplewallet to save
current sessions state. Otherwise, you will possibly need to synchronize 
your wallet again. Your wallet key is NOT under risk anyway.
 
PLEASE NOTE: the following 25 words can be used to recover access to your wallet. Please write them down and store them 
somewhere safe and secure. Please do not store them in your email or on file storage services outside of your immediate 
control.
 
sauerkraut sauerkraut sauerkraut sauerkraut sauerkraut sauerkraut sauerkraut 
sauerkraut sauerkraut sauerkraut sauerkraut sauerkraut sauerkraut sauerkraut 
sauerkraut sauerkraut sauerkraut sauerkraut sauerkraut sauerkraut sauerkraut 

( |___ This series of words, generated in the language above, is called Seed.)
(      It allows to access the Wallet without knowing the password and should)
(      obviously kept VERY secret (or even destroyed). PRIVATE!)
 
 
**********************************************************************

The technology behind Monero, Cryptonote, integrates the privacy aspect by design. This means that one cannot see the balance of any address out of the Blockchain. By this, simplewallet has to scan the Blockchain for transactions matching the wallets private key to determine its balance. For this, bitmonerod has to be running and be accessible by the wallet tool via RPC. Execute the refresh command to scan the Blockchain for transactions related to you wallet. This scans only new blocks, so it’s quick after the first execution has concluded.

address prints your wallet address, which is in fact your public key (and not a hash of the public key, like in Bitcoin). balance might be useful as well and help shows the list of available commands.

As stated above, the address ie. the public key, is stealth inside the Blockchain. By analysing the Blockchain, it is not possible to identify transactions associated to an address. This is where the view key comes in. The view key allows to identify transactions related to your address. It is meant to be published if the movements around an address are considered “public”. In short: your transactions are anonymous, until you have the view key of an account.

[wallet 45mezm]: (Type command:) refresh
Starting refresh...
Refresh done, blocks received: 755909                           
balance: 0.000000000000, unlocked balance: 0.000000000000

[wallet 45mezm]: (Type command:) address
45mezmBHxtCivwct1xhKXycUcKHDhmkBAP9wRuEVsK1BjX7TxVVBZSYAPXY7mMbRmC8vYqYnr4ggwJDQEGCUJXLHKr56hwJ

[wallet 45mezm]: (Type command:) balance
balance: 0.000000000000, unlocked balance: 0.000000000000

CPU Mining Test

The mining aspect of Monero is not part of this tutorial, so we start the integrated Miner just to verify that everything works well. Running the simple CPU miner in the bitmonerod tool will result very likely in Stale blocks, when done without pool. Stale blocks are blocks that have been found by someone else before your Miner located them. They are not added to the Blockchain since not located “at the end of the chain” anymore, and they do not give Mining Rewards.

Knowing our Wallet address, we can start mining by executing the following command, back in our bitmonerod console:

(Type command:) start_mining 45mezmBHxtCivwct1xhKXycUcKHDhmkBAP9wRuEVsK1BjX7TxVVBZSYAPXY7mMbRmC8vYqYnr4ggwJDQEGCUJXLHKr56hwJ
  or
(Type command:) start_mining 45mezmBHxtCivwct1xhKXycUcKHDhmkBAP9wRuEVsK1BjX7TxVVBZSYAPXY7mMbRmC8vYqYnr4ggwJDQEGCUJXLHKr56hwJ 3
  with 3 = number of mining CPU threads.

2015-Sep-25 23:47:48.249643 Mining has started with 1 threads, good luck!
2015-Sep-25 23:47:48.249687 Miner thread was started [0]

(Type command:)show_hr
hashrate: 1.0000
hashrate: 1.0000
hashrate: 0.8889
hashrate: 0.9000
hashrate: 0.8182
hashrate: 0.7500
hashrate: 0.8462
(Type command:)hide_hr
:
:
(Type command:)set_log 2    (for more real-time info on this mining process)
:
:
(Type command:)stop_mining
2015-Sep-25 23:50:36.950188 [miner 0]Miner thread stopped [0]
2015-Sep-25 23:50:36.950330 Mining has been stopped, 0 finished

For Information: Memory Footprint

(Update on “Memory Footprint”: Since build version 20150906, the node tool does not keep the entire Blockchain in memory anymore. This drastically reduces the RAM requirements. I’ll update this guide as soon as the new version is officially released.)

Monero is based on the CryptoNote project. CryptoNote is open-source and aims to implement the technology allowing the creation of completely anonymous egalitarian crypto-currencies.

One of the principal concepts is the “Egalitarian Proof of Work”, which is supposed to be perfectly suitable for ordinary PCs. It utilises built-in CPU instructions, which are very hard and too expensive to implement in special purpose devices or fast memory-on-chip devices with low latency (ASICs etc). The algorithm uses a memory-bound proof-of-work pricing function. It relies on random access to a slow memory and emphasizes latency dependence. As opposed to scrypt (Litecoin), every new block depends on all previous blocks.

As consequence, bitmonerod has a very high memory footprint. The following table shows the memory consumption by running a simple script while first node start-up. The increase happens when the line “2015-Sep-25 22:41:13.707594 Loading blockchain…” appears in the output. Note that the Blockchain data file size was 4.5 GB during this test – which is loaded into memory.

-------------------------------------------------------------------------------------------
%CPU 	%MEM      VSZ                         RSS                     TIME       COMMAND
                Virtual Memory Size         Resident Set Size
                All process memory          Physical memory allocated 
                including swapped out       to this process and 
                and from shared libraries   currently in RAM

2.0     0.0      106 368                    12 836                   0:00      ./bitmonerod
15.0    3.0      551 120                    432 008                  0:01      ./bitmonerod
47.8    13.7     2 040 244                  1 947 016                0:06      ./bitmonerod
62.5    23.7     3 445 240                  3 352 084                0:11      ./bitmonerod
70.7    30.7     4 438 052                  4 344 724                0:16      ./bitmonerod
79.8    39.8     5 716 980                  5 623 912                0:26      ./bitmonerod
82.2    41.7     5 978 016                  5 884 888                0:31      ./bitmonerod
86.1    46.3     6 646 992                  6 535 992                0:46      ./bitmonerod
87.4    47.0     6 737 320                  6 644 128                0:51      ./bitmonerod
82.1    47.0     7 599 580                  6 644 224                0:52      ./bitmonerod
73.5    48.8     8 214 932                  6 889 220                0:58      ./bitmonerod
79.3    51.3     8 689 952                  7 242 788                1:16      ./bitmonerod
82.9    51.6     8 755 488 (8.7 GB)         7 288 444 (7.2 GB)       1:32      ./bitmonerod 
-------------------------------------------------------------------------------------------

Once the node is synchronised, the memory footprint increased from 8.7 GB to about 9.5 GB, while the CPU load is reduced considerably. On my 16 GB RAM VM, the complete memory usage was around 10 GB, while the Swap File remained empty.

I also performed a test on a non-virtualised Mint Linux, running on a ‘normal’ laptop, 4 GB of RAM, 4 GB of Swap File, classic HD. The system was rendered unresponsive when loading the Blockchain into memory at bitmonerod start-up. Physical memory and swap file were completely full. I deduce that running a full node on a 4 GB RAM machine is not possible with this version of the bitmonerod client.

NB: Simple script to obtain this information:

#!/bin/bash
while :
do
   date
   ps u $(pgrep bitmonerod)

   date >> mem.log
   ps u $(pgrep bitmonerod) >> mem.log
   sleep 5
done

For Information: simplewallet Command-line

bitmonero wallet v0.8.8.6-release
[wallet 45mezm]: help
Commands: 
  address              Show current wallet public address
  balance              Show current wallet balance
  bc_height            Show blockchain height
  help                 Show this help
  incoming_transfers   incoming_transfers [available|unavailable] - Show incoming transfers - all of them or filter them by availability
  payments             payments &lt;payment_id_1&gt; [&lt;payment_id_2&gt; ... &lt;payment_id_N&gt;] - Show payments &lt;payment_id_1&gt;, ... &lt;payment_id_N&gt;
  refresh              Resynchronize transactions and balance
  save                 Save wallet synchronized data
  save_bc              Save current blockchain data
  seed                 Get deterministic seed
  set_log              set_log &lt;level&gt; - Change current log detalization level, &lt;level&gt; is a number 0-4
  start_mining         start_mining [&lt;number_of_threads&gt;] - Start mining in daemon
  stop_mining          Stop mining in daemon
  transfer             transfer &lt;mixin_count&gt; &lt;addr_1&gt; &lt;amount_1&gt; [&lt;addr_2&gt; &lt;amount_2&gt; ... &lt;addr_N&gt; &lt;amount_N&gt;] [payment_id] - 
                       Transfer &lt;amount_1&gt;,... &lt;amount_N&gt; to &lt;address_1&gt;,... &lt;address_N&gt;, respectively. &lt;mixin_count&gt; is the 
                       number of transactions yours is indistinguishable from (from 0 to maximum available)
  viewkey              Get viewkey

For Information: bitmonerod Command-line

help
bitmonero v0.8.8.6-release
Commands: 
  diff            Show difficulty
  help            Show this help
  hide_hr         Stop showing hash rate
  print_bc        Print blockchain info in a given blocks range, print_bc &lt;begin_height&gt; [&lt;end_height&gt;]
  print_block     Print block, print_block &lt;block_hash&gt; | &lt;block_height&gt;
  print_cn        Print connections
  print_pl        Print peer list
  print_pool      Print transaction pool (long format)
  print_pool_sh   Print transaction pool (short format)
  print_tx        Print transaction, print_tx &lt;transaction_hash&gt;
  save            Save blockchain
  set_log         set_log <level> - Change current log detalization level, <level> is a number 0-4
  show_hr         Start showing hash rate
  start_mining    Start mining for specified address, start_mining <addr> [threads=1]
  stop_mining     Stop mining

For Information: Logging and Internals

When activating the highest log level during intensive Blockchain database synchronisation, the following log file indicates what the tool is doing:

Log Extract, Level 4, No Mining, During Blockchain Synch, Version ‘bitmonero v0.8.8.6-release’

During normal operations, I suggest setting the log level to 1 or 2 (set_log 1) if more verbose output is desired.

Leave a Reply

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