-
Notifications
You must be signed in to change notification settings - Fork 4
Ubuntu Server with XMRig Installation
This guide shows you how to build XMRig from source, and have it automatically start up whenever you reboot your server.
The user being used is named miner
, so throughout the instructions, amend user if yours is different !
Where you see COIN
, substitute this to the coin's Ticker, e.g. xmr
These are all required before you proceed:
- Ubuntu Server with OpenSSH Server installed and configured for access.
- The
COIN
you are mining, e.g.xmr
. - Pool port, typically
100nn
,nn
being the last to digits unique to the pool. See our Discord for port list for guidance. e.g.10009
- Your Wallet Address for the
COIN
. - SSH client connected to the server.
NOTE: To leave a donation for the developers for their hard work, skip this line sed -i 's/5\;/0\;/g' xmrig/src/donate.h && sed -i 's/1\;/0\;/g' xmrig/src/donate.h
Let's build XMRig from source:
cd ~
sudo apt install git build-essential cmake libuv1-dev libssl-dev libhwloc-dev sed
git clone https://github.com/xmrig/xmrig.git
sed -i 's/5\;/0\;/g' xmrig/src/donate.h && sed -i 's/1\;/0\;/g' xmrig/src/donate.h
mkdir xmrig/build && cd xmrig/build
cmake ..
make -j$(nproc)
mkdir ~/XMRig
mv xmrig ~/XMRig/xmrig
cd ~
sudo rm xmrig -r
This will increase your hashing performance:
Edit the file /etc/sysctl.conf
using your preferred editor, use sudo to elevate your permissions, adding the following to the end of the file:
vm.nr_hugepages=1024
cd ~/XMRig
wget -O config.json https://raw.githubusercontent.com/The-GNTL-Project/Configs/master/XMRig_config.json
Edit the file ~/XMRig/config.json
using your preferred editor, adding for example:
"url": "pool.gntl.uk:10007",
"user": "gnt1ibrAtYtThQWQ8QdeLPWGD9ZeqnDsJ9A4d86DMC2RD7frBSE1uZmFezsbW7TXHdNHYWDWsccRo8TpE55p2HWR74ofajRWc5",
"pass": "Desktop01",
We will run our XMRig instance in a screen session, so you can attach and detach to it to monitor it.
Create the file /etc/systemd/system/mining.service
using your preferred editor, use sudo to elevate your permissions:
[Unit]
Description=Mining Service
[Service]
LimitMEMLOCK=infinity
Type=forking
RemainAfterExit=yes
User=miner
WorkingDirectory=/home/miner
ExecStart=/home/miner/StartMining
KillMode=none
[Install]
WantedBy=multi-user.target
This is what the service runs. We have separated this, as it's easier to add/remove additional commands, without having to modify the service file. We will run our XMRig instance in a screen session, so you can attach and detach to it to monitor it.
Create the file ~/StartMining
using your preferred editor:
#!/bin/sh
screen -dmS Mine sudo /home/miner/XMRig/xmrig
Let's now grant the required permissions for this to work:
sudo systemctl daemon-reload
sudo systemctl enable mining
sudo chmod 0755 ~/StartMining
Simply reboot the server, which will start the miner on the next boot.
sudo reboot
A few commands to monitor the miner:
- Attach to the screen session using
screen -r
, so you can view connection, errors, hashrate, etc. - De-attach from the screen session using
CTRL A D
, so you can leave it running in the background.