Sunday, August 21, 2016
Ethereum mining on Ubuntu Linux
For a couple months, I've been intending to do a blog post on mining with Ubuntu. Now that I've been able do make a static build of Genoil's ethminer, that process has become much easier. Since I have no Nvidia GPUs, this post will only cover how to mine with AMD GPUs like the R7 and R9 series.
The first step is to download a 64-bit Ubuntu 14.04 desktop release. I use the desktop distribution since it includes X11, although it is possible to use Ubuntu server and then install the X11 packages separately. I recommend installing Ubuntu without any GPU cards installed (use your motherboard's iGPU), in order to confirm the base system is working OK. Follow the installation instructions, and at step 7, choose "Log in automatically". This will make it easier to have your rig start mining automatically after reboot.
After the initial reboot, I recommend installing ssh server. It can be installed from the shell (terminal) with: "sudo apt-get install openssh-server -y". Ubuntu uses mDNS, so if you chose 'rig1' as the computer name during the installation, you can ssh to 'rig1.local' from other computers on your LAN.
Shutdown the computer and install the first GPU card, and plug your monitor into the GPU card instead of the iGPU video port. Most motherboards will default to using the GPU card when it is installed, and if not, there should be a BIOS setup option to choose between them. If you do not even see a boot screen, try plugging the card directly into the motherboard instead of using a riser. Also double-check your card's PCI-e power connections.
Once you are successfully booting into the Ubuntu desktop, edit /etc/init/gpu-manager.conf to keep gpu manager from modifying /etc/X11/xorg.conf. Then install the AMD fglrx video drivers: "sudo apt-get install fglrx -y". If the fglrx drivers installed successfully, running "sudo aticonfig --lsa" will show your installed card. Next, to set up your xorg.conf file, run "sudo rm /etc/X11/xorg.conf" and "sudo aticonfig --initial --adapter=all".
After rebooting, if the computer does not boot into the X11 desktop, ssh into the computer and verify that /etc/modprobe.d/fglrx-core.conf was created when the fglrx driver was installed. This keeps Ubuntu from loading the open-source radeon drivers, which will conflict with the proprietary fglrx drivers. For additional debugging, look at the /var/log/Xorg.0.log file.
Continue with installing the rest of your cards one at a time. Re-initialize your xorg.conf each time, by executing "sudo rm /etc/X11/xorg.conf" and "sudo aticonfig --initial --adapter=all". Reboot one more time, and then exeucte, "aticonfig --odgc --adapter=all". This will display all the cards and their core/memory clocks. If you are connecting remotely via ssh, you need to run, "export DISPLAY=:0" or you will get the "X needs to be running..." error. You can use aticonfig to change the clock speeds on your card. For example, "aticonfig --od-enable --adapter=2 --odsc 820,1500" will set card #2 to 820Mhz core and 1500Mhz memory (a good speed for most R9 380 cards). To simplify setting clock speeds on different cards, I created a script which reads a list of card types and clock rates from a clocks.txt file.
Once your cards are installed and configured, you can use my ethminer build:
wget github.com/nerdralph/ethminer-nr/raw/110/releases/ethminer-1.1.9nr-OCL.tgz
tar xzf ethminer-1.1.9nr-OCL.tgz
cd ethminer-nr
./mine.sh
Once you've confirmed that ethminer is working, you can edit the mine.sh script to use your own mining pool account. If you want your rig to start mining automatically on boot-up, edit your .bashrc and add "cd ethminer-nr" and "./mine.sh" to the end of the file.