Adding a CPU miner to smOS

in #mining6 years ago (edited)

In this tutorial we add the xmrig cpu miner to smOS. It’ll be helpful if you have a basic understanding of linux cli. I have a tutorial here Linux CLI (Command Line Interface) primer for beginners — Steemit

Screenshot 2018-02-12 22.18.14.png

I won’t cover how to ssh here. See my bminer tutorial for that. Here is how to secure ssh for smOS https://steemit.com/mining/@greerso/securing-ssh-for-smos.

  1. Install xmrig dependencies.
    sudo apt-get install git build-essential cmake libuv1-dev libmicrohttpd-dev
  2. . Download xmrig-2.4.4 (version 2.4.4 at the time of writing) from GitHub. You can read more about xmrig on their GitHub repo GitHub - xmrig/xmrig: Monero (XMR) CPU miner.
    git clone https://github.com/xmrig/xmrig.git
    cd xmrig-2.4.4
    
  3. Make a directory to compile xmrig into.
    mkdir build
    cd build
    
  4. Compile xmrig.
    cmake ..
    make
    
  5. Make a directory in the smOS miners_org and move xmrig into it.
    sudo mkdir /root/miner_org/xmrig-2.4.4&&sudo mv xmrig /root/miner_org/xmrig-2.4.4/
    
  6. Make sure that the new miner is executable.
    sudo chmod +x /root/miner_org/xmrig-2.4.4/xmrig
    
  7. Create a config file in the xmrig directory.
    sudo nano /root/miner_org/xmrig-2.4.4/config.json
    
    and paste the following text replacing your own preferences:
    {
    "algo": "cryptonight",  // cryptonight (default) or cryptonight-lite
    "av": 0,                // algorithm variation, 0 auto select
    "background": true,    // true to run the miner in the background
    "colors": true,         // false to disable colored output
    "cpu-affinity": null,   // set process affinity to CPU core(s), mask "0x3" for cores 0 and 1
    "cpu-priority": null,   // set process priority (0 idle, 2 normal to 5 highest)
    "donate-level": 1,      // donate level, mininum 1%
    "log-file": null,       // log all output to a file, example: "c:/some/path/xmrig.log"
    "max-cpu-usage": 75,    // maximum CPU usage for automatic mode, usually limiting factor is CPU cache not this option.
    "print-time": 60,       // print hashrate report every N seconds
    "retries": 5,           // number of times to retry before switch to backup server
    "retry-pause": 5,       // time to pause between retries
    "safe": false,          // true to safe adjust threads and av settings for current CPU
    "syslog": false,        // use system log for output messages
    "threads": null,        // number of miner threads
    "pools": [
        {
            "url": "us-east.cryptonight-hub.miningpoolhub.com:20596",   // URL of mining server
            "user": "greerso.Trio_CPU",                        // username for mining server
            "pass": "x",                       // password for mining server
            "keepalive": true,                 // send keepalived for prevent timeout (need pool support)
            "nicehash": false                  // enable nicehash/xmrig-proxy support
        }
    ],
    "api": {
        "port": 3333,                             // port for the miner API https://github.com/xmrig/xmrig/wiki/API
        "access-token": null,                  // access token for API
        "worker-id": null                      // custom worker-id for API
        }
    }
    
    Exit nano and save.
    [ctrl+x]
    y
    [enter]
    
  8. If you wish to test the miner, change the background mode above to "background": false and run the command
    sudo /root/miner_org/xmrig-2.4.4/xmrig
    
    You will see the miner output to the screen.
    [ctrl]+c
    
    to cancel
  9. Run xmrig as a service.
    sudo nano /lib/systemd/system/xmrig.service
    
    paste the following text
    [Unit]
    Description=XMRig Daemon
    After=network.target
    
    [Service]
    Type=forking
    GuessMainPID=no
    ExecStart=/root/miner_org/xmrig-2.4.4/xmrig -c /root/miner_org/xmrig-2.4.4/config.json -B
    Restart=always
    User=miner
    
    [Install]
    WantedBy=multi-user.target
    
    Exit nano and save.
    [ctrl+x]
    y
    [enter]
    
  10. Enable the new service.
    sudo systemctl daemon-reload
    sudo systemctl enable xmrig.service
    sudo systemctl start xmrig.service
    
    You can control the service with the following commands
    sudo systemctl status xmrig # Get status of service
    sudo systemctl stop xmrig # Stop the service
    sudo systemctl restart xmrig # restart the service
    

The cpu miner will not be able to be monitored via simplemining.net but it does have an api accessible on the port specified in the config.json file.

Coin Marketplace

STEEM 0.20
TRX 0.13
JST 0.030
BTC 65359.95
ETH 3492.90
USDT 1.00
SBD 2.51