[Guide] CPU mining using Linux (Ubuntu)
-
For the past weeks I have been refining my process and recycling old hardware into mining rigs, simply just for CPU mining. To make life easier I wrote down everything so I could repeat the process over and over. So this has been proven to work perfectly well for me and I decided to share it, after all, I have [url=http://en.wikipedia.org/wiki/ShareReactor]experience with sharing[/url] :)
First you need a computer and setup a basic Linux on it. For the sake of this guide, I used Ubuntu Server 13.04, both the 32 bit and the 64 bit version. If your computer can take it (and it should if it’s anything recent) use the 64 bit one. You can get an image at the [url=http://www.ubuntu.com/download/server]Ubuntu website[/url]. There are many ways to install it (burn it to CD, put it on a USB stick), but this would make this guide explode. You can find many good guides out there, but the entire process is pretty much straight forward. The only thing I advise you to make certain is when it asks you what the machine is supposed to be doing, the top spot is “OpenSSH server”, there you should select that (hit space) and leave the others alone. With that you can use a client ([url=http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html]putty[/url] for example) to ssh into the machine from a more comfortable setup, where you can also copy paste the commands into.
So now you should be connected to your machine with the user account you created during setup. Something like “user@machine:” is on your screen. To do all that is needed, you have to change to root though. You can do it with the following command and then entering your own users password (not the root password):
[tt]sudo -s[/tt]
As root, I suggest doing these commands to make sure your machine is up to date:
[tt]aptitude update
aptitude safe-upgrade[/tt]A reboot and then getting back into being root like before is adviseable here, since mostly you will get a kernel update, even in recent downloaded images.
Time to install the tools needed to do the work.
[tt]aptitude install make gcc m4 automake libevent-dev zlibc zlib1g-dev libjansson-dev libcurl4-openssl-dev git[/tt]
Now run the following commands, one by one and keep an eye out for errors. I did not get any with a dozen different installs, but you never know. Since you download from github here, there might be one souce of errors. If that fails, make sure the internet connection works.
[tt]cd /usr/local/
git clone git://github.com/pooler/cpuminer.git
cd cpuminer/
./autogen.sh
./configure CFLAGS=“-O3”
make[/tt]The cpuminer is now built. You could give it a spin with “./minerd --help” to see if it’s there and looks like it compiled correctly. Now you could start right away, but instead, I want to give you a great tool into your hands, that will make sure your cpuminer starts every time your miner machine is running.
Take the content below and edit it to your needs.
Change the part after -o (small letter O) to the address for your pool, including the port number.
The -u part is your username. Many pools use first the account name followed by a dot and then a configureable name, so you can name multiple miners and keep an eye on each seperately. Those workers you can usually configure on the pools website, or in some cases they tell you to use the payout address as username. Look very carefully how to configure this! If you leave it like this, you will mine for me instead.
Behind the -p comes the password for that user. Most pools have a standard of x or 1 as password. Again, be very careful to set this right or your work will not be counted.IMPORTANT: Change the -t part. I left it at 1 for this example to not floor your machine. Set this to the number of cores in your machine. If you have many and do other things on it as well (or also GPU mining) I suggest using the maximum number and then reduce it by 1. Not sure how to get the number of cores? run this command:
[tt]grep -c ^processor /proc/cpuinfo[/tt]
It will output a number that you can use straight away.
A small side note, I’m using the nice utility here to lower the priority of the cpu miner slightly. All this does is make it possible for you to still manage the machine even if you go full speed ahead with CPU mining. It will not lower your hashrate while the machine is doing nothing but mining. Nice levels mean the higher the number, the lower the priority (20 the lowest, -20 the highest). You can adjust if you feel the need.
Create it with an editor:
[tt]nano /etc/init.d/minerd[/tt]
Paste the content below, after editing it.
[b]WARNING[/b] If you do not edit this, then you will mine for me, not for yourself. Read above, it describes everything in as much detail as I can muster. Again, [b]change pool, user and password to yours![/b]
[code]#!/bin/bash
# minerd cpu miner
# USAGE: start|stop
#
case “$1” in
start)
echo “Starting CPU miner.”
/usr/bin/nice -5 /usr/local/cpuminer/minerd -a scrypt -t 1 -o http://pool.d2.cc:9344 -u ChristianRiesen.tutorial -p x -B -q > /dev/null
;;
stop)
echo “Stopping CPU miner.”
killall -q -w minerd
;;
*)
echo “CPU miner”
echo $“Usage: $0 {start|stop}”
exit 1
esac
exit 0[/code]To make it start and stop automatically, execute these commands now:
[tt]chmod a+x /etc/init.d/minerd
cd /etc/rc2.d/
ln -s …/init.d/minerd S99minerd[/tt]When your computer starts, it will automatically start the cpuminer now.
Should you want to stop it on your own, you can, as root, execute the following command:
[tt]/etc/init.d/minerd start[/tt]
And to stop of course:
[tt]/etc/init.d/minerd stop[/tt]
[b]FAQ:[/b]
It says something about aptitude not found?
aptitude is a programm that is standard in Ubuntu 13.04, in older versions you might need to install it first with this:
[tt]apt-get install aptitude[/tt]
[b]Thanks for reading![/b]
If you enjoyed this guide and you got some coins rolling in, I’m always grateful for a donation, even a small one. Drop me a note as well so I can say thanks :)
FTC: 6ivPQHp6TY9r3qmQoJktogwUD65TLchdepIf you have anything to add, problems, anything, don’t hesitate to contact me or post here and I will revise it.
-
A very nice and concise guide ChristianRiesen and I love that you’re using nano as opposed to the other editors out there, nano has been, by far, a godsend at speeding and making edits easy for me :P
Also, just to note. Ubuntu doesn’t come with aptitude installed (At least on 11.10 it doesn’t.)
Easily fixed and solved by running:
[code]apt-get install aptitude
aptitude update
aptitude upgrade[/code] -
Thanks for the feedback :)
I used pico before nano was born, simply because it makes most small edits so much easier. And specially for copy pasting nano usually does the trick well.
aptitude is standard since I think Ubuntu 12. So the guide going for Ubuntu 13 has it for sure installed, but thanks for the input, I will add it to the guide.
-
[quote name=“ChristianRiesen” post=“1759” timestamp=“1368091367”]
Thanks for the feedback :)I used pico before nano was born, simply because it makes most small edits so much easier. And specially for copy pasting nano usually does the trick well.
aptitude is standard since I think Ubuntu 12. So the guide going for Ubuntu 13 has it for sure installed, but thanks for the input, I will add it to the guide.
[/quote]
Just trying to help out where I can, some people don’t want to upgrade their OS due to compatibility (or lack of) issues. But, giving a once over of your guide again I really can’t see any other problems aside from aptitude. ^_^Edit: I know to you and I this is plain obvious, but you want want to note and inform people to substitute in their own pool/worker details. Unfortunately I’ve come to realize that not everyone is blessed with a decent or acceptable level of common sense. x:
[code]/usr/bin/nice -5 /usr/local/cpuminer/minerd -a scrypt -t 1 -o http://pool.d2.cc:9344 -u ChristianRiesen.tutorial -p x -B -q > /dev/null
;;
stop)[/code] -
I wrote a whole block about it, but I think I add another warning, thanks :)
-
[quote name=“ChristianRiesen” post=“1765” timestamp=“1368092701”]
I wrote a whole block about it, but I think I add another warning, thanks :)
[/quote]
There’s many a person out there that won’t read the block text but just look at the italics and code. And just hop, skip and jump past all the ‘boring’ stuff. >.< -
Thanks! I will add this to the main ‘guide’ topic!
-
[quote name=“ShadowEW” post=“1767” timestamp=“1368092829”]
[quote author=ChristianRiesen link=topic=321.msg1765#msg1765 date=1368092701]
I wrote a whole block about it, but I think I add another warning, thanks :)
[/quote]
There’s many a person out there that won’t read the block text but just look at the italics and code. And just hop, skip and jump past all the ‘boring’ stuff. >.<
[/quote]
I know. I don’t get how people can make anything work that way. I could just make a shellscript they can run and then I have lots of people mining for me ;) -
Don’t forget you can use apt-get instead of aptitude if it’s not installed and you don’t want to for some reason.
Nice guide, Ubuntu is my distro of choice too.
-
Okay, everything is working manually but when I try doing this:
[quote]
chmod a+x /etc/init.d/minerd
cd /etc/rc2.d/
ln -s …/init.d/minerd S99minerd[/quote]It says:
[quote]ln: failed to create symbolic link ‘S99minerd’: File exists[/quote]
Any idea what I need to do in order to get it to launch by itself every time?
Okay, and weird, last night it was working and showing me a hash rate but now it’s just detecting blocks. All I did was move the computer from one location to another; what’d I do?
-
Install failed. Log at https://dl.dropboxusercontent.com/u/4071418/config.log
Any suggestions?
-
[quote name=“jimwalton7” post=“33293” timestamp=“1383609515”]
Install failed. Log at https://dl.dropboxusercontent.com/u/4071418/config.logAny suggestions?
[/quote]
Your dropbox is 404’d to boot. Ever figure it out? -
[quote name=“ChristianRiesen” post=“1750” timestamp=“1368090415”]
[tt]aptitude install make gcc m4 automake libevent-dev zlibc zlib1g-dev libjansson-dev libcurl4-openssl-dev git[/tt]
[/quote]Great guide! I just wanted to point out though that instead of aptitude to install make gcc m4 and automake you can just:
[tt]apt-get install build-essential libevent-dev zlibc zlib1g-dev libjansson-dev libcurl4-openssl-dev git[/tt]
build-essential will install all you need for compiling
-
Quick question for those with the linux knowhow. If you did this:
[code]To make it start and stop automatically, execute these commands now:
chmod a+x /etc/init.d/minerd
cd /etc/rc2.d/
ln -s …/init.d/minerd S99minerd[/code]How do you tell it to NOT start automatically at boot?
-
First thank you very much for this write up (what is an appropriate FTC tip amount)
Second I am having a small issue (Linux Ubuntu)
Everything went very smooth except for the following:
zlib1g-dev This is a number 1 in front of the g? Or lowercase L? I can’t find this package
And Theese are my errors
Checking for gawk… No
Checking wether to enable maintainer-specific portions of makefiles…no
Checking wether the C compiler works…no
Configure error: in ‘/usr/local/cpuminer’:
Configure: error: c compiler cannot create executablesUPDATE: working and hashing Yay!!!
Fix: do the following
autoconf
automake
bison
build-essential
flex
gawk
libtoolYou should be OK for compiling then.