In this tutorial you will learn how to configure Linux on a mining computer that uses Nvidia GPU’s. We will also configure the computer to use SSH, so we can control the computer from another computer. The main advantage of setting up your mining computer using SSH is primarily because if you have multiple mining computers, you can control all of them from a main desktop or laptop that is connected to the same network. You also don’t have to have an extra keyboard, mouse and monitor plugged into all of your mining computers this way.

Linux Cryptocurrency Mining Guide

The main reason for writing this article is to guide you through the process of installing the Nvidia drivers, and configuring the GPU’s, so one can control the fan speed and other GPU settings.

Choosing the Linux Distribution

Since we want to use an SSH setup, we do not need a GUI for our mining computer. Because of this, I have chosen Ubuntu Server for our Linux distribution.

At the time of writing this (4/14/2018) We are about 12 days away from the release of Ubuntu 18.04 LTS. The LTS version of Ubuntu server, is the one we want to download. This is because the LTS version provides updates for about five years after the release date. We want the long term update version, since we will download drivers from their package repository. The non LTS versions only provide updates for nine months, meaning we would have to reinstall or update the OS every nine months, instead of five years. Plus the LTS version makes the process easy to update from one LTS version to the next LTS version, without reinstalling the OS.

Make sure you download the 16.04 LTS version if you’re reading this before 4/26/2018 otherwise download the 18.04 LTS version. I will be using the beta version of 18.04 since this is the future OS for the Ubuntu server, and I need to write this article for Ubuntu 18.04. I DO NOT suggest using a beta version for your mining computer, so it may be best to just wait until the official Ubuntu 18.04 server is released. I am just using the beta so I can write the tutorial for the future Ubuntu 18.04 and not the old Ubuntu 16.04.

Create the bootable disk

Once you have download the ISO file, you have to write the file to a DVD or a USB drive, and make it bootable. I prefer to write it to a USB drive, so I will explain this in the tutorial.

I use rufus to create my bootable USB drives. Rufus only runs on Windows. Just download rufus, and then plug in the USB drive you want to create the bootable ISO file.

Note: The USB drive you make bootable will lose all of its data, so make sure the USB drive is empty before going any further. Do not select your hard drive, otherwise it will erase your computer’s hard drive that your working on. Make sure you have selected a USB drive and not your Windows hard drive. For this reason I have a separate USB drive that I only use for this purpose.

Now run the rufus file, and you should see something like this

The red arrow indicates the USB drive you want to write the Linux ISO file to.

Note: The USB drive you make bootable will lose all of its data, so make sure the USB drive is empty before going any further. Do not select your hard drive, otherwise it will erase your computer’s hard drive that your working on. Make sure you have selected a USB drive and not your Windows hard drive. For this reason I have a separate USB drive that I only use for this purpose.

The blue arrow indicates the partition scheme you want for your mining computer. I usually use the last selection “GPT partition scheme for UEFI”. To use this partition scheme, you need to have a motherboard that supports UEFI, so you will need to check your motherboard’s specifications. If not use the first selection “MBR partition scheme for BIOS or UEFI”.

The next step is to click the first red box in the picture (the one with the dvd on the hard drive image) and select the ISO file.

The green arrow indicates the name of the USB drive. I just used the default name.

Once you have made sure you have filled out all of the settings correctly, click the start button. This can take a few minutes to a few hours, depending on the speed of the USB drive and the size of the ISO file.

Install the Linux OS

Once it is completed, you need to install the Linux OS on your mining rig. I am not going to explain this process, since it is pretty straightforward and varies because of each individuals hardware. I will however give a brief overview of how I installed the Linux OS.

You will need a keyboard, mouse and monitor connected to the mining computer to install the Linux OS.

First I booted up the computer and went into the BIOS. I changed the boot priority of the machine to boot from the USB first. I then saved and exited the BIOS. I then rebooted the machine with the bootable Linux USB drive inserted in the machine.

Next I followed the installation instructions.

Update the Linux OS

Now that you have installed Linux, you should login to the username that you created during the installation process.

The first step is to update the system. We can do this by using:

sudo apt-get update && sudo apt-get upgrade

The next step is to install the SSH server

sudo apt-get install openssh-server

My computer already said it was installed, but you need to install it if it is not.

Next we need to get some information about our network. We will need this information to connect to the mining computer using SSH, and to setup a static IP address for the mining computer. We need the following network settings:

Local IP address
Netmask
Netmask CIDR
Gateway
Interface

Type:

ifconfig | grep netmask

