How To CPU Mine Monero on LinuxsteemCreated with Sketch.

in mining •  8 years ago  (edited)

IMG_4050.PNGPersonally I really like Monero for the fact that it is completely anonymous and CPU mining is actually worth it. Currently on all of my CPUs I mine XMR. So here is a step by step guide to mining XMR with your CPU on Ubuntu.

Step 1: Get a Monero Wallet

MyMonero
Make sure you save the string of words it gives you because this is basically your password. Once you have this you'll need to copy your XMR address.

Step 2: Install dependencies

Now I will say I know how to use Ubuntu and I have built quite a few computers with this OS, but this is just a list of dependencies that if I run all of them I don't have any problems. Some of these might not be needed, but they won't hurt. You will want to open your terminal by pressing 'Ctrl+Alt+T', and copy and paste these lines into the terminal and press enter. To paste into the terminal you can not just press 'Ctrl+V' you need to press 'Ctrl+Shift+V'. And if for some reason you need to kill a process that is running in your terminal you need to press 'Ctrl+C'. So here are all the dependencies, this is easily the longest part of the tutorial.

First we will need to set up a root password. To do this:
sudo passwd root
Then type your desired password.
Now to sign in as root:
su
Now to install all the dependencies:

sudo apt-get install git
sudo add-apt-repository main
sudo add-apt-repository universe
sudo add-apt-repository restricted
sudo add-apt-repository multiverse
sudo apt-get update
sudo apt install ocl-icd-opencl-dev
sudo apt-get install libmicrohttpd-dev libssl-dev cmake build-essential
sudo apt-get install automake libtool make gcc
sudo apt-get install libjansson-dev
sudo apt-get update
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install g++-5

sudo apt-get upgrade

sudo update-initramfs -u
sudo apt-get install libopenblas-dev liblapack-dev
sudo apt-get install linux-image-generic linux-image-extra-virtual
sudo apt-get install linux-source linux-headers-generic

sudo apt-get install libglu1-mesa libxi-dev libxmu-dev -y
sudo apt-get — yes install build-essential
sudo apt-get install python-pip python-dev -y
sudo apt-get install python-numpy python-scipy -y
sudo apt-get install libglu1-mesa libxi-dev libxmu-dev libglu1-mesa-dev
sudo apt-get install apt-file && apt-file update

sudo apt-get upgrade
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:george-edison55/cmake-3.x
sudo apt-get update
sudo apt-get install cmake
sudo apt-get upgrade

Once you have installed all of these we don't want to be super user any more so type:

exit

Step 3: Download and and install xmr-stak-cpu

We will need to clone the github repository.

git clone https://github.com/fireice-uk/xmr-stak-cpu.git

Once you have done this you will now have the option to edit the donation level. To do this edit the file called 'donate-level.h', the initial amount is set to 1.0 but you can change it to 0.0 if you do not want to donate to the developers.

Now to install:
cd xmr-stak-cpu
cmake -DCMAKE_CXX_COMPILER=/usr/bin/g++-5 -DCMAKE_CC_COMPILER=/usr/bin/gcc5
make install
cd bin
chmod +x xmr-stak-cpu

Step 4: Decide how many threads you should use

To do this find out how much cache your CPU has and how many cores it has. So I have a CPU that has 4mb cache and 4 cores. In order to figure out how many threads you want to use you want to divide your cache by 2mb. So this CPU should use only 2 threads because 4mb/2mb=2.
I also have an AMD FX-9590. This has 16mb of cache and 8 cores. You would think that I should be using 8 threads, but that isn't the case. If the amount of threads you should be using is equal to the number of cores you have subtract 1. We don't want to use every core. So I mine with 7 threads on this chip because 16mb/2mb=8 and we have 8 cores so we subtract 1 and are left with 7 threads.

Step 5: Edit the config file

Once you have installed the miner you should go into xmr-stak-cpu's /bin folder and edit this 'config.txt' file. Click here to look at my config file. You will notice the section under 'cpu_threads_conf' is where you will put how many threads to use. This file is set up for 7 threads so remove as you feel necessary. Also you will need to scroll down and change the wallet address to your wallets address.

Step 6: Load Huge Pages

If you open up the config file you will notice a section outlining how to enable huge pages on Linux. But if you are lazy here is a pastebin link to what to do. At the end it will ask you to reset your computer.

Step 7: Create a start.sh file

While in the ../xmr-stak-cpu/bin repository create a file called 'start.sh'. Inside the file put this:

sudo sysctl -w vm.nr_hugepages=128
sudo ./xmr-stak-cpu config.txt

