Market Cap: $2.6532T 1.33%
Volume(24h): $204.8037B 44.96%
Fear & Greed Index:

15 - Extreme Fear

  • Market Cap: $2.6532T 1.33%
  • Volume(24h): $204.8037B 44.96%
  • Fear & Greed Index:
  • Market Cap: $2.6532T 1.33%
Cryptos
Topics
Cryptospedia
News
CryptosTopics
Videos
Top Cryptospedia

Select Language

Select Language

Select Currency

Cryptos
Topics
Cryptospedia
News
CryptosTopics
Videos

How to Mine Bitcoin on Linux? (Advanced Ubuntu Guide)

Set up Ubuntu 22.04 with full-disk encryption, install ROCm/CUDA drivers, compile BFGMiner with OpenCL/CUDA support, secure via non-root user and UFW, and monitor thermals headlessly.

Feb 03, 2026 at 08:59 pm

Setting Up the Mining Environment

1. Install Ubuntu Server 22.04 LTS with full disk encryption and minimal package selection to reduce attack surface and improve stability.

2. Update the system repository index and upgrade all installed packages using apt update && apt upgrade -y before proceeding.

3. Install essential build tools including build-essential, cmake, libtool, and autoconf to compile mining software from source.

4. Configure kernel parameters to prevent memory overcommit and adjust swappiness to 10 via /etc/sysctl.conf for sustained computational workloads.

5. Disable GUI services and unnecessary daemons such as systemd-resolved and ModemManager to free CPU cycles and reduce background I/O pressure.

Selecting Compatible Hardware Drivers

1. Identify GPU models using lspci | grep VGA and cross-reference with supported ASIC emulators or OpenCL-compatible devices.

2. For AMD GPUs, install rocm-opencl-runtime and validate compute capability with clinfo to confirm OpenCL 2.0+ support.

3. For NVIDIA hardware, deploy nvidia-driver-535 alongside cuda-toolkit-12-3, then verify CUDA availability using nvidia-smi and nvcc --version.

4. Load kernel modules explicitly: sudo modprobe amdgpu or sudo modprobe nvidia-uvm, then persist them in /etc/modules.

5. Set GPU power limits using rocm-smi --setpoweroverdrive or nvidia-smi -pl to stabilize thermal behavior during extended hashing sessions.

Compiling and Configuring BFGMiner

1. Clone the official BFGMiner repository from GitHub and checkout the latest stable release tag instead of using master branch.

2. Run ./autogen.sh followed by ./configure --enable-scrypt --enable-x11 --enable-opencl --enable-cuda to activate relevant algorithms and backends.

3. Compile with make -j$(nproc) and install globally using sudo make install to place binaries in /usr/local/bin.

4. Generate a configuration file at ~/.bfgminer/bfgminer.conf specifying pool URL, worker credentials, device targeting, and intensity settings per GPU.

5. Launch with bfgminer --config ~/.bfgminer/bfgminer.conf --log-file /var/log/bfgminer.log --debug to capture runtime diagnostics without terminal flooding.

Securing Remote Mining Operations

1. Create a dedicated non-root user named miner with no shell access and restrict sudo privileges to only /usr/local/bin/bfgminer.

2. Bind the mining daemon to localhost only and disable JSON-RPC remote access unless absolutely required for monitoring interfaces.

3. Configure UFW to deny all incoming connections except SSH on a non-standard port and allow outbound traffic solely to known mining pool IPs.

4. Rotate API keys and worker passwords weekly using a cron job that updates bfgminer.conf and reloads the process via systemctl restart bfgminer.service.

5. Store wallet.dat backups offline and encrypt them with gpg --symmetric --cipher-algo AES256 before transferring to air-gapped storage media.

Troubleshooting Common Failures

1. If clGetPlatformIDs returns CL_PLATFORM_NOT_FOUND_KHR, reinstall ROCm stack and ensure user belongs to render and video groups.

2. When nvidia-smi shows “No running processes found” but hash rate is zero, check if persistence mode is enabled via nvidia-smi -pm 1.

3. A segmentation fault during BFGMiner startup often indicates mismatched OpenCL library versions; verify LD_LIBRARY_PATH includes correct /opt/rocm/opencl/lib/x86_64 or /usr/local/cuda/lib64.

4. Pool connection timeouts may stem from DNS resolution failures; override resolver in /etc/systemd/resolved.conf to use 1.1.1.1 and restart systemd-resolved.

5. Sudden drops in accepted shares correlate with unstable memory clocks; underclock VRAM by 200 MHz using rocm-smi --setmemclock or nvidia-settings -a [gpu:0]/GpuMemoryTransferRateOffset[3]=0.

Frequently Asked Questions

Q: Can I mine Bitcoin directly with a GPU on Ubuntu?Bitcoin’s SHA-256 algorithm is no longer viable on GPUs due to ASIC dominance; attempting it yields negligible returns and high electricity cost per terahash.

Q: Why does BFGMiner fail with “No devices detected” even after driver installation?This occurs when OpenCL or CUDA libraries are not linked correctly; verify ldconfig -p | grep opencl and ensure vendor-specific ICD files exist in /etc/OpenCL/vendors/.

Q: Is it safe to run mining software as root?No. Running as root introduces critical privilege escalation risks; always operate under a restricted account with minimal filesystem and device permissions.

Q: How do I monitor temperature and fan speed without X11?Use rocm-smi for AMD or nvidia-smi -q -d TEMPERATURE,FAN for NVIDIA; parse output with awk and log to syslog via logger in a cron loop.

Disclaimer:info@kdj.com

The information provided is not trading advice. kdj.com does not assume any responsibility for any investments made based on the information provided in this article. Cryptocurrencies are highly volatile and it is highly recommended that you invest with caution after thorough research!

If you believe that the content used on this website infringes your copyright, please contact us immediately (info@kdj.com) and we will delete it promptly.

Related knowledge

See all articles

User not found or password invalid

Your input is correct