The Local IP address is the ip address that starts with 192.168 in the example above it is 192.168.1.71

The netmask is the netmask address that is on the same row as the local IP address. In the example above it is 255.255.255.0

Now type:

netstat -r -n

The gateway is the address that is not 0.0.0.0 in the example above it is 192.168.1.254

The interface is Iface on the same row as the gateway. In the example above it is enp1s0

We now need to calculate the CIDR for your netmask address. To do this run this command and replace “255.255.255.0” with your netmask IP address.

IFS=’.’ read -ra IPADDRESS <<< "255.255.255.0" && IPADDRESSZERO=`(echo "obase=2;${IPADDRESS[0]}" | bc)` && IPADDRESSONE=`(echo "obase=2;${IPADDRESS[1]}" | bc)` && IPADDRESSTWO=`(echo "obase=2;${IPADDRESS[2]}" | bc)` && IPADDRESSTHREE=`(echo "obase=2;${IPADDRESS[3]}" | bc)` && echo -n $IPADDRESSZERO$IPADDRESSONE$IPADDRESSTWO$IPADDRESSTHREE | awk -F'1' 'NF{print NF-1}'

You should get a number between 24-30. In the above example I get 24.

At this point we can finish the rest of the tutorial from your main computer using the SSH feature. You can now unplug the keyboard, mouse and monitor from the mining computer.

Connect to the mining computer using SSH using a Windows system

If your main computer is Mac or Linux you will already have an SSH client installed. If your main computer is Windows, you will need to download putty. I like the non installing file, so I scroll down to the alternative binary files, and download the putty.exe

Once you have putty downloaded, open the file and you should see something like this

The only thing you need to fill out is the IP address, and then press open.

Here is my setup

If any warning boxes appear, just click on yes.

It should then ask you to login (using your username and password that you setup in the installation of the Linux OS)

Connect to the mining computer using SSH using a Linux or Mac system

To connect to your mining computer using SSH, open up a terminal and type in:

ssh IP_address_of_mining_computer

For example I would use:

ssh 192.168.1.71

It should then ask you to login (using your username and password that you setup in the installation of the Linux OS)

Configure a static local IP Address

First we need to set a static local IP address for the mining computer. If we don’t, it may change the IP address after every reboot. I suggest setting the static IP address to the IP address it gave you when you typed in ifconfig, this way we won’t assign it an IP address already in use by another system on the network.

The network file is located in a different place in Ubuntu 18.04 compared to the previous versions of Ubuntu, and it uses the YAML format instead of text.

To find the network file type

ls /etc/netplan/

It should list one file. For me it listed “50-cloud-init.yaml”

Open the file by typing in:

sudo nano /etc/netplan/50-cloud-init.yaml

You should see something like this

Change it so it looks like this

For the address you want to type in the ip address you want (I suggest using the one it gave you in ifconfig) at the end you need to type in / and then the Netmask CIDR we calculated earlier. Then make sure DHCP for both IPV4 and IPV6 is turned off, and type in the IP address for your network’s gateway.

Save the file by pressing Control + X and then Y and then Enter. You should now automatically return back to the command line.

Then reboot the system:

sudo reboot now

Then reconnect to the system using SSH and your assigned IP address.

Configure the GPU drivers

Now we need to install the Linux Headers using:

sudo apt-get install -y linux-headers-$(uname -r)

You may already have the latest headers.

Now we need to install the xorg dev package

sudo apt-get install xorg-dev

Now reboot:

sudo reboot now

Next we need to add the PPA for the graphics-drivers:

sudo apt-add-repository ppa:graphics-drivers/ppa

Now we need to update APT so it knows about the latest drivers in the PPA

sudo apt-get update

Now we need to figure out what drivers are the latest drivers. You can find this out by visiting the Graphics Drivers PPA Scroll down to the bottom and look at the entry that says “nvidia-graphics-drivers-” for example the latest ones at the time of writing this article (4/14/2018) is “nvidia-graphics-drivers-396”

Now install the drivers as well as CUDA

sudo apt install -y nvidia-396 nvidia-cuda-toolkit

the files are big (around 1GB) so it may take a while

When it is done installing you need to check if it installed correctly using

lsmod | grep nvidia

If nothing returns, then the driver installation failed, otherwise it should show something like this

Now we need to create the Nvidia config file

sudo nvidia-xconfig -a --cool-bits=31 --allow-empty-initial-configuration

You should see something like this

If it gives you an error, reboot and try to create the Nvidia config file again.

