Skip to main content

Xmrig Config

# Xmrig Configuration Documentation for Monero Mining

This documentation provides a detailed explanation of how your system is configured for mining Monero using `xmrig`. It includes descriptions of both the systemd service file and the configuration specifics.

## Systemd Service File

### Overview

The systemd service file orchestrates the execution of `xmrig` in a tmux session. This setup ensures that the miner runs continuously, even if the terminal or user logs out, by leveraging tmux's capabilities.

### File Details

```ini
[Unit]
Description=Xmrig

[Service]
User=poslop
Type=forking
ExecStart=/usr/bin/tmux new -s xmrig -d 'sudo /usr/bin/xmrig/xmrig'
RemainAfterExit=true
ExecStop=tmux send-keys -t xmrig C-c

[Install]
WantedBy=multi-user.target
```

#### Explanation

- **Unit Section**
  - `Description=Xmrig`: Provides a human-readable description of the service.

- **Service Section**
  - `User=poslop`: Specifies that the service runs under the user `poslop`.
  - `Type=forking`: Indicates that the service forks into the background, which is typical for services managed by systemd.
  - `ExecStart=/usr/bin/tmux new -s xmrig -d 'sudo /usr/bin/xmrig/xmrig'`:
    - Launches a new tmux session named `xmrig`.
    - Detaches it (`-d`) to run in the background.
    - Executes `xmrig` using `sudo`, ensuring necessary permissions are granted.
  - `RemainAfterExit=true`: Ensures that the service is marked as active even after the main process exits, which is useful for tmux sessions.
  - `ExecStop=tmux send-keys -t xmrig C-c`: Sends a "Ctrl-C" to gracefully stop the `xmrig` process within its tmux session.

- **Install Section**
  - `WantedBy=multi-user.target`: Specifies that this service should be started at boot time when the system is in a multi-user mode.

## Xmrig Configuration

### Config File Location

The configuration for `xmrig` is stored in:

```
/usr/bin/xmrig/config.json
```

This JSON file contains various settings specific to your mining operation, such as algorithm type, pool information, and performance tuning parameters.

### Connection Details

- **Pool Node Connection**: 
  - Uses `p2pool`, a decentralized mining pool.
  
- **Node Address**:
  - Host: The service connects to the server named `pas` via `tailscale VPN`.
  - Port: `3333`
  - If remote, `tailscale VPN` facilitates secure access; if local, it uses `localhost`.

### Summary

This configuration ensures that `xmrig` runs effectively in a dedicated tmux session under the user `poslop`, connected securely to your chosen mining pool. The systemd service management provides robustness and automatic recovery on boot or after logouts.

This setup is optimized for continuous Monero mining operations, leveraging both system-level services and network configurations for secure, efficient operation.