Getting Started: How to Setup Ubuntu 18.04 for Coin Mining

So, you want to get into coin mining but are a bit awash in all the information out there.  How to just get started with a basic OS platform to build on can be challenging.  Fear not, I think I can help.

We will be using Ubuntu 18.04 a.k.a. Bionic Beaver as our base OS.  A few reasons for choosing Ubuntu.  Ubuntu is lightweight, fast, software installs/ downloads are simple, it fits on a USB stick, and mining software runs very well on Ubuntu.  If you do not have Ubuntu or would like to make a bootable Ubuntu USB stick, no problem.   Check out my article here.

To start, I would suggest using a bootable Ubuntu USB stick.  This will isolate mining from the rest of your valuable day-to-day computer OS.  Also, you can now boot into a miner on any computer.   So, when your buddy asks if it will work on her computer you can boot that baby up and get to mining.  You know, because your buddy has a rocking CPU and GPU that they employ to kick your butt in Fortnite.  “Yah, but how does it mine?”, you ask.

At this point, it is my assumption you have Ubuntu 18.04 setup and ready to go.  Ready also means the OS is fully updated.  Next steps are to load on some common software used in mining.

Common Software

Okay, let’s get some common software.  The following will provide the abilty to download from code repositories, build code, and text edit config files.  Not to mention you will be one step closer to a nerd.  Its okay, embrace the inner nerd. 
In a terminal run:

sudo apt install libmicrohttpd-dev libssl-dev cmake build-essential libhwloc-dev git curl nano

GPU Libraries

Mining utilizes both CPU and GPU processing power.  CPU we got covered but we need to install the GPU libraries.  These are CUDA for NVIDIA GPUs and OpenCL for AMD GPUs.  We will add both because you never know if you will have a system change or want to run on another system entirely.  So, let’s cover all the bases.

We will start easy with the AMD GPU library for OpenCL.  In a terminal run:

sudo apt install ocl-icd-opencl-dev
sudo apt-get install opencl-headers

For more information on OpenCL here is a helpful link:
Installation-Instructions-for-amdgpu-Graphics-Stacks

Now for NVIDIA CUDA 10.  This is a bit more step by step.  Navigate to a location in Ubuntu you would like to perform the download and  install.  Somewhere like ~/Downloads for example.

Download CUDA – In a terminal run:

sudo mkdir cuda
sudo chmod 777 cuda
cd cuda
curl -O "https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-repo-ubuntu1804_10.0.130-1_amd64.deb"

Now install CUDA.  Assuming you are in the cuda folder where we downloaded the CUDA deb. 

Install CUDA – In a terminal run:

sudo dpkg -i cuda-repo-ubuntu1804_10.0.130-1_amd64.deb
sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
sudo apt-get update
sudo apt-get install cuda

After install reboot.  This will enable CUDA.

Ubuntu Config

Mining software makes a few assumptions.  One is that Ubuntu has the ability to utilize hugepages.  Hugepages allows for larger memory allocation in the CPU.  Here is more on hugepages for more reading if you wish.

First, check to see what the hugepages is set at for your current user.  
In a terminal run:

/sbin/sysctl vm.nr_hugepages ; ulimit -l

If the result is vm.nr_hugepages = 0 then hugepages is not on.  We will now enable hugepages. 
In a terminal run:

nano /etc/sysctl.d/60-hugepages.conf

This opens the hugepages config file in Nano editor.  Add the following to the file:

vm.nr_hugepages=128

To have Nano save the changes type ctrl-O and the return key to approve saving the file.  To leave Nano type ctrl-X.

Note:  on larger CPU threaded machines you may set as 256. For, example an AMD Ryzen Threadripper 1920x.

We still have some more memory configuration to do.  Next is memlock.
In a terminal run:

sudo nano /etc/security/limits.d/60-memlock.conf

This opens the memlock config file in Nano editor.   Add the following 2 lines to the file:

* - memlock 262144
root - memlock 262144

To have Nano save the changes type ctrl-O and the return key to approve saving the file.  To leave Nano type ctrl-X.

Now reboot.  When you return open a terminal and enter the following:

/sbin/sysctl vm.nr_hugepages ; ulimit -l

You should see a response similar to:

vm.nr_hugepages = 128
262144

That’s pretty much all there is to creating an Ubuntu base to put mining software on.

Some miner suggestions:
   CPU Miner (easy) – Webchain Miner
   CPU/ GPU Miner (advanced) – XMR-STAK

You can use the Webchain Miner on Krunzy Webchain Pool to get started fast!

Hopefully you found this useful.  Throw us a few coins to say thanks.

Leave a Reply

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