Now make sure all of the GPU’s are detected in your system

nvidia-smi

As you can see it has detected the GT 1030 in the computer.

It also shows you the fan speed, temperature and power usage per GPU.

Now reboot

sudo reboot now

Now we need to login as root

sudo su root

To configure the fan speed, core clock or memory speed we need to start xorg and then tell the system that our main display is the SSH console.

X :1 &

The computer console should not give any errors, but it will not return back to the username at the command line. Then type in

export DISPLAY=:1

Then it should return back to the username at the command line.

Configure the GPUs

Note: changing the fan speed, GPU core clock and GPU memory clock could damage the GPU and or shorten the life of the GPU. Make sure you know what your doing if you try to edit these settings. I am not endorsing or advocating the fact that you should try to change any of these GPU settings.

To change the fan speed you can use

nvidia-settings -a [gpu:index_of_GPU]/GPUFanControlState=1 -a [fan:0]/GPUTargetFanSpeed=fan_speed_percentage

For example to turn the fan speed to 100 on GPU 0 I would use:

nvidia-settings -a [gpu:0]/GPUFanControlState=1 -a [fan:0]/GPUTargetFanSpeed=100

To change the GPU core clock speed, you use

nvidia-settings -a '[gpu:index_of_GPU]/GPUGraphicsClockOffset[3]=+or-offset'

You can use + or – to increase or decrease the speed by the offset. For example to increase the core clock by 1 we would use

nvidia-settings -a '[GPU:0]/GPUGraphicsClockOffset[3]=+1'

To set the GPU memory speed you would use

nvidia-settings -a '[gpu:index_of_GPU]/GPUMemoryTransferRateOffset[3]=memory_speed'

For example to set the memory speed to 3010 we would use

nvidia-settings -a '[gpu:0]/GPUMemoryTransferRateOffset[3]=3010'

Download the mining software

Okay now it is time to start mining. Most mining computers that use Nvidia and Linux are built to mine equihash coins. Because of this we will follow a previous tutorial I have written on how to mine Bitcoin Private I will not be going into the details on how to setup the command line configuration, so make sure you follow the tutorial.

We now need to create a folder for our mining software. I chose to create a folder in my home directory called “mining_software”

Change the directory to the home directory

cd home/zach

Now create the folder

mkdir mining_software

Now give ownership of the folder to your username

chown username mining_software

In my case I would use

chown zach mining_software

Now we need to install EWBF miner You can read more about it in the Bitcoin Private tutorial.

Download the tar file on your main computer (Windows, Mac, Linux)

If your using Windows, we need to download pscp for Windows. This is a scp client for windows created by the same people who made putty. Then make sure both the pscp.exe and the EWBF file are located in the same folder. Now open a command window in that folder.

If you have Mac or Linux installed you have scp built in. Open a terminal in the folder where the EWBF file was downloaded.

To copy the EWBF software from your main computer to your mining computer we need to use

If using Windows:

pscp file username@ipaddress:/folder/

If using Mac or Linux:

scp file username@ipaddress:/folder/

I am using Windows, so my command line configuration is

pscp "Zec Miner 0.3.4b Linux Bin.tar.gz" zach@192.168.1.71:/home/zach/mining_software

Now check if the file was copied over

Change directory to the mining_software folder

cd mining_software

Then type

ls

It should show the only file being the EWBF mining software.

Once the file has copied we can close the scp or pscp windows on our main computer

Now we need to extract the mining software.

tar -xf "Zec Miner 0.3.4b Linux Bin.tar.gz"

Then check if the miner has been extracted

ls

Then remove the tar file

rm "Zec Miner 0.3.4b Linux Bin.tar.gz"

Then check if the file has been deleted

ls

Then change directories to the miner folder

cd 0.3.4b

Then create a new file with the command line configuration for the miner. Refer to the Bitcoin private tutorial on how to configure your command line parameters. For example I am using

./miner --server us.btcprivate.pro --port 2827 --user b1PR4MkpD5BpRu6BUbX1uCz9ptuPzjoY3FP.miningcomputer4 --pass x --pec --api 0.0.0.0:8000

Save this in a script file by typing

echo nohup ./miner --server us.btcprivate.pro --port 2827 --user b1PR4MkpD5BpRu6BUbX1uCz9ptuPzjoY3FP.miningcomputer4 --pass x --pec --api 0.0.0.0:8000 & >> mine_BTCP.sh

We use ip address 0.0.0.0 for the API so we can check it on another device that is connected to the network