Once you have created it, in the remaining in the bin repository in the terminal put:

chmod +x start.sh

Step 9: Start up XMR-STAK-CPU

Navigate into your xmr-stak-cpu/bin folder in your terminal and become a super user.

su
sudo ./start.sh

Congradulations!! You are now mining Monero on your CPU!

If you have any other questions feel free to ask me!



Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

hey thanks for the guides, I was curious is this solo mining or pool mining? my hash is relatively low so I am thinking if solo mining I could go days and days without seeing a result

This is pool mining. You can even check your stats if you go to their site and put in your wallet address.

Hi! I am a robot. I just upvoted you! Readers might be interested in similar content by the same author:
https://steemit.com/monero/@joshmocek/how-to-mine-monero-on-your-cpu-for-windows

Thank you very much for this very straight forward guide, helped me alot even with my mediocre knowledge of CLI :)
LOL I got it working in Microsoft Azure, Ubuntu 16.04. You can keep up with my experiement here!

Can this be done on a laptop by chance? If so, what hardware will I need?

I haven't tried it on my laptop, but I'm sure it would work. If you want a super super simple miner there is Minergate. Here is their site.

Note that he makes 10% of your profits if you use his referral link...

Nice... Ill give it a shot! Any good tips I should know to help me leverage up?

Can confirm. I mined monero with minergate on a number of laptops simultaneously. If I remember correctly I got pissed off with minergate because I had to have atleast 1 Monero to transfer Moneros to elsewhere and then the charges went through the roof. That may have changed by now.

So how does it all work if you don't mind me asking?

Please also comment on https://steemit.com/baikal/@lucky.digger/baikal-miner-dash-miner if you can. Or anyone else here.

Btw... you should also make a coin Magi tutorial .. It's cpu-only

I'll have to look into it!

So is there a way to run this from a USB stick that has a version of Linux installed? Such as Ubuntu? I have tried a couple of times but the directions seem to fail when trying from a persistent USB Linux install.

Thanks buddy. Got any experience in running a raspberry pi stack with this configuration?

I don't, I really considered building one though.

Let's do. Do you think a stack will work with Orangi Pi too? Lets say 20x stack?

http://www.orangepi.org/ Let's start a project. I need a miner. I mean, a miner. I want my cables to melt.

I need molten and burnt cables... let's start a project.

Oh man, I love building computer, but that looks like way too much work lol

I don't know how to win if I don't take a chance...

Trump-Almanack.png

Lol what do you need me to do?

  ·  8 years ago 

What's the performance? Without a GPU is workable?

Yes, it should be.

Was thinking we all agree on execution as follows:

a.) PARTSLIST, agreed by you and me. We both build. The reason to project together is to learn from each other and remain motivated. Basic Orange Pi or Raspberry Pi setup depending on available hardware for 1. power supply (like usb distributor) and 2. network hub and 3. mechanical stacking components. I am sitting in Perth / Australia, I can order from RS Components for myself. But I was thinking we need a standard, so that any dude anywhere can build. Therefore really internationally available components. And dirt cheap. But so good that you can sell it to your neighbour if he wants to mine. A good quality thing you can be proud of, and kicks ass.

b.) SOFTWARE for 1. stacking/clustering so that all cores are networked together into one single CPU with lets say 40 cores or 32 cores. This should make for an excellent Monero miner. And 2. mining software optimisation, field testing. Github forks.

c.) AMORTISATION of incurred cost for a labor and materials via small scale hobby style commercialisation and keys for Github forks.

Please comment. All ideas and critisism welcome.

Guo ShuYao.jpg

Thanks

Check this please. Is it optimal config?

https://pastebin.com/MgDrPiEw

Works great on ubuntu 14.04, thanks!

https://github.com/fireice-uk/xmr-stak-cpu/blob/master/LINUXCOMPILE.md - the steps here are much shorter, especially the part about adding all the dependency files.

  ·  8 years ago (edited)

You just made it so complicated... just download MinerGate linux app...
https://minergate.com/downloads/gui
Create your account and clic "Start" on Monero. i just wonder if you found this to be better concerning Hashrate.

You get about double the hashrate with this. And minergates algorithms kind of suck. Their uncle rate with ethereum is by far the worst out of all the pools.

Step 2 seems to be optimized/shorter here from the official xmr-stak-cpu:
https://github.com/fireice-uk/xmr-stak-cpu/blob/master/LINUXCOMPILE.md

thanks for the helpful article!

How can I see my mining running total? I don't see anything showing up in my wallet

when i check the page provided I don't see the hash rate that my terminal is displaying. I see no hash rate at all. any suggestions?

good guide, thanks!