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.

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.

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!

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!