The nohup and the & at the end, allows us to run the mining software when we disconnect from the SSH client.

Next make the script file executable by typing

chmod 700 mine_BTCP.sh

Then start the script by typing

./mine_BTCP.sh

Then press Control + C

The miner should be running in the background now. You can now disconnect from the SSH client, and monitor the mining computer from a web browser on any device connected to the network.

When you connect to the mining computer using the SSH client, if you need to stop the mining software type

ps -eaf

Look for the PID of the mining software. You can tell it is the mining software, because the process will have ./miner in the description. In my example it is 2109

Then type

sudo kill 2109

That’s it. You should now be mining BTCP!

How to update drivers

To update drivers, you will need to remove the old driver using

sudo apt-get purge nvidia*

Then reboot the system

sudo reboot now

Now we need to update APT so it knows about the latest drivers in the PPA

sudo apt-get update

Now we need to figure out what drivers are the latest drivers. You can find this out by visiting the Graphics Drivers PPA Scroll down to the bottom and look at the entry that says “nvidia-graphics-drivers-” for example the latest ones at the time of writing this article (4/14/2018) is “nvidia-graphics-drivers-396”

Now install the drivers

sudo apt install -y nvidia-396

When it is done installing, you need to check if it installed correctly using

lsmod | grep nvidia

If nothing returns, then the driver installation failed, otherwise it should show something like this

Now make sure all of the GPU’s are detected in your system

nvidia-smi

That’s it. You should now figure out what coin you want to mine on your new Linux and Nvidia mining system. You can browse all of the Blockonomi mining articles to learn about different coins, and learn how to mine them!


Buy Crypto    Trade Crypto
eToro Risk Warning: 66% of retail investor accounts lose money when trading CFDs with this provider. You should consider whether you can afford to take the high risk of losing your money.

Avatar

Posted by Zach Hildreth

I am a developer who programs websites, games, software and is knowledgeable about cyber security. I have been a cryptocurrency investor, since 2013, and have been interested in cryptocurrency mining, trading and writing since 2016.


All content on Blockonomi.com is provided solely for informational purposes, and is not an offer to buy or sell or a solicitation of an offer to buy or sell any security, product, service or investment. The opinions expressed in this Site do not constitute investment advice and independent financial advice should be sought where appropriate.

18 Comments

  1. Avatar

    Hi Zach!
    I am the co-founder of PiMP, the Portable instant Mining Platform. For the last 6 years we have made a Linux mining OS with all the packages, drivers and miners pre-installed – we believe its the easiest way to start mining with Linux. Once the OS image is booted and validated, a few simple commands is all it takes to select a miner and start mining.
    We invite you to check it out; we have an active community on Discord and our own support forum where you can ask questions and get help both before and after you buy.
    We are By Miners, For Miners, and we thank you for your support!

    Reply

  2. Avatar

    When I stopped putty, it stopped the mining software. How do I get it to continue to run when I exit SSH?

    Reply

    1. Avatar

      Hi JayPee,

      I have in the article that inside your mine_coin.sh script you need to add nohup in the front and & in the back

      echo nohup ./miner –server us.btcprivate.pro –port 2827 –user b1PR4MkpD5BpRu6BUbX1uCz9ptuPzjoY3FP.miningcomputer4 –pass x –pec –api 0.0.0.0:8000 & >> mine_BTCP.sh

      then after you run it press Control + C.
      you then can exit the SSH console.

      If that still does not work for you their is a different way using screen

      install screen
      sudo apt-get install screen

      then create your mine_coin.sh without the nohup and the &
      echo ./miner –server us.btcprivate.pro –port 2827 –user b1PR4MkpD5BpRu6BUbX1uCz9ptuPzjoY3FP.miningcomputer4 –pass x –pec –api 0.0.0.0:8000 >> mine_BTCP.sh

      then run the script by using screen
      screen -dmS BTCPmining

      then exit the SSH console.

      when you want to stop mining
      log back into SSH and then type
      screen -x BTCPmining

      then it should show you the mining output and you can just press Control + C to stop the mining software.

      Let me know if they both work for you or just the screen command,
      so I can update the article with both ways.

      Reply

      1. Avatar

        I typed the wrong screen command it should be
        screen -dmS BTCPmining mine_BTCP.sh

        to start the mining software

        Reply

        1. Avatar

          Hi
          I having trouble transfering the tar.gz over to Linux.
          I got the folder over ok but I can’t open it from CMD and can’t see the tar inside the mining_software folder
          I think it may have to do with permission s or .? I can extract from GUI and got the tar file extracted that way . Mystery to me is the GUI home folder seems to be a second folder or different folder than the cmd home
          Newbie question probably
          Thanks

          Reply

          1. Avatar

            reply to myself but if Zach your out there and everyone .I just thought id say i am around this problem.

  3. Avatar

    I am trying to set up a mining rig with ubuntu 18.04, but with gnome. I can get 6 nvidia cards running, but once I add the seventh, gnome will not start. I am not sure how to proceed.

    zach, any help is appreciated.

    Reply

  4. Avatar

    Hello!
    Thank you for this guide, but i have a problem. When i installed the nvidia driver, lsmod didnt work, so i rebooted and now it gives error not enough memory and goes into kernel panic. I have 8GB od ddr4 memory on it. When i run previous kernel before nvidia drivers, it boots fine.

    Reply

  5. Avatar

    I’m stuck on installing nvidia-396. I keep getting the error message unable to locate package nvidia:396 and nvidia-cuda-toolkit
    Is there a way around this?

    Reply

    1. Avatar

      did you add the PPA to your system? that sounds like that may be the issue

      sudo apt-add-repository ppa:graphics-drivers/ppa
      sudo apt-get update
      sudo apt install -y nvidia-396 nvidia-cuda-toolkit

      let me know if this fixes the issue

      Reply

      1. Avatar

        Not for me :'(

        Distributor ID: Ubuntu
        Description: Ubuntu 18.04.1 LTS
        Release: 18.04
        Codename: bionic

        Reply

  6. Avatar

    I’m having the same issues Seth everything worked fine until I started trying to install the drivers. I figured out the mistake but now it’s to late so I need to figure out how to undo everything to just before I started the driver installations. Reboot, reboot, reboot! If you hit a step that you can’t get it to work on stop do a reboot and then try, every time I had an issue if I had just rebooted it would have saved me a lot of time. I’m going to do a fresh install tomorrow and start over just reboot after every step. Thx for the guide Zach appreciate the effort and help.

    Reply

    1. Avatar

      Thanks for the comment. Yes I agree reboots usually will fix problems with the linux GPU drivers

      Reply

  7. Avatar

    Hey Zach, thanks for this great guide!

    Everything was great until I had to download the PPA drivers “nvidia-396”. I also got the “E: unable to locate package package-name” error when trying to download it.

    I spent close to 6 hours troubleshooting this and I finally managed to figured it out. It might be worth updating your article (with a note) with this info because I have no doubt a lot of people will run into the same issue

    “nvidia-396” does not exist, or at least it does, but the naming convention has changed. That error is simply due to failing to find it on the repositories.

    The correct package name ended up been “nvidia-driver-396”. As soon as I entered this name, everything downloaded and worked perfectly. I was up and running!

    Along the way, I came across the package “ubuntu-drivers” which gave me all the driver information I was after, I recommended running it after adding the PPA repository.

    *** Make sure your GPUs are actually plugged in at this point and not using the onboard one (easy mistake!)

    % sudo apt-get install ubuntu-drivers-common

    % ubuntu-drivers devices

    == /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==
    modalias : pci:v000010DEd00001B06sv00003842sd00006393bc03sc00i00
    vendor : NVIDIA Corporation
    model : GP102 [GeForce GTX 1080 Ti]
    driver : nvidia-driver-390 – third-party free
    driver : nvidia-driver-396 – third-party free recommended
    driver : xserver-xorg-video-nouveau – distro free builtin

    % sudo apt install -y nvidia-driver-396 nvidia-cuda-toolkit

    % sudo reboot now

    Reply

    1. Avatar

      Thanks for this cutial piece of iformation! 😉
      Helped me to install the NVIDIA driver.

      But I still have the same issue with the nvidia-cuda-toolkit package! 🙁
      Need help!

      Reply

  8. Avatar

    Try FluneOs based on Xubuntu. It’s quite new distribution .. premiere was at 13.08.18. IT free (also free of charge 🙂 ) and OpenSource Linux distribution for CryptoMining created by the team of volunteers inspired by freedom and independence of software.

    Reply

    1. Avatar

      missed link :).. www.fluen.org

      Reply

  9. Avatar

    Save yourself some time! Install Ubuntu Studio and your graphics cards will be preconfigured. You will have a gui, but you will also have puredata, Jack, Blender, and Video Editing software ;p

    Determine if it is worth it for you to experiment with an awesome distro for content producers 🙂

    Reply

Leave a reply

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